Demurrage
This commit is contained in:
@@ -3347,26 +3347,26 @@ class StatementOfFacts(ModelSQL, ModelView):
|
||||
|
||||
@fields.depends('shipment', 'charter_party', 'applied_condition')
|
||||
def on_change_shipment(self):
|
||||
if self.shipment and self.shipment.charter_party and not self.charter_party:
|
||||
self.charter_party = self.shipment.charter_party
|
||||
self._set_default_applied_condition()
|
||||
|
||||
@fields.depends('charter_party', 'applied_condition')
|
||||
@fields.depends('shipment', 'charter_party', 'applied_condition')
|
||||
def on_change_charter_party(self):
|
||||
self._set_default_applied_condition()
|
||||
|
||||
def _set_default_applied_condition(self):
|
||||
if self.applied_condition:
|
||||
condition_ids = self.get_applied_conditions()
|
||||
applied_condition_id = getattr(self.applied_condition, 'id', None)
|
||||
if applied_condition_id in condition_ids:
|
||||
return
|
||||
conditions = getattr(self.charter_party, 'conditions', None) or []
|
||||
if len(conditions) == 1:
|
||||
self.applied_condition = conditions[0]
|
||||
self.applied_condition = None
|
||||
if len(condition_ids) == 1:
|
||||
self.applied_condition = condition_ids[0]
|
||||
|
||||
def get_owner_charter_conditions(self, name=None):
|
||||
if self.charter_party:
|
||||
return ShipmentIn._unique_condition_ids(self.charter_party.conditions)
|
||||
if self.shipment:
|
||||
return self.shipment.get_owner_charter_conditions(name)
|
||||
if self.charter_party:
|
||||
return ShipmentIn._unique_condition_ids(self.charter_party.conditions)
|
||||
return []
|
||||
|
||||
def get_purchase_charter_conditions(self, name=None):
|
||||
|
||||
Reference in New Issue
Block a user