From e088db2c50f0891dae0c42e03215511706151ca0 Mon Sep 17 00:00:00 2001 From: BernatPForgeFlow Date: Mon, 27 Nov 2023 17:17:01 +0100 Subject: [PATCH] [FIX] mrp_multi_level: Correct main supplier when changing sequence in Vendor Pricelist When we change the sequence order of the Vendor Pricelist for a product, we firstly fetch the vendors and then we change the sequence. Then, when changing a sequence we try to get the first supplier but we do not get the desired result. Reordering the suppliers allows to always get the first supplier in the list. --- mrp_multi_level/models/product_mrp_area.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mrp_multi_level/models/product_mrp_area.py b/mrp_multi_level/models/product_mrp_area.py index 0f5286d49..138cca4dd 100644 --- a/mrp_multi_level/models/product_mrp_area.py +++ b/mrp_multi_level/models/product_mrp_area.py @@ -219,7 +219,7 @@ class ProductMRPArea(models.Model): suppliers = rec.product_id.seller_ids.filtered( lambda r: (not r.product_id or r.product_id == rec.product_id) and (not r.company_id or r.company_id == rec.company_id) - ) + ).sorted(lambda s: (s.sequence, -s.min_qty, s.price, s.id)) if not suppliers: rec.main_supplierinfo_id = False rec.main_supplier_id = False