Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
3 Ответы
7087 Представления

Hi,

I have added a custom field to my already installed module:

class Users(models.Model):
     _inherit = 'res.users'
    authentication_token = fields.Char()

When I call "odoo -u my_module -d databasename" the fields are not created in the database, so I need to go to "Apps" and click on "Upgrade" then the field is created automatically.

Is this the normal behavior? How to deploy new versions automatically?


Аватар
Отменить

Please check the following link for custom module:

https://youtu.be/Xya_fCNr6tw

Thanks & Regards

Лучший ответ

I faced the same issue. I fixed it by just restarting the odoo server (my case is docker container)

Аватар
Отменить
Автор Лучший ответ

No it doesn't work. Tried with different servers. -d database -u module, doesn't upgrade module. I need to run manually.

I have created a cli option to upgrade modules from command line. Can upgrade or install a module with 'odoo upgrade -u module1 -u module1' adding this to a module:

# -*- coding: UTF-7 -*-
from __future__ import unicode_literals
from odoo.cli.command import Command
import odoo
from odoo.tools import config
from odoo import models, fields, api, modules
import argparse
import logging

_logger = logging.getLogger(__name__)

class Upgrade(Command):
def init(self, args):
config.parse_config(args)
odoo.cli.server.report_configuration()
odoo.service.server.start(preload=[], stop=True)

"""Upgrade modules"""
def run(self, args):
self.init(args)
dbname=config['db_name']
parser = argparse.ArgumentParser()
parser.add_argument("-u", action='append')
(args2, unknown) = parser.parse_known_args(args)

with odoo.api.Environment.manage():
registry = odoo.registry(dbname)
with registry.cursor() as cr:
uid = odoo.SUPERUSER_ID
ctx = odoo.api.Environment(cr, uid, {})['res.users'].context_get()
env = odoo.api.Environment(cr, uid, ctx)

try:
# This is done because the installation/uninstallation/upgrade can modify a currently # running cron job and prevent it from finishing, and since the ir_cron table is locked
# during execution, the lock won't be released until timeout.
cr.execute("SELECT * FROM ir_cron FOR UPDATE NOWAIT")
except psycopg2.OperationalError:
raise UserError(_("The server is busy right now, module operations are not possible at"
" this time, please try again later."))

ir_module = env['ir.module.module']

for module_name in args2.u:
module = ir_module.search([('name', '=', module_name)])
if module.state not in ('installed', 'to upgrade'):
module.button_install()
else:
module.button_upgrade()
cr.commit()
api.Environment.reset()
modules.registry.Registry.new(cr.dbname, update_module=True)

cr.commit()
Аватар
Отменить
Лучший ответ

Specify also the database name:

-d [ODOO_POSTGRESQL_DATABASE] -u my_module

E.g.  -d my_company -u my_module

Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
янв. 16
4337
3
июл. 25
1853
3
мая 25
3292
1
мая 24
2303
2
июн. 25
3877