Skip to content

Commit

Permalink
FIX l10n_it_withholding_tax: wrong WT entry when paying multiple invo…
Browse files Browse the repository at this point in the history
…ices
  • Loading branch information
eLBati committed Nov 18, 2024
1 parent f75cef5 commit 6e65412
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
17 changes: 13 additions & 4 deletions l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,15 @@ def create(self, vals_list):
ld = self.env["account.move.line"].browse(vals.get("debit_move_id"))
lc = self.env["account.move.line"].browse(vals.get("credit_move_id"))

move_ids = ld.move_id | lc.move_id
move_lines = ld | lc
lines = self.env["account.move.line"].search(
[("withholding_tax_generated_by_move_id", "in", move_ids.ids)]
[
(
"withholding_tax_generated_by_move_line_id",
"in",
move_lines.ids,
)
]
)
if lines:
is_wt_move = True
Expand Down Expand Up @@ -543,6 +549,9 @@ class AccountMoveLine(models.Model):
withholding_tax_id = fields.Many2one("withholding.tax", string="Withholding Tax")
withholding_tax_base = fields.Float()
withholding_tax_amount = fields.Float()
withholding_tax_generated_by_move_line_id = fields.Many2one(
"account.move.line", string="Withholding Tax generated from", readonly=True
)
withholding_tax_generated_by_move_id = fields.Many2one(
"account.move", string="Withholding Tax generated from", readonly=True
)
Expand All @@ -554,9 +563,9 @@ def remove_move_reconcile(self):
rec_move_ids = self.env["account.partial.reconcile"]
domain = [
(
"withholding_tax_generated_by_move_id",
"withholding_tax_generated_by_move_line_id",
"=",
account_move_line.move_id.id,
account_move_line.id,
)
]
wt_mls = self.env["account.move.line"].search(domain)
Expand Down
3 changes: 3 additions & 0 deletions l10n_it_withholding_tax/models/withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ def generate_account_move(self):
ml_vals[
"withholding_tax_generated_by_move_id"
] = self.payment_line_id.move_id.id
ml_vals[
"withholding_tax_generated_by_move_line_id"
] = self.payment_line_id.id
if self.payment_line_id.credit:
ml_vals["credit"] = abs(self.amount)
else:
Expand Down

0 comments on commit 6e65412

Please sign in to comment.