[FIX] mrp: use the right receipt date for PO replenishments

Instead of always using the `date_planned` of the PO to compute the
estimated/expected receipt date of a purchase order in the MO Overview,
instead use the `scheduled_date` of the related picking when it's
possible (i.e. when the PO is confirmed).

Part of task-3217757

Part-of: odoo/odoo#118023
This commit is contained in:
clesgow
2023-04-13 15:26:41 +02:00
parent a2cc7f307b
commit 3784b0882e
@@ -42,8 +42,11 @@ class ReportMoOverview(models.AbstractModel):
def _get_replenishment_receipt(self, doc_in, components):
res = super()._get_replenishment_receipt(doc_in, components)
if doc_in._name == 'purchase.order':
receipt_state = 'expected' if doc_in.state == 'purchase' else 'estimated'
return self._format_receipt_date(receipt_state, doc_in.date_planned)
if doc_in.state != 'purchase':
return self._format_receipt_date('estimated', doc_in.date_planned)
in_pickings = doc_in.picking_ids.filtered(lambda p: p.state not in ('done', 'cancel'))
planned_date = max(in_pickings.mapped('scheduled_date')) if in_pickings else doc_in.date_planned
return self._format_receipt_date('expected', planned_date)
return res
def _get_resupply_data(self, rules, rules_delay, quantity, uom_id, product, warehouse):