diff --git a/modules/account_invoice/invoice_melya.fodt b/modules/account_invoice/invoice_melya.fodt index ac42534..9f55f0e 100644 --- a/modules/account_invoice/invoice_melya.fodt +++ b/modules/account_invoice/invoice_melya.fodt @@ -595,7 +595,7 @@ - + diff --git a/modules/purchase_trade/invoice.py b/modules/purchase_trade/invoice.py index c7a896c..80f12a5 100644 --- a/modules/purchase_trade/invoice.py +++ b/modules/purchase_trade/invoice.py @@ -2305,19 +2305,34 @@ class Invoice(metaclass=PoolMeta): shipment = self._get_report_shipment() if shipment and shipment.vessel: return shipment.vessel.vessel_name + + @staticmethod + def _report_location_with_country(location): + if not location: + return '' + location_name = ( + getattr(location, 'rec_name', None) + or getattr(location, 'name', None) + or '') + country = getattr(location, 'country', None) + country_name = getattr(country, 'name', None) if country else '' + parts = [ + part for part in [location_name, country_name] + if isinstance(part, str) and part] + return ' '.join(parts) @property def report_loading_port(self): shipment = self._get_report_shipment() if shipment and shipment.from_location: - return shipment.from_location.rec_name + return self._report_location_with_country(shipment.from_location) return '' @property def report_discharge_port(self): shipment = self._get_report_shipment() if shipment and shipment.to_location: - return shipment.to_location.rec_name + return self._report_location_with_country(shipment.to_location) return '' @property diff --git a/modules/purchase_trade/tests/test_module.py b/modules/purchase_trade/tests/test_module.py index db93d57..1d77c7f 100644 --- a/modules/purchase_trade/tests/test_module.py +++ b/modules/purchase_trade/tests/test_module.py @@ -10786,8 +10786,10 @@ description bl_date='2026-04-05', bl_number='BL-B', vessel=Mock(vessel_name='VESSEL B'), - from_location=Mock(rec_name='LOADING B'), - to_location=Mock(rec_name='DISCHARGE B'), + from_location=Mock( + rec_name='LOADING B', country=Mock(name='Brazil')), + to_location=Mock( + rec_name='DISCHARGE B', country=Mock(name='Turkey')), controller=Mock(rec_name='CTRL B'), number='SI-B', ) @@ -10805,8 +10807,8 @@ description self.assertEqual(invoice.report_bl_nb, 'BL-B') self.assertEqual(invoice.report_bl_date, '2026-04-05') self.assertEqual(invoice.report_vessel, 'VESSEL B') - self.assertEqual(invoice.report_loading_port, 'LOADING B') - self.assertEqual(invoice.report_discharge_port, 'DISCHARGE B') + self.assertEqual(invoice.report_loading_port, 'LOADING B Brazil') + self.assertEqual(invoice.report_discharge_port, 'DISCHARGE B Turkey') self.assertEqual(invoice.report_controller_name, 'CTRL B') self.assertEqual(invoice.report_si_number, 'SI-B') self.assertEqual(invoice.report_si_reference, 'REF-B')