add parent project field
This commit is contained in:
parent
4c4f5d94a6
commit
c37ef70045
|
@ -17,7 +17,7 @@ class AccountAnalyticLine(models.Model):
|
|||
start_time = fields.Float(string='Start Time', digits=(16, 2))
|
||||
end_time = fields.Float(string='End Time', digits=(16, 2))
|
||||
unit_amount = fields.Float('Duration', default=0.0)
|
||||
parent_project = fields.Many2one('project.project', string='Parent Project')
|
||||
parent_project = fields.Many2one('project.project', related='project_id.parent_project', string='Parent Project')
|
||||
|
||||
|
||||
def _default_start_datetime(self):
|
||||
|
@ -30,16 +30,16 @@ class AccountAnalyticLine(models.Model):
|
|||
end_datetime = fields.Datetime("End Time", required=True)
|
||||
|
||||
|
||||
@api.onchange('project_id')
|
||||
def _onchange_parent_project_id(self):
|
||||
if self.project_id:
|
||||
parent_project = self.env['project.project'].search([('sub_project', '=', self.project_id.id)], limit=1)
|
||||
if parent_project:
|
||||
self.parent_project = parent_project.id
|
||||
else:
|
||||
self.parent_project = False
|
||||
else:
|
||||
self.parent_project = False
|
||||
# @api.onchange('project_id')
|
||||
# def _onchange_parent_project_id(self):
|
||||
# if self.project_id:
|
||||
# parent_project = self.env['project.project'].search([('sub_project', '=', self.project_id.id)], limit=1)
|
||||
# if parent_project:
|
||||
# self.parent_project = parent_project.id
|
||||
# else:
|
||||
# self.parent_project = False
|
||||
# else:
|
||||
# self.parent_project = False
|
||||
|
||||
|
||||
@api.onchange('employee_id')
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
<field name="end_datetime" string="End Time"/><!--custom-->
|
||||
<field name="unit_amount" optional="show" widget="timesheet_uom" sum="Total"
|
||||
decoration-danger="unit_amount > 24"/>
|
||||
<field name="parent_project"/><!--custom-->
|
||||
<field name="parent_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/><!--custom-->
|
||||
<field name="company_id" invisible="1"/>
|
||||
<field name="user_id" invisible="1"/>
|
||||
</tree>
|
||||
|
|
|
@ -8,7 +8,7 @@ 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')
|
||||
parent_project = fields.Many2one('project.project', domain="[('is_sub_project', '=', False)]", string='Parent Project')
|
||||
|
||||
@api.depends('sub_project')
|
||||
def onchange_parent_project_sub_project(self):
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='privacy_visibility']" position="after">
|
||||
<field name="is_sub_project"/>
|
||||
<field name="is_sub_project" invisible="1"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='privacy_visibility']" position="after">
|
||||
<field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)]}"/>
|
||||
<field name="parent_project" attrs="{'invisible': [('is_sub_project', '=', False)], 'required': [('is_sub_project', '=', True)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//page[@name='settings']" position="after">
|
||||
<page name="sub_project" string="Sub Project"
|
||||
|
|
Loading…
Reference in New Issue