summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Lejeune <sle@openerp.com>2019-07-29 14:37:02 +0000
committerSimon Lejeune <sle@openerp.com>2019-08-05 18:25:38 +0000
commit0033659ff4c6efac8209d5fec9d0f4f02b2bbebd (patch)
treeb0854db802c0d645ec5cb800b8a6a36b4ca02f3d
parent795c7b0a9415d04a777e1a5d48921adbd72f38cf (diff)
[FIX] mrp: workorder grouped by date
Read_group only work on stored field. We still can't make these fields stored related because of what's explained on the comment: the write aren't batched and a constraint is raised. See rev 0679d0d54269ffe0664845e8e0bd1238110fd514 task-2036914 closes odoo/odoo#35268 Signed-off-by: Simon Lejeune (sle) <sle@openerp.com>
-rw-r--r--addons/mrp/models/mrp_workorder.py17
1 files changed, 5 insertions, 12 deletions
diff --git a/addons/mrp/models/mrp_workorder.py b/addons/mrp/models/mrp_workorder.py
index 58903a3aec5..f7be61d8325 100644
--- a/addons/mrp/models/mrp_workorder.py
+++ b/addons/mrp/models/mrp_workorder.py
@@ -55,14 +55,14 @@ class MrpWorkorder(models.Model):
'Scheduled Date Start',
compute='_compute_dates_planned',
inverse='_set_dates_planned',
- search='_search_date_planned_start',
- states={'done': [('readonly', True)], 'cancel': [('readonly', True)]})
+ states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
+ store=True)
date_planned_finished = fields.Datetime(
'Scheduled Date Finished',
compute='_compute_dates_planned',
inverse='_set_dates_planned',
- search='_search_date_planned_finished',
- states={'done': [('readonly', True)], 'cancel': [('readonly', True)]})
+ states={'done': [('readonly', True)], 'cancel': [('readonly', True)]},
+ store=True)
date_start = fields.Datetime(
'Effective Start Date',
states={'done': [('readonly', True)], 'cancel': [('readonly', True)]})
@@ -131,8 +131,7 @@ class MrpWorkorder(models.Model):
# fields Changes. As the ORM doesn't batch the write on related fields and instead
# makes multiple call, the constraint check_dates() is raised.
# That's why the compute and set methods are needed. to ensure the dates are updated
- # in the same time. The two next search method are needed as the field are non stored and
- # not direct related fields.
+ # in the same time.
@api.depends('leave_id')
def _compute_dates_planned(self):
for workorder in self:
@@ -147,12 +146,6 @@ class MrpWorkorder(models.Model):
'date_to': date_to,
})
- def _search_date_planned_start(self, operator, value):
- return [('leave_id.date_from', operator, value)]
-
- def _search_date_planned_finished(self, operator, value):
- return [('leave_id.date_to', operator, value)]
-
@api.onchange('finished_lot_id')
def _onchange_finished_lot_id(self):
"""When the user changes the lot being currently produced, suggest