Skip to content

Commit 2823c18

Browse files
committed
[FIX] multiple payment on wizard payment register
1 parent 79ffb57 commit 2823c18

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

l10n_it_withholding_tax/wizards/account_payment_register.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,23 @@ class AccountPaymentRegister(models.TransientModel):
1111
@api.model
1212
def _get_wizard_values_from_batch(self, batch_result):
1313
wizard_values_from_batch = super()._get_wizard_values_from_batch(batch_result)
14-
self._inject_withholding_net_pay_residual(wizard_values_from_batch)
14+
self._inject_withholding_net_pay_residual(
15+
wizard_values_from_batch, lines=batch_result.get("lines", False)
16+
)
1517
return wizard_values_from_batch
1618

17-
def _inject_withholding_net_pay_residual(self, wizard_values_from_batch):
19+
def _inject_withholding_net_pay_residual(
20+
self, wizard_values_from_batch, lines=False
21+
):
1822
"""If the payment is for Invoices having Withholding Taxes,
1923
set the Residual Net To Pay as the amount to be paid.
2024
"""
2125
if self.env.context.get("active_model") == "account.move":
22-
moves_ids = self.env.context.get("active_ids", [])
23-
moves = self.env["account.move"].browse(moves_ids)
26+
if lines and lines.exists():
27+
moves = lines.mapped("move_id")
28+
else:
29+
moves_ids = self.env.context.get("active_ids", [])
30+
moves = self.env["account.move"].browse(moves_ids)
2431
withholding_moves = moves.filtered("withholding_tax")
2532
if withholding_moves:
2633
currency = withholding_moves.currency_id

0 commit comments

Comments
 (0)