File tree 1 file changed +7
-4
lines changed
account_invoice_show_currency_rate/models
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class AccountMove(models.Model):
20
20
"state" ,
21
21
"date" ,
22
22
"line_ids.amount_currency" ,
23
+ "line_ids.balance" ,
23
24
"company_id" ,
24
25
"currency_id" ,
25
26
"show_currency_rate_amount" ,
@@ -32,12 +33,14 @@ def _compute_currency_rate_amount(self):
32
33
"""
33
34
self .currency_rate_amount = 1
34
35
for item in self .filtered ("show_currency_rate_amount" ):
35
- lines = item .line_ids .filtered (lambda x : x .amount_currency > 0 )
36
+ lines = item .line_ids .filtered (lambda x : abs ( x .amount_currency ) > 0 )
36
37
if item .state == "posted" and lines :
37
- amount_currency_positive = sum (lines .mapped ("amount_currency" ))
38
- total_debit = sum (lines .mapped ("debit" ))
38
+ amount_currency_positive = sum (
39
+ [abs (amc ) for amc in lines .mapped ("amount_currency" )]
40
+ )
41
+ total_balance_positive = sum ([abs (b ) for b in lines .mapped ("balance" )])
39
42
item .currency_rate_amount = item .currency_id .round (
40
- amount_currency_positive / total_debit
43
+ amount_currency_positive / total_balance_positive
41
44
)
42
45
else :
43
46
rates = item .currency_id ._get_rates (item .company_id , item .date )
You can’t perform that action at this time.
0 commit comments