From d967356c7eb69d33d8d4d12df95ba653faa90d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 11 Oct 2024 15:59:18 +0200 Subject: [PATCH] Return location instance in getter of sale and purchase If the location field is empty, it prevents to raise an attribute error when accessing the id. Closes #13544 --- modules/purchase/purchase.py | 8 ++++---- modules/sale/sale.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/purchase/purchase.py b/modules/purchase/purchase.py index 0e7c977066..a41ed18159 100644 --- a/modules/purchase/purchase.py +++ b/modules/purchase/purchase.py @@ -1707,16 +1707,16 @@ class Line(sequence_ordered(), ModelSQL, ModelView): def get_from_location(self, name): if (self.quantity or 0) >= 0: if self.purchase.party.supplier_location: - return self.purchase.party.supplier_location.id + return self.purchase.party.supplier_location elif self.purchase.return_from_location: - return self.purchase.return_from_location.id + return self.purchase.return_from_location def get_to_location(self, name): if (self.quantity or 0) >= 0: if self.purchase.warehouse: - return self.purchase.warehouse.input_location.id + return self.purchase.warehouse.input_location elif self.purchase.party.supplier_location: - return self.purchase.party.supplier_location.id + return self.purchase.party.supplier_location @fields.depends('product') def on_change_with_movable(self, name=None): diff --git a/modules/sale/sale.py b/modules/sale/sale.py index ae4180770a..17357f5750 100644 --- a/modules/sale/sale.py +++ b/modules/sale/sale.py @@ -1775,18 +1775,18 @@ class SaleLine(TaxableMixin, sequence_ordered(), ModelSQL, ModelView): def get_from_location(self, name): if (self.quantity or 0) >= 0: if self.warehouse: - return self.warehouse.output_location.id + return self.warehouse.output_location else: party = self.sale.shipment_party or self.sale.party - return party.customer_location.id + return party.customer_location def get_to_location(self, name): if (self.quantity or 0) >= 0: party = self.sale.shipment_party or self.sale.party - return party.customer_location.id + return party.customer_location else: if self.warehouse: - return self.warehouse.input_location.id + return self.warehouse.input_location @classmethod def movable_types(cls):