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
This commit is contained in:
1 parent
f53b5cb0d0
commit
d967356c7e
2 files changed
+8
-8
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user