diff --git a/modules/purchase_trade/stock.py b/modules/purchase_trade/stock.py
index a4fec24..4fe654a 100755
--- a/modules/purchase_trade/stock.py
+++ b/modules/purchase_trade/stock.py
@@ -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)
diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py
index 722b4d5..6e4b843 100644
--- a/modules/purchase_trade/tests/test_module.py
+++ b/modules/purchase_trade/tests/test_module.py
@@ -7784,6 +7784,30 @@ description
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')
diff --git a/modules/stock/insurance.fodt b/modules/stock/insurance.fodt
index 6ec671c..04bc556 100644
--- a/modules/stock/insurance.fodt
+++ b/modules/stock/insurance.fodt
@@ -1053,7 +1053,9 @@
applicable) and strike as per hte according Clauses.
In case of loss and/or damage, contact the following surveyor:
- <for each="line in (records[0].report_insurance_contact_surveyor or '').splitlines()"><line></for>
+ <for each="line in (records[0].report_insurance_contact_surveyor or '').splitlines()">
+ <line>
+ </for>
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.