Render insurance surveyor address as block
This commit is contained in:
@@ -1331,6 +1331,49 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
def _normalize_report_address_line(value):
|
||||
return ' '.join(str(value or '').split()).strip().casefold()
|
||||
|
||||
@staticmethod
|
||||
def _get_report_address_text(value):
|
||||
return value.strip() if isinstance(value, str) else ''
|
||||
|
||||
@classmethod
|
||||
def _split_report_address_value(cls, value):
|
||||
lines = []
|
||||
for line in cls._get_report_address_text(value).splitlines():
|
||||
parts = line.split(',') if ',' in line else [line]
|
||||
lines.extend(part.strip() for part in parts if part.strip())
|
||||
return lines
|
||||
|
||||
@classmethod
|
||||
def _get_report_address_block_lines(cls, address):
|
||||
lines = []
|
||||
for field in ['name', 'street']:
|
||||
lines.extend(cls._split_report_address_value(
|
||||
getattr(address, field, None)))
|
||||
|
||||
postal_code = cls._get_report_address_text(
|
||||
getattr(address, 'postal_code', None))
|
||||
city = cls._get_report_address_text(getattr(address, 'city', None))
|
||||
city_line = ' '.join(filter(None, [postal_code, city]))
|
||||
if city_line:
|
||||
lines.append(city_line)
|
||||
|
||||
country = getattr(address, 'country', None)
|
||||
country_name = ''
|
||||
if country:
|
||||
country_name = (
|
||||
cls._get_report_address_text(getattr(country, 'name', None))
|
||||
or cls._get_report_address_text(
|
||||
getattr(country, 'rec_name', None)))
|
||||
if country_name:
|
||||
lines.append(country_name)
|
||||
|
||||
if lines:
|
||||
return lines
|
||||
|
||||
full_address = cls._get_report_address_text(
|
||||
getattr(address, 'full_address', None))
|
||||
return cls._split_report_address_value(full_address)
|
||||
|
||||
@classmethod
|
||||
def _get_report_party_address_lines(cls, party):
|
||||
if not party:
|
||||
@@ -1352,15 +1395,7 @@ class ShipmentIn(metaclass=PoolMeta):
|
||||
]
|
||||
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:
|
||||
for line in cls._get_report_address_block_lines(address):
|
||||
if cls._normalize_report_address_line(line) in duplicate_names:
|
||||
continue
|
||||
lines.append(line)
|
||||
|
||||
@@ -7784,6 +7784,30 @@ description</t></is></c>
|
||||
shipment.report_insurance_contact_surveyor,
|
||||
'SGS\nRue du Test 1\n1201 Geneva\nSwitzerland')
|
||||
|
||||
def test_shipment_insurance_contact_surveyor_splits_flat_address(self):
|
||||
'insurance contact surveyor splits flat address into a block'
|
||||
ShipmentIn = Pool().get('stock.shipment.in')
|
||||
shipment = ShipmentIn()
|
||||
address = Mock(
|
||||
party_name='KARESI',
|
||||
party_full_name='KARESI',
|
||||
full_address=(
|
||||
'KARESI, ATEAYENIKOY MAH, YENIKOY 51 SOK NO:7, '
|
||||
'TAX ID: KARESI VD 218012979110100, '
|
||||
'KARESI-BALIKESIR, TURKIYE'))
|
||||
shipment.surveyor = Mock(
|
||||
rec_name='KARESI',
|
||||
full_name='KARESI',
|
||||
address_get=Mock(return_value=address))
|
||||
shipment.controller = Mock(rec_name='CONTROL UNION')
|
||||
shipment.fees = []
|
||||
|
||||
self.assertEqual(
|
||||
shipment.report_insurance_contact_surveyor,
|
||||
'KARESI\nATEAYENIKOY MAH\nYENIKOY 51 SOK NO:7\n'
|
||||
'TAX ID: KARESI VD 218012979110100\n'
|
||||
'KARESI-BALIKESIR\nTURKIYE')
|
||||
|
||||
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')
|
||||
|
||||
@@ -1053,7 +1053,9 @@
|
||||
<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:p text:style-name="P37"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><for each="line in (records[0].report_insurance_contact_surveyor or '').splitlines()"></text:placeholder></text:span><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><line></text:placeholder></text:span><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"></for></text:placeholder></text:span></text:p>
|
||||
<text:p text:style-name="P37"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><for each="line in (records[0].report_insurance_contact_surveyor or '').splitlines()"></text:placeholder></text:span></text:p>
|
||||
<text:p text:style-name="P37"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"><line></text:placeholder></text:span></text:p>
|
||||
<text:p text:style-name="P37"><text:span text:style-name="T5"><text:placeholder text:placeholder-type="text"></for></text:placeholder></text:span></text:p>
|
||||
<text:p text:style-name="P23"/>
|
||||
<text:p text:style-name="P23"/>
|
||||
<text:p text:style-name="P17">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.</text:p>
|
||||
|
||||
Reference in New Issue
Block a user