c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #28888
[Bug 812723] Re: passing ids as integer to account.account write method throws KeyError: "Field '0' does not exist in object 'browse_record'...
** Branch linked: lp:~openerp-dev/openobject-addons/trunk-bug-812723-bde
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/812723
Title:
passing ids as integer to account.account write method throws
KeyError: "Field '0' does not exist in object 'browse_record'...
Status in OpenERP Modules (addons):
Fix Committed
Bug description:
If "ids" is passed to write as integer instead of a list you get this:
Traceback (most recent call last):
File "/home/simahawk/dev/openobject/stable/server/bin/osv/osv.py", line 122, in wrapper
return f(self, dbname, *args, **kwargs)
File "/home/simahawk/dev/openobject/stable/server/bin/osv/osv.py", line 176, in execute
res = self.execute_cr(cr, uid, obj, method, *args, **kw)
File "/home/simahawk/dev/openobject/stable/server/bin/osv/osv.py", line 167, in execute_cr
return getattr(object, method)(cr, uid, *args, **kw)
File "/home/simahawk/dev/openobject/stable/server/bin/addons/account/account.py", line 552, in write
self._check_allow_type_change(cr, uid, ids, vals['type'], context=context)
File "/home/simahawk/dev/openobject/stable/server/bin/addons/account/account.py", line 525, in _check_allow_type_change
for account in self.browse(cr, uid, ids, context=context):
File "/home/simahawk/dev/openobject/stable/server/bin/osv/orm.py", line 189, in __getitem__
name, self))
KeyError: "Field '0' does not exist in object 'browse_record(account.account, 33)'"
as you can see the error occurs into _check_allow_type_change whereas
at line 523 [1]:
for account in self.browse(cr, uid, ids, context=context):
the problem can be easily solved using:
if not isinstance(ids,list):
ids = [ids,]
for account in self.browse(cr, uid, ids, context=context):
The weird thing is that also at line 544 [2] we have:
if 'company_id' in vals:
move_lines = self.pool.get('account.move.line').search(cr, uid, [('account_id', 'in', ids)])
if move_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'])]:
beside the horrible nested for.... this *is going to fail* whenever
ids is not a list.
I supposed you've been lucky till here because probably when
'company_id' is in vals you have always a list...
This bug is similar to https://bugs.launchpad.net/openobject-addons/+bug/740202
[1] http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/view/head:/account/account.py#L523
[2] http://bazaar.launchpad.net/~openerp/openobject-addons/6.0/view/head:/account/account.py#L544
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-addons/+bug/812723/+subscriptions
References