From 2f9399b555cb84a7520cf7e36feb6b8c37769cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 29 Jul 2021 09:06:38 +0200 Subject: [PATCH] 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 --- invoice.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/invoice.py b/invoice.py index 55d463c102..2b236ad777 100644 --- a/invoice.py +++ b/invoice.py @@ -118,6 +118,16 @@ class InvoiceLine(metaclass=PoolMeta): 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()