[FIX] account_edi_ubl_cii: line id start at 1 in UBL
In Saudi Arabia, the InvoiceLine/ID should not be greater than 6 digits. Using the move.line_id, this limit can be exceeded. Simply count the invoice line ids starting from 1 instead. In master, add a parameter `line_id` to `_get_invoice_line_vals`. closes odoo/odoo#133794 X-original-commit: 3ce90ddf33f59a80de34cbafd05679d0817d0076 Signed-off-by: Josse Colpaert <jco@odoo.com> Signed-off-by: Julien Van Roy (juvr) <juvr@odoo.com>
This commit is contained in:
@@ -304,7 +304,7 @@ class AccountEdiXmlUBL20(models.AbstractModel):
|
||||
'base_quantity_attrs': {'unitCode': uom},
|
||||
}
|
||||
|
||||
def _get_invoice_line_vals(self, line, taxes_vals):
|
||||
def _get_invoice_line_vals(self, line, line_id, taxes_vals):
|
||||
""" Method used to fill the cac:InvoiceLine node.
|
||||
It provides information about the invoice line.
|
||||
|
||||
@@ -322,15 +322,10 @@ class AccountEdiXmlUBL20(models.AbstractModel):
|
||||
return {
|
||||
'currency': line.currency_id,
|
||||
'currency_dp': line.currency_id.decimal_places,
|
||||
|
||||
# The requirement is the id has to be unique by invoice line.
|
||||
'id': line.id,
|
||||
|
||||
'id': line_id + 1,
|
||||
'invoiced_quantity': line.quantity,
|
||||
'invoiced_quantity_attrs': {'unitCode': uom},
|
||||
|
||||
'line_extension_amount': line.price_subtotal + total_fixed_tax_amount,
|
||||
|
||||
'allowance_charge_vals': allowance_charge_vals_list,
|
||||
'tax_total_vals': self._get_invoice_tax_totals_vals_list(line.move_id, taxes_vals),
|
||||
'item_vals': self._get_invoice_line_item_vals(line, taxes_vals),
|
||||
@@ -394,9 +389,9 @@ class AccountEdiXmlUBL20(models.AbstractModel):
|
||||
invoice_lines = invoice.invoice_line_ids.filtered(lambda line: line.display_type not in ('line_note', 'line_section'))
|
||||
document_allowance_charge_vals_list = self._get_document_allowance_charge_vals_list(invoice)
|
||||
invoice_line_vals_list = []
|
||||
for line in invoice_lines:
|
||||
for line_id, line in enumerate(invoice_lines):
|
||||
line_taxes_vals = taxes_vals['tax_details_per_record'][line]
|
||||
line_vals = self._get_invoice_line_vals(line, line_taxes_vals)
|
||||
line_vals = self._get_invoice_line_vals(line, line_id, line_taxes_vals)
|
||||
invoice_line_vals_list.append(line_vals)
|
||||
|
||||
line_extension_amount += line_vals['line_extension_amount']
|
||||
|
||||
@@ -215,9 +215,9 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel):
|
||||
|
||||
return vals_list
|
||||
|
||||
def _get_invoice_line_vals(self, line, taxes_vals):
|
||||
def _get_invoice_line_vals(self, line, line_id, taxes_vals):
|
||||
# EXTENDS account.edi.xml.ubl_21
|
||||
vals = super()._get_invoice_line_vals(line, taxes_vals)
|
||||
vals = super()._get_invoice_line_vals(line, line_id, taxes_vals)
|
||||
|
||||
vals.pop('tax_total_vals', None)
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel):
|
||||
}
|
||||
return {}
|
||||
|
||||
def _get_invoice_line_vals(self, line, taxes_vals):
|
||||
def _get_invoice_line_vals(self, line, line_id, taxes_vals):
|
||||
""" Override to include/update values specific to ZATCA's UBL 2.1 specs """
|
||||
|
||||
def grouping_key_generator(base_line, tax_values):
|
||||
@@ -338,7 +338,7 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel):
|
||||
line_taxes = line.move_id._prepare_invoice_aggregated_taxes(grouping_key_generator=grouping_key_generator)
|
||||
taxes_vals = line_taxes['tax_details_per_record'][line]
|
||||
|
||||
line_vals = super()._get_invoice_line_vals(line, taxes_vals)
|
||||
line_vals = super()._get_invoice_line_vals(line, line_id, taxes_vals)
|
||||
total_amount_sa = abs(taxes_vals['tax_amount_currency'] + taxes_vals['base_amount_currency'])
|
||||
extension_amount = abs(line_vals['line_extension_amount'])
|
||||
if not line.move_id._is_downpayment() and line._get_downpayment_lines():
|
||||
|
||||
Reference in New Issue
Block a user