changeset bd1fac2a0753 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=bd1fac2a0753
description:
        Compute delivery date with the selected product supplier

        issue8081
        review56581002
diffstat:

 purchase.py |  20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (40 lines):

diff -r 64efb69c75c1 -r bd1fac2a0753 purchase.py
--- a/purchase.py       Wed Feb 13 10:40:16 2019 +0100
+++ b/purchase.py       Fri Feb 15 23:29:14 2019 +0100
@@ -1275,8 +1275,8 @@
         else:
             return self.purchase.party.supplier_location.id
 
-    @fields.depends('product', 'quantity', 'moves', 'purchase',
-        '_parent_purchase.purchase_date', '_parent_purchase.party',
+    @fields.depends('product_supplier', 'quantity', 'moves', 'purchase',
+        '_parent_purchase.purchase_date',
         'delivery_date_edit', 'delivery_date_store',
         '_parent_purchase.delivery_date')
     def on_change_with_delivery_date(self, name=None):
@@ -1292,19 +1292,15 @@
             delivery_date = self.delivery_date_store
         elif self.purchase and self.purchase.delivery_date:
             delivery_date = self.purchase.delivery_date
-        elif (self.product
+        elif (self.product_supplier
                 and self.quantity is not None
                 and self.quantity > 0
-                and self.purchase and self.purchase.party
-                and self.product.product_suppliers):
+                and self.purchase):
             date = self.purchase.purchase_date if self.purchase else None
-            for product_supplier in self.product.product_suppliers:
-                if product_supplier.party == self.purchase.party:
-                    delivery_date = product_supplier.compute_supply_date(
-                        date=date)
-                    if delivery_date == datetime.date.max:
-                        delivery_date = None
-                    break
+            delivery_date = self.product_supplier.compute_supply_date(
+                date=date)
+            if delivery_date == datetime.date.max:
+                delivery_date = None
         if delivery_date and delivery_date < Date.today():
             delivery_date = None
         return delivery_date

Reply via email to