[IMP] account_edi_ubl_cii: always set customer reference

For PEPPOL, the Customer Reference field on invoices is a required
field. In Odoo it can be blank when creating an invoice from scratch.
In order to avoid errors when sending PEPPOL invoices, we want to
set the Customer Reference to the invoice name when no reference was
provided.

task-3499548

closes odoo/odoo#135158

Signed-off-by: Laurent Smet (las) <las@odoo.com>
This commit is contained in:
Dylan Kiss (dyki)
2023-10-17 10:05:48 +00:00
parent abe7f88a8b
commit a442fdc833
3 changed files with 7 additions and 1 deletions
@@ -491,7 +491,7 @@ class AccountEdiXmlUBL20(models.AbstractModel):
sales_order_id = 'sale_line_ids' in invoice.invoice_line_ids._fields \
and ",".join(invoice.invoice_line_ids.sale_line_ids.order_id.mapped('name'))
# OrderReference/ID (order_reference) is mandatory inside the OrderReference node !
order_reference = invoice.ref or invoice.name if sales_order_id else invoice.ref
order_reference = invoice.ref or invoice.name
vals = {
'builder': self,
@@ -9,6 +9,9 @@
<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
<cbc:BuyerReference>Mohammed Ali</cbc:BuyerReference>
<cac:OrderReference>
<cbc:ID>INV/2023/00034</cbc:ID>
</cac:OrderReference>
<cac:AdditionalDocumentReference>
<cbc:ID>QR</cbc:ID>
<cac:Attachment>
@@ -12,6 +12,9 @@
<cbc:DocumentCurrencyCode>SAR</cbc:DocumentCurrencyCode>
<cbc:TaxCurrencyCode>SAR</cbc:TaxCurrencyCode>
<cbc:BuyerReference>Azure Interior</cbc:BuyerReference>
<cac:OrderReference>
<cbc:ID>INV/2022/00014</cbc:ID>
</cac:OrderReference>
<cac:AdditionalDocumentReference>
<cbc:ID>PIH</cbc:ID>
<cac:Attachment>