Show insurance surveyor address

This commit is contained in:
2026-07-28 07:35:59 +02:00
parent c62cee33af
commit a1bb0e8a04
4 changed files with 73 additions and 5 deletions

View File

@@ -417,9 +417,10 @@ 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`)
- `report_insurance_contact_surveyor`: nom et adresse du surveyor affiches
sous `Contact the following surveyor` (priorite au champ shipment
`surveyor`, puis fallback controller / fee `Insurance`). La premiere ligne
d'adresse est ignoree si elle duplique le nom long de la party.
- base de travail pour un certificat d'assurance lie a un shipment
## 10) Recommandations

View File

@@ -1319,9 +1319,57 @@ class ShipmentIn(metaclass=PoolMeta):
supplier = getattr(fee, 'supplier', None) if fee else None
return getattr(supplier, 'rec_name', '') or ''
def _get_report_insurance_surveyor_party(self):
if self.surveyor:
return self.surveyor
if self.controller:
return self.controller
fee = self._get_report_insurance_fee()
return getattr(fee, 'supplier', None) if fee else None
@staticmethod
def _normalize_report_address_line(value):
return ' '.join(str(value or '').split()).strip().casefold()
@classmethod
def _get_report_party_address_lines(cls, party):
if not party:
return []
name = getattr(party, 'rec_name', '') or ''
lines = [name] if name else []
address_get = getattr(party, 'address_get', None)
address = address_get() if address_get else None
if not address:
return lines
duplicate_names = {
cls._normalize_report_address_line(value)
for value in [
name,
getattr(party, 'full_name', None),
getattr(address, 'party_name', None),
getattr(address, 'party_full_name', None),
]
if value
}
full_address = getattr(address, 'full_address', '') or ''
if not isinstance(full_address, str):
return lines
address_lines = [
line.strip()
for line in full_address.splitlines()
if line.strip()
]
for line in address_lines:
if cls._normalize_report_address_line(line) in duplicate_names:
continue
lines.append(line)
return lines
@property
def report_insurance_contact_surveyor(self):
return self.report_insurance_surveyor
party = self._get_report_insurance_surveyor_party()
return '\n'.join(self._get_report_party_address_lines(party))
@property
def report_insurance_issue_place_and_date(self):

View File

@@ -7765,6 +7765,25 @@ description</t></is></c>
self.assertEqual(
shipment.report_insurance_surveyor, 'SGS')
def test_shipment_insurance_contact_surveyor_includes_address_once(self):
'insurance contact surveyor displays name and address without duplicate party name'
ShipmentIn = Pool().get('stock.shipment.in')
shipment = ShipmentIn()
address = Mock(
party_name='SGS SA',
party_full_name='SGS SA',
full_address='SGS SA\nRue du Test 1\n1201 Geneva\nSwitzerland')
shipment.surveyor = Mock(
rec_name='SGS',
full_name='SGS SA',
address_get=Mock(return_value=address))
shipment.controller = Mock(rec_name='CONTROL UNION')
shipment.fees = []
self.assertEqual(
shipment.report_insurance_contact_surveyor,
'SGS\nRue du Test 1\n1201 Geneva\nSwitzerland')
def test_shipment_insurance_order_reference_falls_back_to_lot_qt(self):
'insurance order reference can read sale deal through matching lot.qt'
ShipmentIn = Pool().get('stock.shipment.in')

View File

@@ -1053,7 +1053,7 @@
<text:p text:style-name="P32">applicable) and strike as per hte according Clauses.</text:p>
<text:p text:style-name="P34"/>
<text:h text:style-name="P43" text:outline-level="2">In case of loss and/or damage, contact the following surveyor:</text:h>
<text:h text:style-name="P44" text:outline-level="2"><text:placeholder text:placeholder-type="text">&lt;records[0].report_insurance_contact_surveyor or &apos;&apos;&gt;</text:placeholder></text:h>
<text:h text:style-name="P44" text:outline-level="2"><text:placeholder text:placeholder-type="text">&lt;for each=&quot;line in (records[0].report_insurance_contact_surveyor or &apos;&apos;).splitlines()&quot;&gt;</text:placeholder><text:placeholder text:placeholder-type="text">&lt;line&gt;</text:placeholder><text:placeholder text:placeholder-type="text">&lt;/for&gt;</text:placeholder></text:h>
<text:p text:style-name="P23"/>
<text:p text:style-name="P23"/>
<text:p text:style-name="P17">Surveyor&apos;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.</text:p>