Skip to content

Commit 3e3a838

Browse files
hugho-adluistorresm
authored andcommitted
[REF] account_invoice_change_currency: Fixed get rate at first currency
convertion. Before this commit, was returned the same currency that the invoice on the onchange context, now is returned the currency recorded at the messages with tracking values.
1 parent 5034505 commit 3e3a838

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

account_invoice_change_currency/models/account_change_currency.py

+5
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ def get_last_currency_id(self, skip_update_currency=False):
135135
@api.multi
136136
def get_last_rate(self):
137137
self.ensure_one()
138+
subtype_create_id = self.env.ref('account.mt_invoice_created')
138139
last_values = self.env['mail.tracking.value'].sudo().search([
139140
('mail_message_id', 'in', self.message_ids.ids),
140141
('field', 'in', ['rate', 'currency_id']),
@@ -146,6 +147,10 @@ def get_last_rate(self):
146147
key=lambda r: r.field)
147148
return (self.currency_id.browse(currency_value.old_value_integer),
148149
rate_value.old_value_float)
150+
if (len(last_values) == 1 and last_values.mail_message_id.subtype_id ==
151+
subtype_create_id):
152+
return (self.currency_id.browse(last_values.new_value_integer),
153+
None)
149154
return self.currency_id.browse(None), None
150155

151156
@api.multi

0 commit comments

Comments
 (0)