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][IMP] account_reconcile_analytic_tag: Using the _get_write_off_move_move_line_dict() method #776

Merged
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
41 changes: 5 additions & 36 deletions account_reconcile_analytic_tag/models/account_reconcile_model.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,8 @@
# Copyright 2024 Tecnativa - Víctor Martínez
# Copyright 2024-2025 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
from odoo import fields, models


class AccountReconcileModel(models.Model):
_inherit = "account.reconcile.model"

# TODO: Remove if merging https://github.com/odoo/odoo/pull/188808
def _get_write_off_move_lines_dict(self, residual_balance, partner_id):
res = super()._get_write_off_move_lines_dict(
residual_balance=residual_balance, partner_id=partner_id
)
if len(res) == 0:
return res
currency = self.company_id.currency_id
index = 0
for line in self.line_ids:
if line.amount_type == "percentage":
balance = currency.round(residual_balance * (line.amount / 100.0))
elif line.amount_type == "fixed":
balance = currency.round(
line.amount * (1 if residual_balance > 0.0 else -1)
)
else:
balance = 0.0

if currency.is_zero(balance):
continue

res[index]["manual_analytic_tag_ids"] = [(6, 0, line.analytic_tag_ids.ids)]
index += 1
return res


class AccountReconcileModelLine(models.Model):
_inherit = "account.reconcile.model.line"

Expand All @@ -42,8 +12,7 @@ class AccountReconcileModelLine(models.Model):
domain="['|', ('company_id', '=', False), ('company_id', '=', company_id)]",
)

# TODO: Use if merging https://github.com/odoo/odoo/pull/188808
# def _get_write_off_move_line_dict(self, balance):
# vals = super()._get_write_off_move_line_dict(balance)
# vals["manual_analytic_tag_ids"] = [(6, 0, self.analytic_tag_ids.ids)]
# return vals
def _get_write_off_move_line_dict(self, balance, currency):
vals = super()._get_write_off_move_line_dict(balance, currency)
vals["manual_analytic_tag_ids"] = [(6, 0, self.analytic_tag_ids.ids)]
return vals
Loading