diff --git a/addons/l10n_cl/models/__init__.py b/addons/l10n_cl/models/__init__.py
index ecf580afe15..6d1d2f88ca6 100644
--- a/addons/l10n_cl/models/__init__.py
+++ b/addons/l10n_cl/models/__init__.py
@@ -2,6 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import account_chart_template
from . import account_move
+from . import account_move_line
from . import account_tax
from . import l10n_latam_document_type
from . import res_company
diff --git a/addons/l10n_cl/models/account_move.py b/addons/l10n_cl/models/account_move.py
index d85800d89d4..fdc20d0b6c4 100644
--- a/addons/l10n_cl/models/account_move.py
+++ b/addons/l10n_cl/models/account_move.py
@@ -42,7 +42,6 @@ class AccountMove(models.Model):
domain += [('code', 'in', [])]
return domain
-
def _check_document_types_post(self):
for rec in self.filtered(
lambda r: r.company_id.account_fiscal_country_id.code == "CL" and
@@ -120,3 +119,26 @@ class AccountMove(models.Model):
if self.l10n_latam_use_documents and self.company_id.account_fiscal_country_id.code == 'CL':
return 'l10n_cl.report_invoice_document'
return super()._get_name_invoice_report()
+
+ def _l10n_cl_get_invoice_totals_for_report(self):
+ self.ensure_one()
+ tax_ids_filter = tax_line_id_filter = None
+ include_sii = self._l10n_cl_include_sii()
+
+ if include_sii:
+ tax_ids_filter = (lambda aml, tax: bool(tax.l10n_cl_sii_code != 14))
+ tax_line_id_filter = (lambda aml, tax: bool(tax.l10n_cl_sii_code != 14))
+
+ tax_lines_data = self._prepare_tax_lines_data_for_totals_from_invoice(
+ tax_ids_filter=tax_ids_filter, tax_line_id_filter=tax_line_id_filter)
+
+ if include_sii:
+ amount_untaxed = self.currency_id.round(
+ self.amount_total - sum([x['tax_amount'] for x in tax_lines_data if 'tax_amount' in x]))
+ else:
+ amount_untaxed = self.amount_untaxed
+ return self._get_tax_totals(self.partner_id, tax_lines_data, self.amount_total, amount_untaxed, self.currency_id)
+
+ def _l10n_cl_include_sii(self):
+ self.ensure_one()
+ return self.l10n_latam_document_type_id.code in ['39', '41', '110', '111', '112', '34']
diff --git a/addons/l10n_cl/models/account_move_line.py b/addons/l10n_cl/models/account_move_line.py
new file mode 100644
index 00000000000..d700ad1ad89
--- /dev/null
+++ b/addons/l10n_cl/models/account_move_line.py
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# Part of Odoo. See LICENSE file for full copyright and licensing details.
+from odoo import models
+
+
+class AccountMoveLine(models.Model):
+
+ _inherit = 'account.move.line'
+
+ def _l10n_cl_prices_and_taxes(self):
+ self.ensure_one()
+ invoice = self.move_id
+ included_taxes = self.tax_ids.filtered(lambda x: x.l10n_cl_sii_code == 14) if self.move_id._l10n_cl_include_sii() else self.tax_ids
+ if not included_taxes:
+ price_unit = self.tax_ids.with_context(round=False).compute_all(
+ self.price_unit, invoice.currency_id, 1.0, self.product_id, invoice.partner_id)
+ price_unit = price_unit['total_excluded']
+ price_subtotal = self.price_subtotal
+ else:
+ price_unit = included_taxes.compute_all(
+ self.price_unit, invoice.currency_id, 1.0, self.product_id, invoice.partner_id)['total_included']
+ price = self.price_unit * (1 - (self.discount or 0.0) / 100.0)
+ price_subtotal = included_taxes.compute_all(
+ price, invoice.currency_id, self.quantity, self.product_id, invoice.partner_id)['total_included']
+ price_net = price_unit * (1 - (self.discount or 0.0) / 100.0)
+
+ return {
+ 'price_unit': price_unit,
+ 'price_subtotal': price_subtotal,
+ 'price_net': price_net
+ }
diff --git a/addons/l10n_cl/models/l10n_latam_document_type.py b/addons/l10n_cl/models/l10n_latam_document_type.py
index e458cb719ba..6e5916b9527 100644
--- a/addons/l10n_cl/models/l10n_latam_document_type.py
+++ b/addons/l10n_cl/models/l10n_latam_document_type.py
@@ -28,10 +28,3 @@ class L10nLatamDocumentType(models.Model):
return False
return document_number.zfill(6)
-
- def _filter_taxes_included(self, taxes):
- """ In Chile we include taxes depending on document type """
- self.ensure_one()
- if self.country_id.code == "CL" and self.code in ['39', '41', '110', '111', '112', '34']:
- return taxes.filtered(lambda x: x.l10n_cl_sii_code == 14)
- return super()._filter_taxes_included(taxes)
diff --git a/addons/l10n_cl/views/report_invoice.xml b/addons/l10n_cl/views/report_invoice.xml
index b4b42680fb2..85b751d2f75 100644
--- a/addons/l10n_cl/views/report_invoice.xml
+++ b/addons/l10n_cl/views/report_invoice.xml
@@ -138,16 +138,22 @@
+
+
+
+
- line.l10n_latam_price_unit
+
+ line.price_unit
+ {"widget": "monetary", "display_currency": o.currency_id}
- ', '.join(map(lambda x: (x.description or x.name), line.l10n_latam_tax_ids))
+ ', '.join(map(lambda x: (x.description or x.name), line.tax_lines))
- current_subtotal + line.l10n_latam_price_subtotal
+ current_subtotal + l10n_cl_values['price_subtotal']
@@ -155,11 +161,13 @@
- line.l10n_latam_price_subtotal
+
+ current_subtotal + l10n_cl_values['price_subtotal']
+ {"widget": "monetary", "display_currency": o.currency_id}
- o._get_tax_totals_for_latam_invoice_report()
+ o._l10n_cl_get_invoice_totals_for_report()