From 239f4fec29c0b856c14b02e318c615c41bab5868 Mon Sep 17 00:00:00 2001 From: Olivier Colson Date: Wed, 28 Feb 2018 11:39:05 +0100 Subject: [PATCH] [FIX] account: When modifying the currency or company of a bank journal, also set it on the related res.partner.bank (if set) See issue https://github.com/odoo/odoo/issues/22980 --- addons/account/models/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index d8932b5175a..ef611962da9 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -100,7 +100,7 @@ class AccountAccount(models.Model): help="Forces all moves for this account to have this account currency.") code = fields.Char(size=64, required=True, index=True) deprecated = fields.Boolean(index=True, default=False) - user_type_id = fields.Many2one('account.account.type', string='Type', required=True, oldname="user_type", + user_type_id = fields.Many2one('account.account.type', string='Type', required=True, oldname="user_type", help="Account Type is used for information purpose, to generate country-specific legal reports, and set the rules to close a fiscal year and generate opening entries.") internal_type = fields.Selection(related='user_type_id.type', store=True, readonly=True) #has_unreconciled_entries = fields.Boolean(compute='_compute_has_unreconciled_entries', @@ -323,6 +323,8 @@ class AccountJournal(models.Model): if ('company_id' in vals and journal.company_id.id != vals['company_id']): if self.env['account.move'].search([('journal_id', 'in', self.ids)], limit=1): raise UserError(_('This journal already contains items, therefore you cannot modify its company.')) + if self.bank_account_id: + self.bank_account_id.company_id = vals['company_id'] if ('code' in vals and journal.code != vals['code']): if self.env['account.move'].search([('journal_id', 'in', self.ids)], limit=1): raise UserError(_('This journal already contains items, therefore you cannot modify its short name.')) @@ -336,6 +338,8 @@ class AccountJournal(models.Model): self.default_debit_account_id.currency_id = vals['currency_id'] if not 'default_credit_account_id' in vals and self.default_credit_account_id: self.default_credit_account_id.currency_id = vals['currency_id'] + if self.bank_account_id: + self.bank_account_id.currency_id = vals['currency_id'] if 'bank_acc_number' in vals and not vals.get('bank_acc_number') and journal.bank_account_id: raise UserError(_('You cannot empty the account number once set.\nIf you would like to delete the account number, you can do it from the Bank Accounts list.')) result = super(AccountJournal, self).write(vals)