[FIX] account_account allow write if company_id has the same value
authorAntony Lesuisse <al@openerp.com>
Fri, 14 Jan 2011 15:01:06 +0000 (16:01 +0100)
committerAntony Lesuisse <al@openerp.com>
Fri, 14 Jan 2011 15:01:06 +0000 (16:01 +0100)
lp bug: https://launchpad.net/bugs/702329 fixed

bzr revid: al@openerp.com-20110114150106-i533hpid59k0rxl3

addons/account/account.py

index 8942870..166d475 100644 (file)
@@ -536,10 +536,14 @@ class account_account(osv.osv):
         if context is None:
             context = {}
 
+        # Dont allow changing the company_id when account_move_line already exist
         if 'company_id' in vals:
             move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)])
             if move_lines:
-                raise osv.except_osv(_('Warning !'), _('You cannot modify Company of account as its related record exist in Entry Lines'))
+                # Allow the write if the value is the same
+                for i in [i['company_id'][0] for i in self.read(cr,uid,ids,['company_id'])]:
+                    if vals['company_id']!=i:
+                        raise osv.except_osv(_('Warning !'), _('You cannot modify Company of account as its related record exist in Entry Lines'))
         if 'active' in vals and not vals['active']:
             self._check_moves(cr, uid, ids, "write", context=context)
         if 'type' in vals.keys():