Skip to content

Commit

Permalink
Merge pull request #199 from kmee/8.0-fix-loading-accounts-from-CSV
Browse files Browse the repository at this point in the history
Allow reloading account.account from CSV files
  • Loading branch information
mileo authored Apr 7, 2017
2 parents b4b1dbe + 845bb81 commit 917a3b8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions l10n_br_account/models/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 917a3b8

Please sign in to comment.