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_it_withholding_tax: wrong WT entry when paying multiple invoices #4160

Closed
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
11 changes: 7 additions & 4 deletions l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ 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 @@ -592,6 +592,9 @@ class AccountMoveLine(models.Model):
withholding_tax_generated_by_move_id = fields.Many2one(
"account.move", string="Withholding Tax generated from", readonly=True
)
withholding_tax_generated_by_move_line_id = fields.Many2one(
"account.move.line", string="Withholding Tax generated from", readonly=True
)

def remove_move_reconcile(self):
# When unreconcile a payment with a wt move linked, it will be
Expand All @@ -600,9 +603,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
Loading