Skip to content

Commit

Permalink
Merge PR #776 into 16.0
Browse files Browse the repository at this point in the history
Signed-off-by pedrobaeza
  • Loading branch information
OCA-git-bot committed Jan 7, 2025
2 parents 5d1095c + f808c46 commit 8fcadb6
Showing 1 changed file with 5 additions and 36 deletions.
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

0 comments on commit 8fcadb6

Please sign in to comment.