Add packing list in account invoice

This commit is contained in:
2026-04-22 20:36:14 +02:00
parent d09d183cdc
commit 99782b5b0e
6 changed files with 1567 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -16,6 +16,8 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
'report_invoice_ict_final', 'CN/DN'),
('invoice_prepayment_report_label', 'account_invoice',
'report_prepayment', 'Prepayment'),
('invoice_packing_list_report_label', 'purchase_trade',
'report_invoice_packing_list', 'Packing List'),
('invoice_payment_order_report_label', 'purchase_trade',
'report_payment_order', 'Payment Order'),
('purchase_report_label', 'purchase', 'report_purchase', 'Purchase'),
@@ -39,6 +41,8 @@ class Configuration(ModelSingleton, ModelSQL, ModelView):
invoice_cndn_report_label = fields.Char("CN/DN Menu Label")
invoice_prepayment_report_template = fields.Char("Prepayment Template")
invoice_prepayment_report_label = fields.Char("Prepayment Menu Label")
invoice_packing_list_report_template = fields.Char("Packing List Template")
invoice_packing_list_report_label = fields.Char("Packing List Menu Label")
invoice_payment_order_report_template = fields.Char("Payment Order Template")
invoice_payment_order_report_label = fields.Char(
"Payment Order Menu Label")

View File

@@ -959,6 +959,29 @@ class Invoice(metaclass=PoolMeta):
return 'Debit Note'
return 'Credit Note'
@property
def report_transportation(self):
shipment = self._get_report_shipment()
if not shipment:
return ''
supplier = getattr(shipment, 'supplier', None)
vessel = getattr(shipment, 'vessel', None)
supplier_name = (
getattr(supplier, 'name', None)
or getattr(supplier, 'rec_name', None)
or '')
vessel_name = getattr(vessel, 'vessel_name', None) or ''
note = getattr(shipment, 'note', None) or ''
if supplier_name and vessel_name:
transport = f"BY {supplier_name} ({vessel_name})"
elif supplier_name:
transport = f"BY {supplier_name}"
else:
transport = vessel_name
return ' '.join(part for part in [transport, note] if part).strip()
@property
def report_bl_date(self):
shipment = self._get_report_shipment()
@@ -1239,6 +1262,8 @@ class InvoiceReport(ReportTemplateMixin, BaseInvoiceReport):
if (report_path.endswith('/prepayment.fodt')
or action_name == 'Prepayment'):
field_name = 'invoice_prepayment_report_template'
elif report_path.endswith('/packing_list.fodt'):
field_name = 'invoice_packing_list_report_template'
elif (report_path.endswith('/payment_order.fodt')
or action_name == 'Payment Order'):
field_name = 'invoice_payment_order_report_template'

View File

@@ -1,5 +1,18 @@
<tryton>
<data>
<record model="ir.action.report" id="report_invoice_packing_list">
<field name="name">Packing List</field>
<field name="model">account.invoice</field>
<field name="report_name">account.invoice</field>
<field name="report">account_invoice/packing_list.fodt</field>
<field name="single" eval="True"/>
</record>
<record model="ir.action.keyword" id="report_invoice_packing_list_keyword">
<field name="keyword">form_print</field>
<field name="model">account.invoice,-1</field>
<field name="action" ref="report_invoice_packing_list"/>
</record>
<record model="ir.action.report" id="report_payment_order">
<field name="name">Payment Order</field>
<field name="model">account.invoice</field>

View File

@@ -941,6 +941,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
invoice_report_template='invoice_melya.fodt',
invoice_cndn_report_template='invoice_ict_final.fodt',
invoice_prepayment_report_template='prepayment.fodt',
invoice_packing_list_report_template='packing_list.fodt',
invoice_payment_order_report_template='payment_order.fodt',
purchase_report_template='purchase_melya.fodt',
)
@@ -975,6 +976,12 @@ class PurchaseTradeTestCase(ModuleTestCase):
'report': 'account_invoice/payment_order.fodt',
}),
'account_invoice/payment_order.fodt')
self.assertEqual(
report_class._resolve_configured_report_path({
'name': 'Packing List',
'report': 'account_invoice/packing_list.fodt',
}),
'account_invoice/packing_list.fodt')
def test_invoice_report_raises_when_template_is_missing(self):
'invoice report must fail clearly when no template is configured'
@@ -985,6 +992,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
invoice_report_template='',
invoice_cndn_report_template='',
invoice_prepayment_report_template='',
invoice_packing_list_report_template='',
invoice_payment_order_report_template='',
)
]
@@ -1003,6 +1011,11 @@ class PurchaseTradeTestCase(ModuleTestCase):
'name': 'Payment Order',
'report': 'account_invoice/payment_order.fodt',
})
with self.assertRaises(UserError):
report_class._resolve_configured_report_path({
'name': 'Packing List',
'report': 'account_invoice/packing_list.fodt',
})
def test_sale_report_uses_templates_from_configuration(self):
'sale report paths are resolved from purchase_trade configuration'
@@ -1107,6 +1120,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
invoice_report_label='',
invoice_cndn_report_label='',
invoice_prepayment_report_label='',
invoice_packing_list_report_label='Packing Slip',
invoice_payment_order_report_label='Wire Order',
purchase_report_label='',
shipment_shipping_report_label='',
@@ -1125,6 +1139,8 @@ class PurchaseTradeTestCase(ModuleTestCase):
action_prepayment.name = 'Prepayment'
action_payment_order = Mock(spec=['name'])
action_payment_order.name = 'Payment Order'
action_invoice_packing = Mock(spec=['name'])
action_invoice_packing.name = 'Packing List'
action_purchase = Mock(spec=['name'])
action_purchase.name = 'Purchase'
action_shipping = Mock(spec=['name'])
@@ -1140,10 +1156,11 @@ class PurchaseTradeTestCase(ModuleTestCase):
4: action_cndn,
5: action_prepayment,
6: action_payment_order,
7: action_purchase,
8: action_shipping,
9: action_insurance,
10: action_packing,
7: action_invoice_packing,
8: action_purchase,
9: action_shipping,
10: action_insurance,
11: action_packing,
}
model_data = Mock()
@@ -1169,6 +1186,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
(
[actions[1]], {'name': 'Offer'},
[actions[2]], {'name': 'Draft'},
[actions[7]], {'name': 'Packing Slip'},
[actions[6]], {'name': 'Wire Order'},
))

View File

@@ -25,6 +25,10 @@
<field name="invoice_prepayment_report_template" colspan="3"/>
<label name="invoice_prepayment_report_label"/>
<field name="invoice_prepayment_report_label" colspan="3"/>
<label name="invoice_packing_list_report_template"/>
<field name="invoice_packing_list_report_template" colspan="3"/>
<label name="invoice_packing_list_report_label"/>
<field name="invoice_packing_list_report_label" colspan="3"/>
<separator id="payment_templates" string="Payment" colspan="4"/>
<label name="invoice_payment_order_report_template"/>