[FIX] mrp: traceback when no date_planned_start
Checks the MO `date_planned_start` is set to do the onchange. Also, add `product_id` in the onchange trigger because the produce delay can be different for each product and so the MO `date_planned_finished` must be recomputed also when the product change. task-2359839 closes odoo/odoo#61295 X-original-commit: b48d0047f6a0a3084739e8991f32aae4a2b399c2 Signed-off-by: William Henrotin <Whenrow@users.noreply.github.com>
This commit is contained in:
@@ -567,9 +567,9 @@ class MrpProduction(models.Model):
|
||||
self.move_finished_ids = [(2, move.id) for move in self.move_finished_ids]
|
||||
self.picking_type_id = self.bom_id.picking_type_id or self.picking_type_id
|
||||
|
||||
@api.onchange('date_planned_start')
|
||||
@api.onchange('date_planned_start', 'product_id')
|
||||
def _onchange_date_planned_start(self):
|
||||
if not self.is_planned:
|
||||
if self.date_planned_start and not self.is_planned:
|
||||
date_planned_finished = self.date_planned_start + relativedelta(days=self.product_id.produce_delay)
|
||||
date_planned_finished = date_planned_finished + relativedelta(days=self.company_id.manufacturing_lead)
|
||||
if date_planned_finished == self.date_planned_start:
|
||||
|
||||
Reference in New Issue
Block a user