[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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user