diff --git a/addons/account/models/account_move.py b/addons/account/models/account_move.py index dec90a77767..95aa23f2b84 100644 --- a/addons/account/models/account_move.py +++ b/addons/account/models/account_move.py @@ -332,7 +332,7 @@ class AccountMove(models.Model): company_currency = self.company_id.currency_id has_foreign_currency = self.currency_id and self.currency_id != company_currency - for line in self.line_ids: + for line in self._get_lines_onchange_currency(): new_currency = has_foreign_currency and self.currency_id line.currency_id = new_currency @@ -886,6 +886,10 @@ class AccountMove(models.Model): if invoice != invoice._origin: invoice.invoice_line_ids = invoice.line_ids.filtered(lambda line: not line.exclude_from_invoice_tab) + def _get_lines_onchange_currency(self): + # Override needed for COGS + return self.line_ids + def onchange(self, values, field_name, field_onchange): # OVERRIDE # As the dynamic lines in this model are quite complex, we need to ensure some computations are done exactly diff --git a/addons/stock_account/models/account_move.py b/addons/stock_account/models/account_move.py index 8766f747861..a4ce69ed661 100644 --- a/addons/stock_account/models/account_move.py +++ b/addons/stock_account/models/account_move.py @@ -13,6 +13,10 @@ class AccountMove(models.Model): # OVERRIDE METHODS # ------------------------------------------------------------------------- + def _get_lines_onchange_currency(self): + # OVERRIDE + return self.line_ids.filtered(lambda l: not l.is_anglo_saxon_line) + def _reverse_move_vals(self, default_values, cancel=True): # OVERRIDE # Don't keep anglo-saxon lines if not cancelling an existing invoice.