add sub-project filter for all views
This commit is contained in:
parent
897afff164
commit
1d53b01eaf
|
@ -37,14 +37,6 @@ class AccountAnalyticLine(models.Model):
|
|||
])
|
||||
return domain
|
||||
|
||||
@api.depends('project_id', 'sub_project')
|
||||
def compute_sub_project_id(self):
|
||||
for record in self:
|
||||
if record.project_id and record.project_id.sub_project:
|
||||
record.sub_project_ids = record.project_id.sub_project.ids
|
||||
else:
|
||||
record.sub_project_ids = False
|
||||
|
||||
def default_get(self, field_list):
|
||||
result = super(AccountAnalyticLine, self).default_get(field_list)
|
||||
if self.env.user:
|
||||
|
@ -61,12 +53,20 @@ class AccountAnalyticLine(models.Model):
|
|||
date = fields.Date('Date', required=True, index=True, compute='_compute_start_end_date', store=True)
|
||||
unit_amount = fields.Float('Duration', default=0.0)
|
||||
parent_project = fields.Many2one('project.project', related='project_id.parent_project', string='Parent Project')
|
||||
sub_project = fields.Many2one('project.project', string='Sub Project', domain="[('id', 'in', sub_project_ids)]")
|
||||
sub_project_ids = fields.Many2many('project.project', compute='compute_sub_project_id')
|
||||
sub_project = fields.Many2one('project.project', string='Sub Project')
|
||||
active_project = fields.Boolean(related='project_id.active', store=True)
|
||||
pricing_type = fields.Selection(related='project_id.pricing_type', store=True)
|
||||
project_type = fields.Selection(related='project_id.project_type', store=True)
|
||||
|
||||
@api.depends('project_id', 'sub_project')
|
||||
def compute_sub_project_id(self):
|
||||
for record in self:
|
||||
if record.project_id and record.project_id.sub_project:
|
||||
record.sub_project_ids = record.project_id.sub_project.ids
|
||||
else:
|
||||
record.sub_project_ids = False
|
||||
|
||||
"""@api.onchange('project_id')
|
||||
def _onchange_sub_project_id(self):
|
||||
self.sub_project = False
|
||||
|
|
|
@ -71,8 +71,7 @@
|
|||
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"
|
||||
/>
|
||||
<field name="sub_project_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="sub_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
|
||||
domain="[('id', 'in', sub_project_ids)]"/>
|
||||
<field name="sub_project" options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="task_id" optional="show" options="{'no_create_edit': True, 'no_open': True}"
|
||||
widget="task_with_hours" context="{'default_project_id': project_id}"
|
||||
domain="[('project_id', '=', project_id)]"/>
|
||||
|
@ -170,6 +169,7 @@
|
|||
<field name="project_id" required="1"
|
||||
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"
|
||||
context="{'form_view_ref': 'project.project_project_view_form_simplified',}"/>
|
||||
<field name="sub_project_ids" widget="many2many_tags" invisible="1"/>
|
||||
<field name="sub_project"
|
||||
options="{'no_open': True, 'no_create': True, 'no_create_edit': True}"/>
|
||||
<field name="task_id" widget="task_with_hours" context="{'default_project_id': project_id}"
|
||||
|
|
Loading…
Reference in New Issue