[FIX] purchase_stock: use max() to compute purchase date
STEPS: * Create a BoM with two components purchased the same vendor, but with different "Delivery Lead Time". First component must have lower value * Create Manufactoring order, Mark as ToDo * Open created purchase order BEFORE: Order Date is equal "MO planned day MINUS delivery lead time for the first component" AFTER: Order Date is equal "MO planned day MINUS maximum amout delivery lead time for the components" --- opw-2388031 closes odoo/odoo#62411 X-original-commit: 8f0cc3609ce7a02d0e3f39586a7b0299ab221d48 Signed-off-by: Ivan Yelizariev // IEL <yelizariev@users.noreply.github.com>
This commit is contained in:
@@ -267,6 +267,7 @@ class StockRule(models.Model):
|
||||
|
||||
procurement_date_planned = min(dates)
|
||||
schedule_date = (procurement_date_planned - relativedelta(days=company_id.po_lead))
|
||||
supplier_delay = max([int(value['supplier'].delay) for value in values])
|
||||
|
||||
# Since the procurements are grouped if they share the same domain for
|
||||
# PO but the PO does not exist. In this case it will create the PO from
|
||||
@@ -274,7 +275,7 @@ class StockRule(models.Model):
|
||||
# arbitrary procurement. In this case the first.
|
||||
values = values[0]
|
||||
partner = values['supplier'].name
|
||||
purchase_date = schedule_date - relativedelta(days=int(values['supplier'].delay))
|
||||
purchase_date = schedule_date - relativedelta(days=supplier_delay)
|
||||
|
||||
fpos = self.env['account.fiscal.position'].with_company(company_id).get_fiscal_position(partner.id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user