From a07447e85a9c486c072294d6af996fbf048f098c Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 7 Apr 2017 16:39:49 +0200 Subject: [PATCH] [FIX] purchase: select supplier When a PO is created through the resolution of a procurement, the first supplier of the list is automatically chosen. This is hardcoded and cannot be extended. We add a hook so it's possible to customize the selection of the supplier, for example by selecting the one who offers the best price. opw-726309 --- addons/purchase/models/purchase.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 3700a2ad677..e13361c752f 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -976,6 +976,12 @@ class ProcurementOrder(models.Model): 'group_id': group } + def _make_po_select_supplier(self, suppliers): + """ Method intended to be overridden by customized modules to implement any logic in the + selection of supplier. + """ + return suppliers[0] + @api.multi def make_po(self): cache = {} @@ -985,7 +991,7 @@ class ProcurementOrder(models.Model): if not suppliers: procurement.message_post(body=_('No vendor associated to product %s. Please set one to fix this procurement.') % (procurement.product_id.name)) continue - supplier = suppliers[0] + supplier = self._make_po_select_supplier(suppliers) partner = supplier.name gpo = procurement.rule_id.group_propagation_option