@@ -11,16 +11,23 @@ class AccountPaymentRegister(models.TransientModel):
11
11
@api .model
12
12
def _get_wizard_values_from_batch (self , batch_result ):
13
13
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
+ )
15
17
return wizard_values_from_batch
16
18
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
+ ):
18
22
"""If the payment is for Invoices having Withholding Taxes,
19
23
set the Residual Net To Pay as the amount to be paid.
20
24
"""
21
25
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 )
24
31
withholding_moves = moves .filtered ("withholding_tax" )
25
32
if withholding_moves :
26
33
currency = withholding_moves .currency_id
0 commit comments