c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #27287
Re: [Bug 802352] Re: [6.0] Inheriting _constraints "list index out of range" if original len(_constraint ) is bigger than the new one
I try it already, just for information, i try it with my module example, and
it works, i attach before a db with several modules installed and i try all
constraints (old and new ones...)
Thanks.
2011/6/27 Jay Vora (OpenERP) <jvo@xxxxxxxxxxx>
> Hello Nhomar,
>
> Thanks for reporting and patch as well.
>
> However, I see that It will also be a trouble when _inheriting
> constraint with a combination of [OLD,NEW] comes.
>
> I am investigating more and will post a solution with test cases.
>
> Thanks.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/802352
>
> Title:
> [6.0] Inheriting _constraints "list index out of range" if original
> len(_constraint ) is bigger than the new one
>
> Status in OpenERP Server:
> In Progress
>
> Bug description:
> branch: 6.0
> addons : 4677
> server: 3452
> My module example:
> class stock_move_constraint(osv.osv):
> _inherit = 'stock.move'
> _columns = {}
> def _check_import_info(self, cr, uid, ids, context=None):
> print "I checked"
> return True
> _constraints = [
> (_check_import_info,'You must assign a track lot with import
> information for this product',['tracking_id'])],
> stock_move_constraint()
>
> When I try to update my module ($python openerp-server.py -u mymodule
> -d mydb) this traceback is received.
>
> Traceback (most recent call last):
> File "./openerp-server.py", line 121, in <module>
> db,pool = pooler.get_db_and_pool(dbname,
> update_module=tools.config['init'] or tools.config['update'],
> pooljobs=False)
> File "/home/nhomar/CD_curso/linux_and_sources/server/bin/pooler.py",
> line 39, in get_db_and_pool
> addons.load_modules(db, force_demo, status, update_module)
> File
> "/home/nhomar/CD_curso/linux_and_sources/server/bin/addons/__init__.py",
> line 883, in load_modules
> processed_modules.extend(load_module_graph(cr, graph, status,
> report=report, skip_modules=processed_modules))
> File
> "/home/nhomar/CD_curso/linux_and_sources/server/bin/addons/__init__.py",
> line 717, in load_module_graph
> modules = pool.instanciate(package.name, cr)
> File "/home/nhomar/CD_curso/linux_and_sources/server/bin/osv/osv.py",
> line 258, in instanciate
> res.append(klass.createInstance(self, module, cr))
> File "/home/nhomar/CD_curso/linux_and_sources/server/bin/osv/osv.py",
> line 354, in createInstance
> if new[c2][2]==c[2] and (new[c2][0] == c[0] \
> IndexError: list index out of range
>
> I printed variables of this method (check patch it is corrected) and
> some kind of bad logic is used, the server is trying to check as a
> list an integer....
>
> Original problem
> ~~~~LINE 348 on osv.py
>
> if s=='_constraints':
> for c in cls.__dict__.get(s, []):
> exist = False
> for c2 in range(len(new)):
> ####THIS IS MY PRINT it is an integer,,,,,
> #on the range(len(new)) always will return an index in c2 of the original
> class never, and if the original
> #_constraint list in class is bigger than the new one it will broke.
> print c2
> #For _constraints, we should check
> field and methods as well
> if new[c2][2]==c[2] and (new[c2][0]
> == c[0] \
> or
> getattr(new[c2][0],'__name__', True) == \
> getattr(c[0],'__name__',
> False)):
> # If new class defines a
> constraint with
> # same function name, we let it
> override
> # the old one.
> new[c2] = c
> exist = True
> break
> if not exist:
> new.append(c)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/openobject-server/+bug/802352/+subscriptions
>
--
Saludos Cordiales
Nhomar G. Hernandez M.
+58-414-4110269
Skype: nhomar00
Web-Blog: http://geronimo.com.ve
Servicios IT: http://openerp.com.ve
Linux-Counter: 467724
Correos:
nhomar@xxxxxxxxxxxxxx <nhomar.hernandez@xxxxxxxxxxxxx>
nhomar@xxxxxxxxxxxxxxx
twitter: @nhomar
--
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/802352
Title:
[6.0] Inheriting _constraints "list index out of range" if original
len(_constraint ) is bigger than the new one
Status in OpenERP Server:
In Progress
Bug description:
branch: 6.0
addons : 4677
server: 3452
My module example:
class stock_move_constraint(osv.osv):
_inherit = 'stock.move'
_columns = {}
def _check_import_info(self, cr, uid, ids, context=None):
print "I checked"
return True
_constraints = [
(_check_import_info,'You must assign a track lot with import information for this product',['tracking_id'])],
stock_move_constraint()
When I try to update my module ($python openerp-server.py -u mymodule
-d mydb) this traceback is received.
Traceback (most recent call last):
File "./openerp-server.py", line 121, in <module>
db,pool = pooler.get_db_and_pool(dbname, update_module=tools.config['init'] or tools.config['update'], pooljobs=False)
File "/home/nhomar/CD_curso/linux_and_sources/server/bin/pooler.py", line 39, in get_db_and_pool
addons.load_modules(db, force_demo, status, update_module)
File "/home/nhomar/CD_curso/linux_and_sources/server/bin/addons/__init__.py", line 883, in load_modules
processed_modules.extend(load_module_graph(cr, graph, status, report=report, skip_modules=processed_modules))
File "/home/nhomar/CD_curso/linux_and_sources/server/bin/addons/__init__.py", line 717, in load_module_graph
modules = pool.instanciate(package.name, cr)
File "/home/nhomar/CD_curso/linux_and_sources/server/bin/osv/osv.py", line 258, in instanciate
res.append(klass.createInstance(self, module, cr))
File "/home/nhomar/CD_curso/linux_and_sources/server/bin/osv/osv.py", line 354, in createInstance
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
IndexError: list index out of range
I printed variables of this method (check patch it is corrected) and
some kind of bad logic is used, the server is trying to check as a
list an integer....
Original problem
~~~~LINE 348 on osv.py
if s=='_constraints':
for c in cls.__dict__.get(s, []):
exist = False
for c2 in range(len(new)):
####THIS IS MY PRINT it is an integer,,,,,
#on the range(len(new)) always will return an index in c2 of the original class never, and if the original
#_constraint list in class is bigger than the new one it will broke.
print c2
#For _constraints, we should check field and methods as well
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
or getattr(new[c2][0],'__name__', True) == \
getattr(c[0],'__name__', False)):
# If new class defines a constraint with
# same function name, we let it override
# the old one.
new[c2] = c
exist = True
break
if not exist:
new.append(c)
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/802352/+subscriptions
References