From 45f1b5ac6cbfddd4ac6363640304e35469842b75 Mon Sep 17 00:00:00 2001 From: Antony Lesuisse Date: Fri, 14 Jan 2011 16:01:06 +0100 Subject: [PATCH] [FIX] account_account allow write if company_id has the same value lp bug: https://launchpad.net/bugs/702329 fixed bzr revid: al@openerp.com-20110114150106-i533hpid59k0rxl3 --- addons/account/account.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/account/account.py b/addons/account/account.py index 894287056c1..166d475fcba 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -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():