summaryrefslogtreecommitdiff
path: root/addons/l10n_it_edi
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-02-23 10:34:52 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2021-02-24 14:13:42 +0000
commit71cc7212b1c1abad5d37e29f3a1f33f6e6cd2a81 (patch)
tree5e6e671349b69f8847ea462d656d39a5970069fc /addons/l10n_it_edi
parenta08ba4be6518dd99ce93a803724165f62cbef032 (diff)
[FIX] l10n_it_edi: generate xml for invoices with 0% tax only
Have an invoice with single line and 0% tax on it As the tax has 0 amount, no related moves are created, the e-invoice export will fail the formal compliance check as it is missing a section opw-2461496 closes odoo/odoo#66668 Signed-off-by: agr-odoo <agr-odoo@users.noreply.github.com>
Diffstat (limited to 'addons/l10n_it_edi')
-rw-r--r--addons/l10n_it_edi/data/invoice_it_template.xml12
-rw-r--r--addons/l10n_it_edi/models/account_invoice.py12
2 files changed, 23 insertions, 1 deletions
diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml
index cfb2833e556..3713bd66e92 100644
--- a/addons/l10n_it_edi/data/invoice_it_template.xml
+++ b/addons/l10n_it_edi/data/invoice_it_template.xml
@@ -172,7 +172,17 @@
<RiferimentoNormativo t-if="tax_line.tax_line_id.l10n_it_has_exoneration" t-esc="tax_line.tax_line_id.l10n_it_law_reference"/>
</DatiRiepilogo>
</t>
-
+ <!-- 0% tax lines -->
+ <t t-foreach="tax_map" t-as="tax">
+ <DatiRiepilogo>
+ <AliquotaIVA t-esc="format_numbers(tax.amount)"/>
+ <Natura t-if="tax.l10n_it_has_exoneration" t-esc="tax.l10n_it_kind_exoneration"/>
+ <ImponibileImporto t-esc="format_monetary(tax_map[tax], currency)"/>
+ <Imposta t-esc="format_monetary(0.00, currency)"/>
+ <EsigibilitaIVA t-if="not tax.l10n_it_has_exoneration or tax.l10n_it_kind_exoneration=='N6'" t-esc="tax.l10n_it_vat_due_date"/>
+ <RiferimentoNormativo t-if="tax.l10n_it_has_exoneration" t-esc="tax.l10n_it_law_reference"/>
+ </DatiRiepilogo>
+ </t>
</DatiBeniServizi>
<DatiPagamento>
<t t-set="payments" t-value="record.line_ids.filtered(lambda line: line.account_id.user_type_id.type in ('receivable', 'payable'))"/>
diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py
index e1198a4919c..6a21a41fe6f 100644
--- a/addons/l10n_it_edi/models/account_invoice.py
+++ b/addons/l10n_it_edi/models/account_invoice.py
@@ -223,6 +223,17 @@ class AccountMove(models.Model):
pdf = base64.b64encode(pdf)
pdf_name = re.sub(r'\W+', '', self.name) + '.pdf'
+ # tax map for 0% taxes which have no tax_line_id
+ tax_map = dict()
+ for line in self.line_ids:
+ for tax in line.tax_ids:
+ if tax.amount == 0.0:
+ tax_amount = tax.compute_all(line.price_unit, currency=line.currency_id, quantity=line.quantity, product=line.product_id, partner=line.partner_id)
+ if tax in tax_map:
+ tax_map[tax] += tax_amount['total_excluded']
+ else:
+ tax_map[tax] = tax_amount['total_excluded']
+
# Create file content.
template_values = {
'record': self,
@@ -240,6 +251,7 @@ class AccountMove(models.Model):
'document_type': document_type,
'pdf': pdf,
'pdf_name': pdf_name,
+ 'tax_map': tax_map,
}
content = self.env.ref('l10n_it_edi.account_invoice_it_FatturaPA_export')._render(template_values)
return content