shipping_information_on_customer_invoice need testing

This commit is contained in:
xtremxpert 2025-02-10 15:27:30 -05:00
parent 6ea64007e0
commit f41b3d2be1
5 changed files with 68 additions and 0 deletions

View file

@ -0,0 +1 @@
from . import models

View file

@ -0,0 +1,19 @@
{
'name': 'Shipping Information on Customer Invoice',
'version': '18.0.0.1',
'category': 'Accounting',
'summary': 'Add shipping carrier information on customer invoices',
'description': """
This module adds shipping carrier information to customer invoices:
* Carrier name
* Tracking number
* Billing mode
""",
'depends': ['account', 'delivery'],
'data': [
'views/report_invoice.xml',
],
'installable': True,
'auto_install': False,
'license': 'LGPL-3',
}

View file

@ -0,0 +1 @@
from . import account_move

View file

@ -0,0 +1,21 @@
from odoo import api, fields, models
class AccountMove(models.Model):
_inherit = 'account.move'
def _get_delivery_info(self):
"""Get the delivery information for the invoice."""
self.ensure_one()
if self.move_type != 'out_invoice':
return False
deliveries = self.picking_ids.filtered(lambda p: p.carrier_id)
if not deliveries:
return False
carrier = deliveries[0].carrier_id
return {
'carrier_name': carrier.name,
'tracking_ref': deliveries[0].carrier_tracking_ref or '',
'invoice_policy': dict(carrier._fields['invoice_policy'].selection).get(carrier.invoice_policy, carrier.invoice_policy),
}

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="report_invoice_document_inherit_shipping" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='informations']" position="inside">
<t t-if="o._get_delivery_info()">
<div class="col-auto col-3 mw-100 mb-2" name="shipping_info">
<strong>Shipping Information:</strong>
<p class="m-0">
<strong>Carrier: </strong>
<span t-esc="o._get_delivery_info()['carrier_name']"/>
</p>
<t t-if="o._get_delivery_info()['tracking_ref']">
<p class="m-0">
<strong>Tracking: </strong>
<span t-esc="o._get_delivery_info()['tracking_ref']"/>
</p>
</t>
<p class="m-0">
<strong>Billing Mode: </strong>
<span t-esc="o._get_delivery_info()['invoice_policy']"/>
</p>
</div>
</t>
</xpath>
</template>
</odoo>