[FIX] mrp: date expected and date deadline
- Create Product A: Routes: MTO and Manufacture Manufacturing Lead Time: 20 days - Create Product B: Routes: MTO and Buy Add a supplier with Delivery Lead Time: 10 days - Create a BOM: 1 unit of B to produce 1 unit of A - Create a SO for A, validate A MO is created with a Deadline set at SO order date - 20 days => OK A PO is created with order date set at SO order date - 10 days => Not OK, it should be - 30 days. In v13, the raw materials expected date is the order date. In v12, this date is computed as: order date minus Manufacturing Lead Time However, in both versions the PO order date is computed as the raw materials expected date minus Delivery Lead Time of the supplier. This comes from a change in the semantic of 'Planned Date' and 'Planned End Date'. In v13, the Manufacturing Lead Time is only taken into account in the Deadline, while in v12 it was taken into account in the Planned Date. However, the expected date of the raw materials still relies on the latter, not on the Deadline. In order to solve this, we apply the 'Manufacturing Lead Time' of the product and the company to 'Planned Date', 'Planned End Date' and 'Deadline' when the MO is created. Note that the solution is still not ideal in case no routing is set on the BOM since 'Planned Date' and 'Planned End Date' won't be updated later in the process. opw-2118951 closes odoo/odoo#40360 X-original-commit: b523f991572e32e69c5f8000a21553191ca54773 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
committed by
fw-bot
parent
a449e2ccf6
commit
92aeaa47ff
@@ -74,6 +74,7 @@ class StockRule(models.Model):
|
||||
)._bom_find(product=product_id, picking_type=self.picking_type_id, bom_type='normal') # TDE FIXME: context bullshit
|
||||
|
||||
def _prepare_mo_vals(self, product_id, product_qty, product_uom, location_id, name, origin, company_id, values, bom):
|
||||
date_deadline = fields.Datetime.to_string(self._get_date_planned(product_id, company_id, values))
|
||||
return {
|
||||
'origin': origin,
|
||||
'product_id': product_id.id,
|
||||
@@ -82,9 +83,9 @@ class StockRule(models.Model):
|
||||
'location_src_id': self.location_src_id.id or self.picking_type_id.default_location_src_id.id or location_id.id,
|
||||
'location_dest_id': location_id.id,
|
||||
'bom_id': bom.id,
|
||||
'date_deadline': fields.Datetime.to_string(self._get_date_planned(product_id, company_id, values)),
|
||||
'date_planned_finished': values['date_planned'],
|
||||
'date_planned_start': fields.Datetime.from_string(values['date_planned']) - relativedelta(hours=1),
|
||||
'date_deadline': date_deadline,
|
||||
'date_planned_finished': date_deadline,
|
||||
'date_planned_start': fields.Datetime.from_string(date_deadline) - relativedelta(hours=1),
|
||||
'procurement_group_id': False,
|
||||
'propagate_cancel': self.propagate_cancel,
|
||||
'propagate_date': self.propagate_date,
|
||||
|
||||
Reference in New Issue
Block a user