gpt4 book ai didi

python - ODOO12 : not creating db column?

转载 作者:行者123 更新时间:2023-11-29 13:38:23 25 4
gpt4 key购买 nike

我在使用 ODOO 12 时遇到问题,我正在声明一个文本字段,而它根本不是由 ODOO 创建的,我已经启用了 --log-level debug_sql,并且在创建时它只是跳过了该字段而没有给我任何错误...

我的代码:

class Processo(models.Model): 

_name = 'processo'
_description = 'Processo'


name = fields.Char(string='Número do processo', readonly=True)

status = fields.Selection(selection=[
('tec','Análise Técnica'),
('tecsup','Análise Técnica Superior'),
('pendencia','Pendência'),
('indeferido','Indeferido'),
('concluido','Concluído')],
string='Estados',
default='tec')

is_tecsup = fields.Boolean( string='É análise superior?')

requerente_id = fields.Many2one( string='Requerente', comodel_name='res.partner', readonly=True)​

requerente_user_id = fields.Many2one( string='Requerente', comodel_name='res.users', readonly=True)

documentos_ids = fields.One2many(string='Documentos', comodel_name='documentos.protocolos', inverse_name='processo_id')

protocolo_ids = fields.One2many( comodel_name='protocolo', inverse_name='processo_id', string='Protocolos')

protocolo_id = fields.Many2one( comodel_name='protocolo', string='Protocolo')

data_aprovacao = fields.Date(string="Data do alvará")

historico = fields.Text( string="Histórico")

pendencia_processo = fields.Text(string="TEST")​

pendencia = fields.Text(string="Pendencia") # <= field problem

这是创建时的日志:

2019-11-27 13:28:32,156 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "name" VARCHAR 2019-11-27 13:28:32,182 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."name" IS 'Número do processo' 2019-11-27 13:28:32,182 24061 DEBUG teste_all odoo.sql_db: query: SELECT 1 FROM "processo" LIMIT 1 2019-11-27 13:28:32,183 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_name_index" 2019-11-27 13:28:32,183 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "status" VARCHAR 2019-11-27 13:28:32,184 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."status" IS 'Estados' 2019-11-27 13:28:32,184 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_status_index" 2019-11-27 13:28:32,184 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "is_tecsup" bool 2019-11-27 13:28:32,185 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."is_tecsup" IS 'É análise superior?' 2019-11-27 13:28:32,185 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_is_tecsup_index" 2019-11-27 13:28:32,186 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "requerente_id" int4 2019-11-27 13:28:32,186 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."requerente_id" IS 'Requerente' 2019-11-27 13:28:32,187 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_requerente_id_index" 2019-11-27 13:28:32,187 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "requerente_user_id" int4 2019-11-27 13:28:32,187 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."requerente_user_id" IS 'Requerente' 2019-11-27 13:28:32,188 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_requerente_user_id_index" 2019-11-27 13:28:32,188 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "protocolo_id" int4 2019-11-27 13:28:32,189 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."protocolo_id" IS 'Protocolo' 2019-11-27 13:28:32,189 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_protocolo_id_index" 2019-11-27 13:28:32,191 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "data_aprovacao" date 2019-11-27 13:28:32,191 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."data_aprovacao" IS 'Data do alvará' 2019-11-27 13:28:32,191 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_data_aprovacao_index" 2019-11-27 13:28:32,191 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "historico" text 2019-11-27 13:28:32,192 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."historico" IS 'Histórico' 2019-11-27 13:28:32,192 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_historico_index" 2019-11-27 13:28:32,192 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "pendencia_processo" text 2019-11-27 13:28:32,192 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."pendencia_processo" IS 'TEST' 2019-11-27 13:28:32,193 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_pendencia_processo_index" 2019-11-27 13:28:32,193 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "autorizador_id" int4 2019-11-27 13:28:32,193 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."autorizador_id" IS 'Autorizador' 2019-11-27 13:28:32,193 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_autorizador_id_index" 2019-11-27 13:28:32,194 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "create_uid" int4 2019-11-27 13:28:32,194 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."create_uid" IS 'Created by' 2019-11-27 13:28:32,194 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_create_uid_index" 2019-11-27 13:28:32,194 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "create_date" timestamp 2019-11-27 13:28:32,194 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."create_date" IS 'Created on' 2019-11-27 13:28:32,195 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_create_date_index" 2019-11-27 13:28:32,195 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "write_uid" int4 2019-11-27 13:28:32,195 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."write_uid" IS 'Last Updated by' 2019-11-27 13:28:32,195 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_write_uid_index" 2019-11-27 13:28:32,196 24061 DEBUG teste_all odoo.sql_db: query: ALTER TABLE "processo" ADD COLUMN "write_date" timestamp 2019-11-27 13:28:32,196 24061 DEBUG teste_all odoo.sql_db: query: COMMENT ON COLUMN "processo"."write_date" IS 'Last Updated on' 2019-11-27 13:28:32,196 24061 DEBUG teste_all odoo.sql_db: query: DROP INDEX IF EXISTS "processo_write_date_index"118/5000

简单地跳过字段“pendencia”的创建而不给我任何错误......有谁知道为什么?

最佳答案

我假设您的 Odoo 没有看到与您正在修改的文件相同的版本。在调试日志中,您在“Pendencia processo”之后有字段“Autorizador”,而不是源代码中的“Pendencia”。

通过重新安装并重启 Odoo 服务器,确保 Odoo 加载最新版本的模块。

同时检查您是否只有一个版本的文件并且 Odoo 正在使用它。您可以使用代码中的调试语句进行检查,如下所示:

import logging
_logger = logging.getLogger(__name__)

class Processo(models.Model):

_name = 'processo'
_description = 'Processo'

_logger.debug("Your code was executed. ")
#...rest of your code here.

关于python - ODOO12 : not creating db column?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59071958/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com