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
error
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...
That's actually the classic error you get on extending model res.partner
with new fields.
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.
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.
What can you do, to fix that?
Update the module on server start
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
If that's not possible,
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
That's like a "self-destroying" headless Odoo instance. The parameter --no-xmlrpc
will be --no-http
in Odoo V11+.
Tell Odoo in the database to update a module/app.
UPDATE ir_module_module set state = 'to upgrade' where name = 'my_module';
After that just restart Odoo.
Or the tricky way:
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 ;-)