@@ -12,6 +12,12 @@ class AccountMove(models.Model):
12
12
compute = "_compute_currency_rate_amount" ,
13
13
digits = 0 ,
14
14
)
15
+ company_currency_rate_amount = fields .Float (
16
+ string = "Rate Amount" ,
17
+ compute = "_compute_currency_rate_amount" ,
18
+ digits = 0 ,
19
+ )
20
+ currency_rate_display = fields .Selection (related = "company_id.currency_rate_display" )
15
21
show_currency_rate_amount = fields .Boolean (
16
22
compute = "_compute_show_currency_rate_amount" , readonly = True
17
23
)
@@ -32,6 +38,7 @@ def _compute_currency_rate_amount(self):
32
38
- Case C: Get expected rate (according to date) to show some value in creation.
33
39
"""
34
40
self .currency_rate_amount = 1
41
+ self .company_currency_rate_amount = 1
35
42
for item in self .filtered ("show_currency_rate_amount" ):
36
43
lines = item .line_ids .filtered (lambda x : abs (x .amount_currency ) > 0 )
37
44
if item .state == "posted" and lines :
@@ -42,9 +49,15 @@ def _compute_currency_rate_amount(self):
42
49
item .currency_rate_amount = (
43
50
amount_currency_positive / total_balance_positive
44
51
)
52
+ item .company_currency_rate_amount = (
53
+ total_balance_positive / amount_currency_positive
54
+ )
45
55
else :
46
56
rates = item .currency_id ._get_rates (item .company_id , item .date )
47
57
item .currency_rate_amount = rates .get (item .currency_id .id )
58
+ item .company_currency_rate_amount = item .currency_id ._convert (
59
+ 1.0 , item .company_id .currency_id , item .company_id , item .date
60
+ )
48
61
49
62
@api .depends ("currency_id" , "currency_id.rate_ids" , "company_id" )
50
63
def _compute_show_currency_rate_amount (self ):
@@ -57,6 +70,41 @@ def _compute_show_currency_rate_amount(self):
57
70
class AccountMoveLine (models .Model ):
58
71
_inherit = "account.move.line"
59
72
73
+ company_currency_rate_amount = fields .Float (
74
+ string = "Rate Amount" ,
75
+ compute = "_compute_company_currency_rate_amount" ,
76
+ digits = 0 ,
77
+ )
78
+ currency_rate_display = fields .Selection (related = "company_id.currency_rate_display" )
79
+
80
+ @api .depends (
81
+ "currency_id" ,
82
+ "move_id.company_id" ,
83
+ "move_id.date" ,
84
+ "move_id.state" ,
85
+ "amount_currency" ,
86
+ "balance" ,
87
+ )
88
+ def _compute_company_currency_rate_amount (self ):
89
+ for line in self :
90
+ line .currency_rate = 1
91
+ if line .currency_id :
92
+ if line .move_id .state != "posted" or not line .amount_currency :
93
+ line .company_currency_rate_amount = line .currency_id ._convert (
94
+ 1.0 ,
95
+ line .company_id .currency_id ,
96
+ line .company_id ,
97
+ date = line .move_id .invoice_date
98
+ or line .move_id .date
99
+ or fields .Date .context_today (line ),
100
+ )
101
+ else :
102
+ line .company_currency_rate_amount = (
103
+ abs (line .balance ) / abs (line .amount_currency )
104
+ if line .amount_currency
105
+ else 0
106
+ )
107
+
60
108
@api .depends (
61
109
"currency_id" ,
62
110
"move_id.company_id" ,
0 commit comments