changeset cab0da9a99be in modules/sale_shipment_cost:default
details: 
https://hg.tryton.org/modules/sale_shipment_cost?cmd=changeset&node=cab0da9a99be
description:
        Do not compute unit price for shipment cost line

        The unit price of such line is computed using the carrier method.

        issue11155
        review354541002
diffstat:

 sale.py |  9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diffs (19 lines):

diff -r 8693733aa9bd -r cab0da9a99be sale.py
--- a/sale.py   Thu Feb 03 22:23:02 2022 +0100
+++ b/sale.py   Thu Feb 03 22:32:27 2022 +0100
@@ -325,6 +325,15 @@
                 Unique(t, t.sale, t.shipment_cost),
                 'sale_shipment_cost.msg_sale_shipment_cost_unique'),
             ]
+        # shipment_cost is needed to compute the unit_price
+        cls.unit_price.depends.append('shipment_cost')
+
+    @fields.depends('shipment_cost', 'unit_price')
+    def compute_unit_price(self):
+        unit_price = super().compute_unit_price()
+        if self.shipment_cost is not None:
+            unit_price = self.unit_price
+        return unit_price
 
     def get_invoice_line(self):
         context = Transaction().context

Reply via email to