Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] l10n_do_accounting: correctly compute l10n_do_itbis_amount #1109

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion l10n_do_accounting/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"category": "Localization",
"license": "LGPL-3",
"website": "https://github.com/odoo-dominicana",
"version": "16.0.1.1.12",
"version": "16.0.1.2.0",
# any module necessary for this one to work correctly
"depends": ["l10n_latam_invoice_document", "l10n_do"],
# always loaded
Expand Down
54 changes: 19 additions & 35 deletions l10n_do_accounting/models/account_move_line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from odoo import models, fields
from odoo import models, fields, api


class AccountMoveLine(models.Model):
Expand All @@ -9,43 +9,27 @@ class AccountMoveLine(models.Model):
store=True,
readonly=True,
currency_field="currency_id",
compute="_compute_totals",
)

def _get_price_total_and_subtotal(
self,
price_unit=None,
quantity=None,
discount=None,
currency=None,
product=None,
partner=None,
taxes=None,
move_type=None,
):
self.ensure_one()
res = super(AccountMoveLine, self)._get_price_total_and_subtotal(
price_unit=price_unit,
quantity=quantity,
discount=discount,
currency=currency,
product=product,
partner=partner,
taxes=taxes,
move_type=move_type,
)
@api.depends("quantity", "discount", "price_unit", "tax_ids", "currency_id")
def _compute_totals(self):
super()._compute_totals()
for line in self:
if line.display_type != "product":
line.l10n_do_itbis_amount = False

if self.move_id.is_ecf_invoice:
line_itbis_taxes = self.tax_ids.filtered(
lambda t: t.tax_group_id == self.env.ref("l10n_do.group_itbis")
)
itbis_taxes_data = line_itbis_taxes.compute_all(
price_unit=self.price_unit,
quantity=self.quantity,
)
res["l10n_do_itbis_amount"] = sum(
[t["amount"] for t in itbis_taxes_data["taxes"]]
)
return res
if line.move_id.is_ecf_invoice:
line_itbis_taxes = line.tax_ids.filtered(
lambda t: t.tax_group_id == self.env.ref("l10n_do.group_itbis")
)
itbis_taxes_data = line_itbis_taxes.compute_all(
price_unit=line.price_unit,
quantity=line.quantity,
)
line.l10n_do_itbis_amount = sum(
[t["amount"] for t in itbis_taxes_data["taxes"]]
)

def _get_l10n_do_line_amounts(self):
group_itbis = self.env.ref("l10n_do.group_itbis")
Expand Down
Loading