diff --git a/modules/purchase_trade/docs/template-properties.md b/modules/purchase_trade/docs/template-properties.md index 151734e..f6555a7 100644 --- a/modules/purchase_trade/docs/template-properties.md +++ b/modules/purchase_trade/docs/template-properties.md @@ -315,6 +315,7 @@ Source code: `modules/purchase_trade/stock.py` - `report_insurance_incoming_amount` - `report_insurance_amount_insured` - `report_insurance_surveyor` +- `report_insurance_contact_surveyor` - `report_insurance_issue_place_and_date` Usage typique: @@ -326,6 +327,9 @@ Usage typique: (`lot.line.unit_price * lot.get_current_quantity_converted()`) - `report_insurance_amount_insured`: `110%` de `report_insurance_incoming_amount` +- `report_insurance_contact_surveyor`: surveyor affiche sous + `Contact the following surveyor` (priorite au champ shipment `surveyor`, + puis fallback controller / fee `Insurance`) - base de travail pour un certificat d'assurance lie a un shipment ## 10) Recommandations diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py index 352408a..89c5b42 100755 --- a/modules/purchase_trade/stock.py +++ b/modules/purchase_trade/stock.py @@ -441,9 +441,10 @@ class ShipmentIn(metaclass=PoolMeta): 'shipment', 'Container' ) - shipment_wr = fields.One2Many('shipment.wr','shipment_in',"WR") - controller = fields.Many2One('party.party',"Controller") - controller_target = fields.Char("Targeted controller") + shipment_wr = fields.One2Many('shipment.wr','shipment_in',"WR") + controller = fields.Many2One('party.party',"Controller") + surveyor = fields.Many2One('party.party', "Surveyor") + controller_target = fields.Char("Targeted controller") send_instruction = fields.Boolean("Send instruction") instructions = fields.Text("Instructions") add_bl = fields.Boolean("Add BL") @@ -625,12 +626,18 @@ class ShipmentIn(metaclass=PoolMeta): @property def report_insurance_surveyor(self): + if self.surveyor: + return self.surveyor.rec_name or '' if self.controller: return self.controller.rec_name or '' fee = self._get_report_insurance_fee() supplier = getattr(fee, 'supplier', None) if fee else None return getattr(supplier, 'rec_name', '') or '' + @property + def report_insurance_contact_surveyor(self): + return self.report_insurance_surveyor + @property def report_insurance_issue_place_and_date(self): Date = Pool().get('ir.date') diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index b32841a..ea2a970 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -530,6 +530,19 @@ class PurchaseTradeTestCase(ModuleTestCase): self.assertEqual( shipment.report_insurance_amount, 'USD 550.00') + def test_shipment_insurance_contact_surveyor_prefers_shipment_surveyor(self): + 'insurance contact surveyor property uses shipment surveyor first' + ShipmentIn = Pool().get('stock.shipment.in') + shipment = ShipmentIn() + shipment.surveyor = Mock(rec_name='SGS') + shipment.controller = Mock(rec_name='CONTROL UNION') + shipment.fees = [] + + self.assertEqual( + shipment.report_insurance_contact_surveyor, 'SGS') + self.assertEqual( + shipment.report_insurance_surveyor, 'SGS') + def test_sale_report_multi_line_helpers_aggregate_all_lines(self): 'sale report helpers aggregate quantity, price lines and shipment periods' Sale = Pool().get('sale.sale') diff --git a/modules/purchase_trade/view/shipment_in_form.xml b/modules/purchase_trade/view/shipment_in_form.xml index 05da436..514eb3f 100755 --- a/modules/purchase_trade/view/shipment_in_form.xml +++ b/modules/purchase_trade/view/shipment_in_form.xml @@ -137,5 +137,9 @@ this repository contains the full copyright notices and license terms. --> + + - \ No newline at end of file + diff --git a/modules/stock/insurance.fodt b/modules/stock/insurance.fodt index 97a1a60..0ddcd44 100644 --- a/modules/stock/insurance.fodt +++ b/modules/stock/insurance.fodt @@ -1051,7 +1051,7 @@ applicable) and strike as per hte according Clauses. In case of loss and/or damage, contact the following surveyor: - <records[0].report_insurance_surveyor or ''> + <records[0].report_insurance_contact_surveyor or ''> Surveyor's functions are limited to that of an independent observer retained for the sole purpose of reporting on the nature extent and proximate cause of loss; the surveyor has no authority to represent underwriters with regard to the terms and conditions of the contract. @@ -1071,3 +1071,4 @@ +