Skip to content

Commit

Permalink
fixup! [FIX] l10n_it_withholding_tax: porting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMule71 committed May 5, 2021
1 parent 01275bd commit 548e8fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions l10n_it_withholding_tax/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ def create(self, vals):
if vals.get("credit_move_id"):
ml_ids.append(vals.get("credit_move_id"))
move_lines = self.env["account.move.line"].browse(ml_ids)
invoice = move_lines.filtered(lambda x: x.exists()).move_id
# invoice.ensure_one() XXX - should we do this?
invoice = move_lines.filtered(lambda x: x.exists()).move_id.filtered(
lambda x: x.is_invoice()
)
invoice.ensure_one()
# Limit value of reconciliation
if invoice and invoice.withholding_tax and invoice.amount_net_pay:
# We must consider amount in foreign currency, if present
Expand Down Expand Up @@ -360,7 +362,7 @@ def _compute_amount_withholding_tax(self):
readonly=True,
)

@api.onchange("line_ids")
@api.onchange("invoice_line_ids")
def _onchange_invoice_line_wt_ids(self):
self.ensure_one()
wt_taxes_grouped = self.get_wt_taxes_values()
Expand Down Expand Up @@ -415,10 +417,12 @@ def get_wt_taxes_values(self):
for invoice in self:
for line in invoice.invoice_line_ids:
taxes = []
for wt_tax in line.invoice_line_tax_wt_ids.filtered(lambda x: x.id):
for wt_tax in line.invoice_line_tax_wt_ids.filtered(
lambda x: x._origin.id
):
res = wt_tax.compute_tax(line.price_subtotal)
tax = {
"id": wt_tax.id,
"id": wt_tax._origin.id,
"sequence": wt_tax.sequence,
"base": res["base"],
"tax": res["tax"],
Expand Down
4 changes: 2 additions & 2 deletions l10n_it_withholding_tax/models/withholding_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _compute_get_rate(self):
for wt in self:
wt.tax = 0
wt.base = 1
if not wt.id:
if not wt._origin.id:
continue
self.env.cr.execute(
"""
Expand All @@ -27,7 +27,7 @@ def _compute_get_rate(self):
and (date_start <= current_date or date_start is null)
and (date_stop >= current_date or date_stop is null)
ORDER by date_start LIMIT 1""",
(wt.id,),
(wt._origin.id,),
)
rate = self.env.cr.fetchone()
if rate:
Expand Down

0 comments on commit 548e8fb

Please sign in to comment.