[FIX] l10n_latam_invoice_document: invoice report

* remove l10n_latam_amount_tax field: This one is not really neccesary since was used for CITI reports and this ones were deprecated.
* improve invoice report view inherit: Improve way to make inherit for report invoice using position attribute
instead of position replace.
* Report amounts:

  * for excluded reports get price unit computing (and not price_unit) to get the untaxed price if the line has taxes with price included (as in sales)
  * fix l10n_latam_price_subtotal for report with taxes included and tax included on the price

closes odoo/odoo#36716

Signed-off-by: Josse Colpaert <jco@openerp.com>
This commit is contained in:
Katherine Zaoral
2019-09-13 15:26:32 +00:00
parent ae8e060cec
commit af0d0dcf61
3 changed files with 11 additions and 11 deletions
@@ -10,7 +10,6 @@ class AccountMove(models.Model):
_inherit = "account.move"
l10n_latam_amount_tax = fields.Monetary(compute='_compute_l10n_latam_amount_and_taxes')
l10n_latam_amount_untaxed = fields.Monetary(compute='_compute_l10n_latam_amount_and_taxes')
l10n_latam_tax_ids = fields.One2many(compute="_compute_l10n_latam_amount_and_taxes", comodel_name='account.move.line')
l10n_latam_available_document_type_ids = fields.Many2many('l10n_latam.document.type', compute='_compute_l10n_latam_documents')
@@ -67,7 +66,6 @@ class AccountMove(models.Model):
included_taxes = invoice.l10n_latam_document_type_id and \
invoice.l10n_latam_document_type_id._filter_taxes_included(tax_lines.mapped('tax_line_id'))
if not included_taxes:
l10n_latam_amount_tax = invoice.amount_tax
l10n_latam_amount_untaxed = invoice.amount_untaxed
not_included_invoice_taxes = tax_lines
else:
@@ -77,13 +75,10 @@ class AccountMove(models.Model):
sign = -1
else:
sign = 1
l10n_latam_amount_tax = sign * sum(not_included_invoice_taxes.mapped('balance'))
l10n_latam_amount_untaxed = invoice.amount_untaxed + sign * sum(included_invoice_taxes.mapped('balance'))
invoice.l10n_latam_amount_tax = l10n_latam_amount_tax
invoice.l10n_latam_amount_untaxed = l10n_latam_amount_untaxed
invoice.l10n_latam_tax_ids = not_included_invoice_taxes
remaining = self - recs_invoice
remaining.l10n_latam_amount_tax = False
remaining.l10n_latam_amount_untaxed = False
remaining.l10n_latam_tax_ids = []
@@ -22,7 +22,9 @@ class AccountMoveLine(models.Model):
invoice.l10n_latam_document_type_id and invoice.l10n_latam_document_type_id._filter_taxes_included(
line.tax_ids)
if not included_taxes:
l10n_latam_price_unit = line.price_unit
price_unit = line.tax_ids.with_context(round=False).compute_all(
line.price_unit, invoice.currency_id, 1.0, line.product_id, invoice.partner_id)
l10n_latam_price_unit = price_unit['total_excluded']
l10n_latam_price_subtotal = line.price_subtotal
not_included_taxes = line.tax_ids
l10n_latam_price_net = l10n_latam_price_unit * (1 - (line.discount or 0.0) / 100.0)
@@ -31,7 +33,10 @@ class AccountMoveLine(models.Model):
l10n_latam_price_unit = included_taxes.compute_all(
line.price_unit, invoice.currency_id, 1.0, line.product_id, invoice.partner_id)['total_included']
l10n_latam_price_net = l10n_latam_price_unit * (1 - (line.discount or 0.0) / 100.0)
l10n_latam_price_subtotal = l10n_latam_price_net * line.quantity
l10n_latam_price_subtotal = included_taxes.compute_all(
line.price_unit, invoice.currency_id, line.quantity, line.product_id,
invoice.partner_id)['total_included']
line.l10n_latam_price_subtotal = l10n_latam_price_subtotal
line.l10n_latam_price_unit = l10n_latam_price_unit
line.l10n_latam_price_net = l10n_latam_price_net
@@ -25,12 +25,12 @@
<attribute name="t-esc">', '.join(map(lambda x: (x.description or x.name), line.l10n_latam_tax_ids))</attribute>
</xpath>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" position="replace">
<t t-set="current_subtotal" t-value="current_subtotal + line.l10n_latam_price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" position="attributes">
<attribute name="t-value">current_subtotal + line.l10n_latam_price_subtotal</attribute>
</t>
<span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded" position="replace">
<span t-field="line.l10n_latam_price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span t-field="line.price_subtotal" position="attributes">
<attribute name="t-field">line.l10n_latam_price_subtotal</attribute>
</span>
<span t-field="o.amount_untaxed" position="attributes">