如何解决res_partner列.在Odoo中不存在? [英] How to solve column res_partner.<column> does not exist in Odoo?
问题描述
例如,模型中很好地添加了"reonp",但是当我尝试添加"gradjanin"时,Odoo 10会引发错误
As an example, 'reonp' is a nicely added in model, but when I tried to add a 'gradjanin', Odoo 10 raise an error
我正在尝试重新启动服务器
I was trying to restart the server
py
class komPartnerrReon(models.Model):
_inherit = 'res.partner'
reonp = fields.Many2one('kom.reon')
gradjanin = fields.Boolean('Gradjanin', default=False) #There was an error after adding this line of code
错误
File "C:\odoo-10.0\odoo\sql_db.py", line 231, in execute
res = self._obj.execute(query, params)
ProgrammingError: column res_partner.gradjanin does not exist
LINE 1: ...id" as "parent_id","res_partner"."name" as "name","res_partn...
推荐答案
这实际上是在使用新字段扩展模型res.partner
时遇到的经典错误.
That's actually the classic error you get on extending model res.partner
with new fields.
在启动Odoo服务器时,每个模块的python文件都会被加载",因此您当然也要在res.partner
上添加新字段.但这仅在python方面,或者在应用程序本身上更好.现在,尝试使用该应用程序或在Odoo的webclient中加载某些内容"将尝试从数据库中加载数据,而新字段没有相应的列.
On starting the Odoo server, every modules python files will be "loaded" so ofcourse your new fields on res.partner
, too. But that's only on python side or better on the application itself. Now trying to use the application or "loading something in Odoo's webclient" will then try to load data from database, where the new fields don't have the corresponding columns.
例如登录名.登录时,Odoo将加载正在登录的用户.Model res.users
继承了整个模型res.partner
,因此Odoo试图从数据库中加载res.partner
数据.并增加错误.
For example the login. On login Odoo will load the user, which is logging in. Model res.users
inherits the whole model res.partner
, so that Odoo is trying to load res.partner
data from database. And boom the error.
如果已经登录,它也可能发生.例如,在具有震颤的模型的公式视图中.聊天者会加载跟随者,而跟随者是伙伴,因此可以增加错误.
It can also happen if already logged in. For example in a formular view of a model with chatter. The chatter loads followers, which are partners, so boom the error.
该如何解决?
在服务器启动时更新模块
具有参数-u
(并且如果系统中有多个数据库具有-d
)
with parameter -u
(and if more than one database in the system with -d
)
odoo -c <path_to_config> -u my_module -d my_database
如果不可能,
例如在生产系统中或由于Odoo作为服务启动,请尝试启动第二个实例,该实例将仅更新模块并在此之后立即停止.
for example in productive systems or because Odoo is started as service, try to start a second instance which will just update the module and stop after that immediately.
odoo -c <path_to_config> -u my_module -d my_database --max-cron-threads=0 --stop-after-init --no-xmlrpc
这就像一个自我毁灭"的无头Odoo实例.在Odoo V11 +中,参数--no-xmlrpc
将为--no-http
.
That's like a "self-destroying" headless Odoo instance. The parameter --no-xmlrpc
will be --no-http
in Odoo V11+.
在数据库中告诉Odoo以更新模块/应用.
UPDATE ir_module_module set state = 'to upgrade' where name = 'my_module';
之后,只需重新启动Odoo.
After that just restart Odoo.
还是棘手的方式:
只需进入应用程序"菜单并打开您的模块/应用程序.重新启动Odoo并更新模块/应用程序.这是最快的方法,但是您猜到了,有时您会忘记这样做.而且只有在收到错误之前它才有效;-)
Just go into the Apps menu and open your module/app. Restart Odoo and update the module/app. That's the fastest way, but you guess it, you will sometimes forget to do it. And it's only working before you get the error ;-)
这篇关于如何解决res_partner列.在Odoo中不存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!