diff --git a/account_statement_import_file/models/__init__.py b/account_statement_import_file/models/__init__.py index 16a78ca32..acfd73d6d 100644 --- a/account_statement_import_file/models/__init__.py +++ b/account_statement_import_file/models/__init__.py @@ -1,2 +1,3 @@ from . import account_journal +from . import account_move from . import account_bank_statement_line diff --git a/account_statement_import_file/models/account_move.py b/account_statement_import_file/models/account_move.py new file mode 100644 index 000000000..bbb36d786 --- /dev/null +++ b/account_statement_import_file/models/account_move.py @@ -0,0 +1,24 @@ +from odoo import api, models + + +class AccountMove(models.Model): + _inherit = "account.move" + + @api.depends("journal_id", "statement_line_id") + def _compute_currency_id(self): + res = super()._compute_currency_id() + if self.env.context.get("from_stmt_import", False): + for invoice in self: + if ( + invoice.statement_line_id.foreign_currency_id + and invoice.statement_line_id.foreign_currency_id + == invoice.journal_id.company_id.currency_id + ): + currency = ( + invoice.journal_id.currency_id + or invoice.statement_line_id.foreign_currency_id + or invoice.currency_id + or invoice.journal_id.company_id.currency_id + ) + invoice.currency_id = currency + return res