diff --git a/cor_custom/models/analytic.py b/cor_custom/models/analytic.py
index ba14b98..bc2032c 100755
--- a/cor_custom/models/analytic.py
+++ b/cor_custom/models/analytic.py
@@ -37,6 +37,14 @@ 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.is_sub_project == True 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:
@@ -53,13 +61,13 @@ 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', domain="[('is_sub_project', '=', True)]",
- string='Sub Project')
+ 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.onchange('project_id')
+ """@api.onchange('project_id')
def _onchange_sub_project_id(self):
self.sub_project = False
res = {}
@@ -67,7 +75,7 @@ class AccountAnalyticLine(models.Model):
res['domain'] = {'sub_project': [('id', 'in', self.project_id.sub_project.ids)]}
else:
res['domain'] = {'sub_project': [('id', '=', False)]}
- return res
+ return res"""
def _default_start_datetime(self):
return fields.Datetime.to_string(datetime.combine(fields.Datetime.now(), datetime.min.time()))
diff --git a/cor_custom/views/analytic_view.xml b/cor_custom/views/analytic_view.xml
index 1756a00..f51a4fd 100755
--- a/cor_custom/views/analytic_view.xml
+++ b/cor_custom/views/analytic_view.xml
@@ -66,10 +66,13 @@
-
-
+ />
+
+
@@ -164,7 +167,8 @@
-