Many2many 向前引用问题
-
详细错误信息:[code]
Traceback (most recent call last):
File "D:devopenerpstableserverbinnetsvc.py", line 235, in dispatch
result = LocalService(service_name)(method, *params)
File "D:devopenerpstableserverbinnetsvc.py", line 74, in call
return getattr(self, method)(*params)
File "D:devopenerpstableserverbinserviceweb_services.py", line 582, in execute
return self.execute(db, uid, wiz_id, datas, action, context)
File "D:devopenerpstableserverbinserviceweb_services.py", line 562, in execute
return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
File "D:devopenerpstableserverbinwizard__init.py", line 178, in execute
res = self.execute_cr(cr, uid, data, state, context)
File "D:devopenerpstableserverbinwizard__init__.py", line 74, in execute_cr
action_res = action(self, cr, uid, data, context)
File "D:devopenerpstableserverbinaddonsbasemodulewizardwizard_module_upgrade.py", line 92, in upgrade_module
db, pool = pooler.restart_pool(cr.dbname, update_module=True)
File "D:devopenerpstableserverbinpooler.py", line 62, in restart_pool
return get_db_and_pool(db_name, force_demo, status, update_module=update_module)
File "D:devopenerpstableserverbinpooler.py", line 40, in get_db_and_pool
addons.load_modules(db, force_demo, status, update_module)
File "D:devopenerpstableserverbinaddons__init_.py", line 718, in load_modules
r = load_module_graph(cr, graph, status, report=report)
File "D:devopenerpstableserverbinaddons__init__.py", line 581, in load_module_graph
init_module_objects(cr, package.name, modules)
File "D:devopenerpstableserverbinaddons__init__.py", line 366, in init_module_objects
result = obj._auto_init(cr, {'module': module_name})
File "D:devopenerpstableserverbinosvorm.py", line 1532, in _auto_init
cr.execute('CREATE TABLE "%s" ("%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE, "%s" INTEGER NOT NULL REFERENCES "%s" ON DELETE CASCADE) WITH OIDS' % (f._rel, f._id1, self._table, f._id2, ref))
File "D:devopenerpstableserverbinsql_db.py", line 76, in wrapper
return f(self, *args, **kwargs)
File "D:devopenerpstableserverbinsql_db.py", line 120, in execute
res = self._obj.execute(query, params)
ProgrammingError: relation "transit_vehicle" does not exist[/code]
-
这个错误应该是因为transit.vehicle对象还没有被初始化就被调用了。把vehicle类放到driver类之前试试?
另外,_inherits在这里用来表示一对一关系的,可是name,active字段与父类重复,应该也会有问题的。
-
哦,想简单了。
假设driver类在前,vehicle类在后。 在driver类中先不声明对vehicle的many2many引用,而在vehicle类之后再创建对driver的继承类并添加many2many field. 看看这样是不是可以? -
res.user和res.roles对应的表是在服务器初始化的时候由base.sql 创建好的,所以没有初始化的先后关系的问题。
-
oldrev, 你的代码现在调试通过了吗?我想跟踪一下,我也在官方论坛里问一下有没有更好的办法。