diff --git a/l10n_br_account/models/account.py b/l10n_br_account/models/account.py index eb10ffbb49b8..b5c59cc320f3 100644 --- a/l10n_br_account/models/account.py +++ b/l10n_br_account/models/account.py @@ -180,6 +180,25 @@ def execute(self, cr, uid, ids, context=None): class AccountAccount(models.Model): _inherit = 'account.account' + _checked_fields = {'company_id', 'active', 'type', 'code'} + + @api.multi + def write(self, vals): + """ + Hack to implement the PR below until it's approved: + https://github.com/odoo/odoo/pull/16188 + + Allows reload of accounts from CSV files. + """ + vals = dict(vals) + checked_fields = self._checked_fields.intersection(vals) + records = self.read(fields=checked_fields) + for field in checked_fields: + if {record[field] for record in records} == {vals[field]}: + # don't try to write unchanged fields. + del vals[field] + return super(AccountAccount, self).write(vals) + @api.v7 def _check_allow_type_change(self, cr, uid, ids, new_type, context=None): """Hack to allow re-shaping demo chart of account in demo mode"""