Charter party

This commit is contained in:
2026-05-31 22:33:55 +02:00
parent 779e1aa361
commit 2dd8360d62
3 changed files with 188 additions and 110 deletions

View File

@@ -622,9 +622,18 @@ class ShipmentIn(metaclass=PoolMeta):
booking_date =fields.Date("Booking date")
ref = fields.Char("Our reference")
note = fields.Text("Notes")
dashboard = fields.Many2One('purchase.dashboard',"Dashboard")
dashboard = fields.Many2One('purchase.dashboard',"Dashboard")
himself = fields.Function(fields.Many2One('stock.shipment.in',"Shipment"),'get_sh')
charter_party = fields.Many2One('stock.charter.party', "Charter Party")
owner_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Owner Conditions"),
'get_owner_charter_conditions')
purchase_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Supplier Conditions"),
'get_purchase_charter_conditions')
sale_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Customer Conditions"),
'get_sale_charter_conditions')
sof = fields.One2Many('sof.statement', 'shipment',"Demurrage calculations")
del_from = fields.Date("Delivery period from")
del_to = fields.Date("to")
@@ -1618,9 +1627,65 @@ class ShipmentIn(metaclass=PoolMeta):
return sum([(e.quantity if e.quantity else 0) for e in self.incoming_moves])
if self.lotqt:
return sum([(e.lot_quantity if e.lot_quantity else 0) for e in self.lotqt])
def get_bales(self,name=None):
Lot = Pool().get('lot.lot')
@staticmethod
def _unique_condition_ids(conditions):
ids = []
seen = set()
for condition in conditions or []:
condition_id = getattr(condition, 'id', condition)
if not condition_id or condition_id in seen:
continue
seen.add(condition_id)
ids.append(condition_id)
return ids
def get_owner_charter_conditions(self, name=None):
return self._unique_condition_ids(
getattr(self.charter_party, 'conditions', None) or [])
def _get_purchase_lines_from_lots(self):
lines = []
seen = set()
for lot_qt in getattr(self, 'lotqt', []) or []:
line = getattr(getattr(lot_qt, 'lot_p', None), 'line', None)
line_id = getattr(line, 'id', None)
if not line or line_id in seen:
continue
seen.add(line_id)
lines.append(line)
return lines
def _get_sale_lines_from_lots(self):
lines = []
seen = set()
for lot_qt in getattr(self, 'lotqt', []) or []:
line = getattr(getattr(lot_qt, 'lot_s', None), 'sale_line', None)
line_id = getattr(line, 'id', None)
if not line or line_id in seen:
continue
seen.add(line_id)
lines.append(line)
return lines
def get_purchase_charter_conditions(self, name=None):
conditions = []
for line in self._get_purchase_lines_from_lots():
getter = getattr(line, 'get_effective_charter_conditions', None)
if getter:
conditions.extend(getter())
return self._unique_condition_ids(conditions)
def get_sale_charter_conditions(self, name=None):
conditions = []
for line in self._get_sale_lines_from_lots():
getter = getattr(line, 'get_effective_charter_conditions', None)
if getter:
conditions.extend(getter())
return self._unique_condition_ids(conditions)
def get_bales(self,name=None):
Lot = Pool().get('lot.lot')
lots = Lot.search(['lot_shipment_in','=',self.id])
if lots:
return sum([l.lot_qt for l in lots])
@@ -1879,6 +1944,15 @@ class StatementOfFacts(ModelSQL, ModelView):
timebar_day = fields.Integer("TimeBar")
timebar_warn = fields.Integer("Warning TimeBar")
charter_party = fields.Many2One('stock.charter.party', "Charter Party")
owner_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Owner Conditions"),
'get_owner_charter_conditions')
purchase_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Supplier Conditions"),
'get_purchase_charter_conditions')
sale_charter_conditions = fields.Function(
fields.One2Many('charter.condition', '', "Customer Conditions"),
'get_sale_charter_conditions')
chart = fields.Many2One('document.incoming',"Charter Party Terms")
sof = fields.Many2One('document.incoming',"Statement of facts")
@@ -1914,6 +1988,23 @@ class StatementOfFacts(ModelSQL, ModelView):
if self.shipment and self.shipment.charter_party and not self.charter_party:
self.charter_party = self.shipment.charter_party
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)
return []
def get_purchase_charter_conditions(self, name=None):
if self.shipment:
return self.shipment.get_purchase_charter_conditions(name)
return []
def get_sale_charter_conditions(self, name=None):
if self.shipment:
return self.shipment.get_sale_charter_conditions(name)
return []
def get_qt(self,name):
if self.shipment:
return self.shipment.get_quantity()

View File

@@ -111,6 +111,18 @@ this repository contains the full copyright notices and license terms. -->
<label name="charter_party"/>
<field name="charter_party"/>
<newline/>
<notebook colspan="4">
<page string="Owner Conditions" id="owner_conditions">
<field name="owner_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
<page string="Supplier Conditions" id="supplier_conditions">
<field name="purchase_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
<page string="Customer Conditions" id="customer_conditions">
<field name="sale_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
</notebook>
<newline/>
<field name="sof" colspan="4" mode="form,tree" view_ids="purchase_trade.view_form_sof,purchase_trade.view_list_sof"/>
<newline/>
<button name="compute" string="compute"/>

View File

@@ -1,108 +1,83 @@
<form>
<notebook>
<!-- 🧾 Onglet 1 : Données contractuelles et générales -->
<page string="Contract details" id="cs">
<form>
<notebook>
<page string="Contract Conditions" id="cs">
<label name="charter_party"/>
<field name="charter_party"/>
<newline/>
<separator string="🌍 Global" id="gb"/>
<newline/>
<label name="laytime_type"/>
<field name="laytime_type"/>
<field name="laytime_clause_hour"/>
<newline/>
<label name="laytime_start"/>
<field name="laytime_start"/>
<label name="laytime_end"/>
<field name="laytime_end"/>
<newline/>
<label name="pumping_rate"/>
<field name="pumping_rate"/>
<label name="demurrage_rate"/>
<field name="demurrage_rate"/>
<newline/>
<separator string="👤 Owner" id="ow"/>
<newline/>
<label name="laytime_type_o"/>
<field name="laytime_type_o"/>
<field name="laytime_clause_hour_o"/>
<newline/>
<label name="laytime_start_o"/>
<field name="laytime_start_o"/>
<label name="laytime_end_o"/>
<field name="laytime_end_o"/>
<newline/>
<label name="pumping_rate_o"/>
<field name="pumping_rate_o"/>
<label name="demurrage_rate_o"/>
<field name="demurrage_rate_o"/>
<newline/>
<separator string="⏳ TimeBar" id="tb"/>
<newline/>
<label name="timebar_day"/>
<field name="timebar_day"/>
<label name="timebar_warn"/>
<field name="timebar_warn"/>
</page>
<!-- 📄 Onglet 2 : Événements du SOF -->
<page string="Sof events" id="event">
<label name="sof"/>
<field name="sof"/>
<newline/>
<label name="arrival_time"/>
<field name="arrival_time"/>
<label name="notice_of_readiness_time"/>
<field name="notice_of_readiness_time"/>
<newline/>
<label name="hoses_connected"/>
<field name="hoses_connected"/>
<label name="start_pumping"/>
<field name="start_pumping"/>
<newline/>
<label name="end_pumping"/>
<field name="end_pumping"/>
<label name="hoses_disconnected"/>
<field name="hoses_disconnected"/>
<newline/>
<label name="sailing_time"/>
<field name="sailing_time"/>
<newline/>
<field name="sof_events" colspan="4" mode="tree" view_ids="purchase_trade.view_sof_event_tree"/>
</page>
<!-- 🧮 Onglet 3 : Calculs de Demurrage -->
<page string="Calculation" id="calcul">
<label name="quantity"/>
<field name="quantity"/>
<newline/>
<label name="laytime_commenced"/>
<field name="laytime_commenced"/>
<label name="laytime_completed"/>
<field name="laytime_completed"/>
<newline/>
<label name="actual_time_used"/>
<field name="actual_time_used"/>
<label name="laytime_allowed"/>
<field name="laytime_allowed"/>
<newline/>
<label name="deductions"/>
<field name="deductions"/>
<newline/>
<label name="laytime_used"/>
<field name="laytime_used"/>
<label name="laytime_balance"/>
<field name="laytime_balance"/>
<newline/>
<label name="compensation_type"/>
<field name="compensation_type"/>
<label name="compensation_amount"/>
<field name="compensation_amount"/>
<newline/>
<label name="notes"/>
<field name="notes" colspan="4"/>
</page>
</notebook>
</form>
<newline/>
<notebook colspan="4">
<page string="Owner" id="owner_conditions">
<field name="owner_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
<page string="Supplier" id="supplier_conditions">
<field name="purchase_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
<page string="Customer" id="customer_conditions">
<field name="sale_charter_conditions" colspan="4" mode="tree,form" view_ids="purchase_trade.charter_condition_view_tree,purchase_trade.charter_condition_view_form"/>
</page>
</notebook>
<newline/>
<separator string="TimeBar" id="tb"/>
<newline/>
<label name="timebar_day"/>
<field name="timebar_day"/>
<label name="timebar_warn"/>
<field name="timebar_warn"/>
</page>
<page string="Sof events" id="event">
<label name="sof"/>
<field name="sof"/>
<newline/>
<label name="arrival_time"/>
<field name="arrival_time"/>
<label name="notice_of_readiness_time"/>
<field name="notice_of_readiness_time"/>
<newline/>
<label name="hoses_connected"/>
<field name="hoses_connected"/>
<label name="start_pumping"/>
<field name="start_pumping"/>
<newline/>
<label name="end_pumping"/>
<field name="end_pumping"/>
<label name="hoses_disconnected"/>
<field name="hoses_disconnected"/>
<newline/>
<label name="sailing_time"/>
<field name="sailing_time"/>
<newline/>
<field name="sof_events" colspan="4" mode="tree" view_ids="purchase_trade.view_sof_event_tree"/>
</page>
<page string="Calculation" id="calcul">
<label name="quantity"/>
<field name="quantity"/>
<newline/>
<label name="laytime_commenced"/>
<field name="laytime_commenced"/>
<label name="laytime_completed"/>
<field name="laytime_completed"/>
<newline/>
<label name="actual_time_used"/>
<field name="actual_time_used"/>
<label name="laytime_allowed"/>
<field name="laytime_allowed"/>
<newline/>
<label name="deductions"/>
<field name="deductions"/>
<newline/>
<label name="laytime_used"/>
<field name="laytime_used"/>
<label name="laytime_balance"/>
<field name="laytime_balance"/>
<newline/>
<label name="compensation_type"/>
<field name="compensation_type"/>
<label name="compensation_amount"/>
<field name="compensation_amount"/>
<newline/>
<label name="notes"/>
<field name="notes" colspan="4"/>
</page>
</notebook>
</form>