在odoo中,高级视图编辑器在保存文件

时间:2016-04-25 20:28:50

标签: openerp odoo-8

我在odoo中自定义默认模板时犯了一个错误。 该错误位于电子商务模块的类别列表中。 保存更改后,Odoo在UI上报告错误并建议回滚。从那以后,odoo网站根本不起作用。

在哪里可以找到服务器上修改过的文件以更改丢弃我的更改? 这是我的日志跟踪...这没有多大帮助!

2016-04-25 19:41:13,773 1505 ERROR fa_prod werkzeug: Error on request:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/opt/openerp/odoo/openerp/service/server.py", line 290, in app
    return self.app(e, s)
  File "/opt/openerp/odoo/openerp/service/wsgi_server.py", line 214, in application
    return werkzeug.contrib.fixers.ProxyFix(application_unproxied)(environ, start_response)
  File "/usr/lib/python2.7/dist-packages/werkzeug/contrib/fixers.py", line 144, in __call__
    return self.app(environ, start_response)
  File "/opt/openerp/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
    result = handler(environ, start_response)
  File "/opt/openerp/odoo/openerp/http.py", line 1290, in __call__
    return self.dispatch(environ, start_response)
  File "/opt/openerp/odoo/openerp/http.py", line 1264, in __call__
    return self.app(environ, start_wrapped)
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__
    return self.app(environ, start_response)
  File "/opt/openerp/odoo/openerp/http.py", line 1428, in dispatch
    ir_http = request.registry['ir.http']
  File "/opt/openerp/odoo/openerp/http.py", line 346, in registry
    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
  File "/opt/openerp/odoo/openerp/modules/registry.py", line 339, in get
    update_module)
  File "/opt/openerp/odoo/openerp/modules/registry.py", line 370, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/opt/openerp/odoo/openerp/modules/loading.py", line 351, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/opt/openerp/odoo/openerp/modules/loading.py", line 255, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/opt/openerp/odoo/openerp/modules/loading.py", line 157, in load_module_graph
    init_module_models(cr, package.name, models)
  File "/opt/openerp/odoo/openerp/modules/module.py", line 293, in init_module_models
    obj._auto_end(cr, {'module': module_name})
  File "/opt/openerp/odoo/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/opt/openerp/odoo/openerp/models.py", line 2710, in _auto_end
    cr.execute('ALTER TABLE "%s" ADD FOREIGN KEY ("%s") REFERENCES "%s" ON DELETE %s' % (t, k, r, d))
  File "/opt/openerp/odoo/openerp/sql_db.py", line 158, in wrapper
    return f(self, *args, **kwargs)
  File "/opt/openerp/odoo/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
ProgrammingError: there is no primary key for referenced table "res_users"

3 个答案:

答案 0 :(得分:2)

Odoo在回滚模板时损坏了数据库。 大多数表都丢失了主键。

为了重新设置它们,我在一个工作实例上执行了以下代码来获取主键列表:

select tc.table_schema, tc.table_name, kc.column_name, kc.constraint_name
from  
    information_schema.table_constraints tc,  
    information_schema.key_column_usage kc  
where 
    tc.constraint_type = 'PRIMARY KEY' 
    and kc.table_name = tc.table_name and kc.table_schema = tc.table_schema
    and kc.constraint_name = tc.constraint_name
order by 1, 2;

然后我从损坏的数据库中导出了故事列表:

select table_name from information_schema.tables;

我在excel中对此进行了匹配,并构建了一个要执行的查询列表,以便再次获取主键:

="ALTER TABLE "&B15&" ADD PRIMARY KEY ("&C15&");"`enter code here`

其中B是包含表的列,C是包含主键字段名称的C. 这给出了很多SQL查询,如下所示:

ALTER TABLE product_template ADD PRIMARY KEY (id);
ALTER TABLE product_ul ADD PRIMARY KEY (id);
ALTER TABLE product_uom ADD PRIMARY KEY (id);
ALTER TABLE product_uom_categ ADD PRIMARY KEY (id);
...

我们可以直接在DB上执行此操作。我重新启动了Odoo并瞧瞧。

答案 1 :(得分:1)

在我看来,你确实在res_users表中犯了一个错误。 也许在这个链接上你可以重新获得它,如果你有备份:localhost:8069 / web / database / manager
另一种方法是,您可以使用localhost:5432上的postgresql manager访问数据库。

程序源代码在addons / module_name字典中。

我希望这对你有用。

答案 2 :(得分:0)

ALTER TABLE res_users ADD PRIMARY KEY (id);

我遇到了同样的问题,我用一种简单的方法解决了它