changeset 31bb67e988c7 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset&node=31bb67e988c7
description:
        Add warehouse to invoice line

        This ensures that the cost price used for COGS lines come from the right
        warehouse when it is computed per warehouse.

        issue10568
        review362161002
diffstat:

 invoice.py |  10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diffs (20 lines):

diff -r 9d974b18ef9d -r 31bb67e988c7 invoice.py
--- a/invoice.py        Mon Jul 12 22:37:21 2021 +0200
+++ b/invoice.py        Thu Jul 29 09:06:38 2021 +0200
@@ -118,6 +118,16 @@
             category = self.origin.unit.category.id
         return category
 
+    def get_warehouse(self, name):
+        pool = Pool()
+        PurchaseLine = pool.get('purchase.line')
+        warehouse = super().get_warehouse(name)
+        if (not warehouse
+                and isinstance(self.origin, PurchaseLine)
+                and self.origin.purchase.warehouse):
+            warehouse = self.origin.purchase.warehouse.id
+        return warehouse
+
     @property
     def origin_name(self):
         pool = Pool()

Reply via email to