changeset b39d7b2b20d1 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=b39d7b2b20d1
description:
        Reuse compute_unit_price when changing quantity

        issue10962
        review391151002
diffstat:

 purchase.py |  14 ++------------
 1 files changed, 2 insertions(+), 12 deletions(-)

diffs (25 lines):

diff -r 9493e3b2bf24 -r b39d7b2b20d1 purchase.py
--- a/purchase.py       Mon Oct 10 18:27:01 2022 +0200
+++ b/purchase.py       Mon Oct 10 18:27:32 2022 +0200
@@ -1380,19 +1380,9 @@
         if self.product:
             return self.product.default_uom_category.id
 
-    @fields.depends(
-        'product', 'quantity', methods=['_get_context_purchase_price'])
+    @fields.depends(methods=['compute_unit_price'])
     def on_change_quantity(self):
-        Product = Pool().get('product.product')
-
-        if not self.product:
-            return
-
-        with Transaction().set_context(self._get_context_purchase_price()):
-            self.unit_price = Product.get_purchase_price([self.product],
-                abs(self.quantity or 0))[self.product.id]
-            if self.unit_price:
-                self.unit_price = round_price(self.unit_price)
+        self.unit_price = self.compute_unit_price()
 
     @fields.depends(methods=['on_change_quantity'])
     def on_change_unit(self):

Reply via email to