Use a fresh product instance to find best product supplier

This ensure to be able to read all the product suppliers.

issue8723
review284231002
This commit is contained in:
Cédric Krier committed 2019-10-24 19:08:07 +02:00
1 parent 9fff3a6a27
commit ba2baf1dca
2 files changed
+12 -3

No files matched your search

+8 -2
View File
@@ -62,7 +62,10 @@ class Template(metaclass=PoolMeta):
})]
def product_suppliers_used(self, **pattern):
for product_supplier in self.product_suppliers:
# Skip rules to test pattern on all records
with Transaction().set_user(0):
template = self.__class__(self)
for product_supplier in template.product_suppliers:
if product_supplier.match(pattern):
yield product_supplier
@@ -112,7 +115,10 @@ class Product(metaclass=PoolMeta):
return cls.get_purchase_price(products, quantity=quantity)
def product_suppliers_used(self, **pattern):
for product_supplier in self.product_suppliers:
# Skip rules to test pattern on all records
with Transaction().set_user(0):
product = self.__class__(self)
for product_supplier in product.product_suppliers:
if product_supplier.match(pattern):
yield product_supplier
pattern['product'] = None
+4 -1
View File
@@ -1165,10 +1165,13 @@ class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
context['taxes'] = [t.id for t in self.taxes or []]
return context
@fields.depends('purchase', '_parent_purchase.party')
@fields.depends('purchase',
'_parent_purchase.party', '_parent_purchase.company')
def _get_product_supplier_pattern(self):
return {
'party': self.purchase.party.id if self.purchase.party else -1,
'company': (
self.purchase.company.id if self.purchase.company else -1),
}
@fields.depends('product', 'unit', 'purchase', '_parent_purchase.party',