add code for project and sub-project

This commit is contained in:
Pawan Kumar 2021-02-24 23:38:16 +05:30
parent 2e6a1e8a49
commit d35031f50e
3 changed files with 56 additions and 5 deletions

View File

@ -189,6 +189,7 @@
<field name="view_mode">tree,kanban,form</field>
<field name="view_id" ref="project.view_project"/>
<field name="search_view_id" ref="project.view_project_project_filter"/>
<field name="domain">[('is_sub_project', '=', False)]</field>
<field name="target">main</field>
<field name="help" type="html">
<p class="o_view_nocontent_smiling_face">

View File

@ -8,6 +8,18 @@ class SubProject(models.Model):
is_sub_project = fields.Boolean("Is Sub Project")
sub_project = fields.Many2many('project.project', 'project_subproject_rel', 'project_id', 'id',
domain="[('is_sub_project', '=', True)]", string='Sub Project')
parent_project = fields.Many2one('project.project', string='Parent Project')
@api.depends('sub_project')
def onchange_parent_project_sub_project(self):
for record in self:
if record.sub_project:
print('111111111', record.sub_project)
for rec in record.sub_project:
print('2222222', rec, record.id, record._origin.id)
#print('2222222AAAAAAAAAAAA', rec.parent_project)
#rec.write({'parent_project' : record._origin.id})
# print('3333333', rec.parent_project)
class InheritProjectTask(models.Model):

View File

@ -11,8 +11,12 @@
<xpath expr="//field[@name='privacy_visibility']" position="after">
<field name="is_sub_project"/>
</xpath>
<xpath expr="//field[@name='privacy_visibility']" position="after">
<field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)]}"/>
</xpath>
<xpath expr="//page[@name='settings']" position="after">
<page name="sub_project" string="Sub Project" attrs="{'invisible': [('is_sub_project', '=', True)]}">
<page name="sub_project" string="Sub Project"
attrs="{'invisible': [('is_sub_project', '=', True)]}">
<!--<group>
<field name="is_sub_project"/>
</group>-->
@ -38,12 +42,46 @@
</field>
</record>
<!--<record id="inherit_view_sub_project_tree" model="ir.ui.view">
<field name="name">project.project.tree.inherit</field>
<field name="model">project.project</field>
<field name="inherit_id" ref="project.view_project"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='partner_id']" position="after">
</xpath>
</field>
</record>-->
<record id="view_sub_project" model="ir.ui.view">
<field name="name">project.sub.project.tree</field>
<field name="model">project.project</field>
<field name="arch" type="xml">
<tree decoration-muted="active == False" string="Projects" delete="0" multi_edit="1" sample="1">
<field name="sequence" optional="show" widget="handle"/>
<field name="message_needaction" invisible="1"/>
<field name="active" invisible="1"/>
<field name="name" string="Name" class="font-weight-bold"/>
<field name="user_id" optional="show" string="Project Manager" widget="many2one_avatar_user"/>
<field name="partner_id" optional="show" string="Customer"/>
<!-- custom field -->
<field name="parent_project"/>
<!-- -->
<field name="analytic_account_id" optional="hide"/>
<field name="privacy_visibility" optional="hide"/>
<field name="subtask_project_id" optional="hide"/>
<field name="label_tasks" optional="hide"/>
<field name="company_id" optional="show" groups="base.group_multi_company"/>
</tree>
</field>
</record>
<!-- SUB PROJECT VIEW-->
<record id="action_sub_project" model="ir.actions.act_window">
<field name="name">Sub Project</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">project.project</field>
<field name="view_mode">tree,form</field>
<field name="view_id" ref="view_sub_project"/>
<!--<field name="search_view_id" ref="sale_order_view_search_inherit_sale"/>-->
<field name="context">{'default_is_sub_project': True}</field>
<field name="domain">[('is_sub_project', '=', True)]</field>
@ -55,10 +93,10 @@
</record>
<menuitem id="menu_sub_project"
name="Sub Project"
action="action_sub_project"
parent="project.menu_main_pm"
sequence="2"/>
name="Sub Project"
action="action_sub_project"
parent="project.menu_main_pm"
sequence="2"/>
</data>
</odoo>