Modify get_carrier_amount method.

This commit refs #11461
This commit is contained in:
jmpardo98 2020-02-28 12:51:04 +00:00 committed by Sergio Morillo
parent 65a83436e1
commit b8011c7a95
1 changed files with 8 additions and 4 deletions

12
load.py
View File

@ -52,6 +52,10 @@ class Load(metaclass=PoolMeta):
def search_unit_loads(cls, name, clause):
return [('orders.unit_loads', ) + tuple(clause[1:])]
@property
def ul_quantity(self):
return sum(o.ul_quantity for o in self.orders)
class LoadOrder(metaclass=PoolMeta):
__name__ = 'carrier.load.order'
@ -145,12 +149,12 @@ class LoadOrder(metaclass=PoolMeta):
return [('lines.unit_loads', ) + tuple(clause[1:])]
def get_carrier_amount(self, name=None):
if (not self.load.unit_price or not self.unit_loads or
not self.load.unit_loads):
if (not self.load.unit_price or not self.ul_quantity or
not self.load.ul_quantity):
return 0
return self.load.currency.round(
(Decimal(len(self.unit_loads)) / Decimal(len(
self.load.unit_loads))) * self.load.unit_price)
(Decimal(len(self.ul_quantity)) / Decimal(len(
self.load.ul_quantity))) * self.load.unit_price)
@classmethod
def cancel(cls, records):