[FIX] mrp: wrong MO finished date
Usecase to reproduce:
- Create a product with 10 days manufacture lead time
- Create a procurement in order to fullfill a need the 01/15
The MO start date is the 01/05 that's the expected values
The MO finished date is the 01/05, 1 h later than the start date
It happens due to commit 92aeaa47ff
This commit modified the wrong start date in order to take the
procurement date - manufacturing lead time. However it also
modified the finished date to 'the start date + 1h'. That returns
the problem to the opposite direction. Now the finished moves have
a wrong planning.
Fix it by using the production + company lead days when it's set
instead of 1h.
opw-2181962
X-original-commit: 6a5ce8de91d3ab2cb7f73127a6ee1c11578ccef9
This commit is contained in:
@@ -90,8 +90,8 @@ class StockRule(models.Model):
|
||||
'location_dest_id': location_id.id,
|
||||
'bom_id': bom.id,
|
||||
'date_deadline': date_deadline,
|
||||
'date_planned_finished': date_deadline,
|
||||
'date_planned_start': fields.Datetime.from_string(date_deadline) - relativedelta(hours=1),
|
||||
'date_planned_finished': fields.Datetime.from_string(values['date_planned']),
|
||||
'date_planned_start': date_deadline,
|
||||
'procurement_group_id': False,
|
||||
'delay_alert': self.delay_alert,
|
||||
'propagate_cancel': self.propagate_cancel,
|
||||
@@ -106,7 +106,10 @@ class StockRule(models.Model):
|
||||
|
||||
def _get_date_planned(self, product_id, company_id, values):
|
||||
format_date_planned = fields.Datetime.from_string(values['date_planned'])
|
||||
date_planned = format_date_planned - relativedelta(days=product_id.produce_delay or 0.0)
|
||||
if product_id.produce_delay:
|
||||
date_planned = format_date_planned - relativedelta(days=product_id.produce_delay)
|
||||
else:
|
||||
date_planned = format_date_planned - relativedelta(hours=1)
|
||||
date_planned = date_planned - relativedelta(days=company_id.manufacturing_lead)
|
||||
return date_planned
|
||||
|
||||
|
||||
Reference in New Issue
Block a user