dodo升级13
Postgresql 常用操作
dodo数据库升级步骤
dodo13全模块升级
Ubuntu挂载硬盘
dodo13 测试问题记录
自定义功能
注册系统服务
13新功能
13源码修改
z
重置 JetBrains 试用时间
runbot环境
odoo相关网站
dodo随手记录
odoo接口安全
dodo单点登录
单点登录说明
接口说明
单点登录时序图
odoo安全
odoo安全性政策
odoo安全披露政策
GPT
2023062901_dodo临时生成文件并下载
本文档使用 MrDoc 发布
-
+
首页
dodo数据库升级步骤
``` git clone http://192.168.15.141:3000/github/OpenUpgrade.git ``` ### 9->10升级 - python>=2.7 ``` pip install git+git://github.com/OCA/openupgradelib.git checkout 10.0 python odoo-bin -d dodo201103 --update all --stop-after-init --data-dir=/tmp/mm -c server.conf ``` #### 报错a1 ``` 2020-11-03 08:57:44,550 3396 INFO dodo201103 odoo.sql_db: bad query: INSERT INTO "ir_model_data" ("id", "noupdate", "name", "res_id", "date_update", "module", "model", "date_init", "create_uid", "write_uid", "create_date", "write_date") VALUES(nextval('ir_model_data_id_seq'), true, 'project_time_mode_id_duplicate_xmlid', 20143, '2020-11-03 08:57:44', 'project', 'ir.model.fields', '2020-11-03 08:57:44', 1, 1, (now() at time zone 'UTC'), (now() at time zone 'UTC')) RETURNING id 2020-11-03 08:57:44,564 3396 WARNING dodo201103 odoo.modules.loading: Transient module states were reset 2020-11-03 08:57:44,566 3396 ERROR dodo201103 odoo.modules.registry: Failed to load registry File "/home/tot/code/OpenUpgrade/odoo/sql_db.py", line 231, in execute res = self._obj.execute(query, params) ParseError: "duplicate key value violates unique constraint "ir_model_data_module_name_uniq_index" DETAIL: Key (module, name)=(project, project_time_mode_id_duplicate_xmlid) already exists. " while parsing /home/tot/code/OpenUpgrade/addons/project/data/project_data.xml:27, near <record id="duplicate_field_xmlid" model="ir.model.data"> <field name="res_id" search="[('model','=','res.company'),('name','=','project_time_mode_id')]" model="ir.model.fields"/> <field name="model">ir.model.fields</field> <field name="module">project</field> <field name="name">project_time_mode_id_duplicate_xmlid</field> <field name="noupdate">True</field> </record> 2020-11-03 08:57:44,571 3396 INFO dodo201103 odoo.service.server: Initiating shutdown 2020-11-03 08:57:44,571 3396 INFO dodo201103 odoo.service.server: Hit CTRL-C again or send a second signal to force the shutdown. -- 解决:提前删除重复的记录 DELETE from ir_model_data where name='project_time_mode_id_duplicate_xmlid' ``` #### 报错a2 ``` -- 须提前修改代码 diff --git a/addons/hr_timesheet/migrations/10.0.1.0/pre-migration.py b/addons/hr_timesheet/migrations/10.0.1.0/pre-migration.py index ede6d4f9e75..0bebbb7e0d4 100644 --- a/addons/hr_timesheet/migrations/10.0.1.0/pre-migration.py +++ b/addons/hr_timesheet/migrations/10.0.1.0/pre-migration.py @@ -23,7 +23,7 @@ def create_and_populate_department(cr): SELECT r.user_id AS user_id, MAX(e.department_id) AS dpt_id FROM hr_employee e JOIN resource_resource r ON e.resource_id = r.id - GROUP BY user_id + GROUP BY r.user_id ) UPDATE account_analytic_line aal SET department_id=departments.dpt_id FROM departments WHERE aal.user_id = departments.user_id AND aal.department_id IS NULL; ``` ### 10->11升级 ``` -- 删除除.git外所有目录 rm -rf addons,setup ``` #### 报错b1 ``` 2020-11-03 09:47:57,594 6343 ERROR dodo201103 odoo.sql_db: bad query: ALTER TABLE "res_partner" ADD FOREIGN KEY ("industry_id") REFERENCES "res_partner_industry"("id") ON DELETE set null ERROR: insert or update on table "res_partner" violates foreign key constraint "res_partner_industry_id_fkey" DETAIL: Key (industry_id)=(156) is not present in table "res_partner_industry". 2020-11-03 09:47:57,602 6343 WARNING dodo201103 odoo.modules.loading: Transient module states were reset psycopg2.errors.ForeignKeyViolation: insert or update on table "res_partner" violates foreign key constraint "res_partner_industry_id_fkey" DETAIL: Key (industry_id)=(156) is not present in table "res_partner_industry". -- 提前修改代码 将 industry_id 替换为 o_industry_id ``` ### 11->12升级 ``` rm -rf addons/ debian/ doc/ odoo/ scripts/ setup/ *.pyc git checkout 12.0 git checkout . -- 将 industry_id 替换为 o_industry_id python odoo-bin -d dodo201103 --update all --stop-after-init --data-dir=/tmp/mm -c server.conf ``` #### 报错c1 ``` File "/home/tot/code/OpenUpgrade/addons/uom/models/uom_uom.py", line 92, in _check_category_reference_uniqueness raise ValidationError(_("UoM category %s should have a reference unit of measure. If you just created a new category, please record the 'reference' unit first.") % (self.env['uom.category'].browse(uom_data['category_id']).name,)) odoo.tools.convert.ParseError: "UoM category Weight should have a reference unit of measure. If you just created a new category, please record the 'reference' unit first. None" while parsing /home/tot/code/OpenUpgrade/addons/uom/data/uom_data.xml:42, near <record id="product_uom_kgm" model="uom.uom"> <field name="category_id" ref="product_uom_categ_kgm"/> <field name="name">kg</field> <field name="factor" eval="1"/> <field name="rounding" eval="0.001"/> </record> -- 查找原因:查找 uom_count 不等于1的 category_id SELECT C.id AS category_id, C.name, count(U.id) AS uom_count FROM uom_category C LEFT JOIN uom_uom U ON C.id = U.category_id AND uom_type = 'reference' AND U.active = 't' GROUP BY C.id -- 查找原因:查看对应的uom详情,发现active字段为false select * from uom_uom where uom_type='reference' and category_id in (10,5,4,2) -- 临时解决:将对应的uom的active字段改为true update uom_uom set active='t' where id in (85,38,43,46) ``` ### 12->13升级 ``` rm -rf addons/ debian/ doc/ odoo/ scripts/ setup/ *.pyc git checkout 13.0 git checkout . -- 将 industry_id 替换为 o_industry_id python odoo-bin -d dodo201103 --update all --stop-after-init --data-dir=/tmp/mm -c server.conf ``` #### 报错d1 ``` File "/home/tot/code/OpenUpgrade/odoo/addons/base/models/qweb.py", line 323, in compile raise QWebException("Error when compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name) odoo.tools.convert.ParseError: "<class 'odoo.addons.base.models.qweb.QWebException'>: "Error when compiling AST" while evaluating 'obj()._get_asset_style_b64()'" while parsing /home/tot/code/OpenUpgrade/addons/web/data/report_layout.xml:2, near <odoo> <data> <record id="asset_styles_company_report" model="ir.attachment"> <field name="datas" model="res.company" eval="obj()._get_asset_style_b64()"/> <field name="mimetype">text/scss</field> <field name="name">res.company.scss</field> <field name="type">binary</field> <field name="url">/web/static/src/scss/asset_styles_company_report.scss</field> </record> </data> </odoo> -- 报错原因 OpenUpgrade 中odoo源码较老,未拉取 [FIX] base: fix qweb ast validation with python 3.8.4 -- 解决方法 手动应用补丁文件 git apply ccc.diff ``` ccc.diff ```diff diff --git a/odoo/addons/base/models/ir_qweb.py b/odoo/addons/base/models/ir_qweb.py index 5c45c91060f..d8a2d04cbb3 100644 --- a/odoo/addons/base/models/ir_qweb.py +++ b/odoo/addons/base/models/ir_qweb.py @@ -426,10 +426,10 @@ class IrQWeb(models.AbstractModel, QWeb): def _get_attr_bool(self, attr, default=False): if attr: if attr is True: - return ast.Name(id='True', ctx=ast.Load()) + return ast.Constant(True) attr = attr.lower() if attr in ('false', '0'): - return ast.Name(id='False', ctx=ast.Load()) + return ast.Constant(False) elif attr in ('true', '1'): - return ast.Name(id='True', ctx=ast.Load()) - return ast.Name(id=str(attr if attr is False else default), ctx=ast.Load()) + return ast.Constant(True) + return ast.Constant(attr if attr is False else bool(default)) diff --git a/odoo/addons/base/models/qweb.py b/odoo/addons/base/models/qweb.py index 771ffc1f932..a4347b8d1a5 100644 --- a/odoo/addons/base/models/qweb.py +++ b/odoo/addons/base/models/qweb.py @@ -600,12 +600,12 @@ class QWeb(object): ast.Compare( left=ast.Name(id='content', ctx=ast.Load()), ops=[ast.IsNot()], - comparators=[ast.Name(id='None', ctx=ast.Load())] + comparators=[ast.Constant(None)] ), ast.Compare( left=ast.Name(id='content', ctx=ast.Load()), ops=[ast.IsNot()], - comparators=[ast.Name(id='False', ctx=ast.Load())] + comparators=[ast.Constant(False)] ) ] ), @@ -1233,7 +1233,7 @@ class QWeb(object): keywords=[], starargs=None, kwargs=None ), self._compile_expr0(expression), - ast.Name(id='None', ctx=ast.Load()), + ast.Constant(None), ], ctx=ast.Load()) ) ] @@ -1550,7 +1550,7 @@ class QWeb(object): if isinstance(key, str): keys.append(ast.Str(s=key)) elif key is None: - keys.append(ast.Name(id='None', ctx=ast.Load())) + keys.append(ast.Constant(None)) values.append(ast.Str(s=value)) # {'nsmap': {None: 'xmlns def'}} ``` #### 报错d3 ``` 2020-11-04 03:25:58,757 6440 ERROR dodo201103 odoo.sql_db: bad query: INSERT INTO "ir_act_window_view" ("id", "create_uid", "create_date", "write_uid", "write_date", "act_window_id", "sequence", "view_id", "view_mode") VALUES (nextval('ir_act_window_view_id_seq'), 1, (now() at time zone 'UTC'), 1, (now() at time zone 'UTC'), 5641, 3, 8236, 'form') RETURNING id ERROR: duplicate key value violates unique constraint "act_window_view_unique_mode_per_action" DETAIL: Key (act_window_id, view_mode)=(5641, form) already exists. -- 解决:提前删除重复的记录 DELETE from ir_act_window_view where view_mode='form' and act_window_id = 5641 ``` ### 升级后操作 - 升级完成后 hr_employee 表中的 user_id 字段全部被置成 None 了,需要从正式环境重新恢复一下 ``` -- 从正式环境恢复字段值(或修改迁移工具) select id,customer,supplier,employee from res_partner; ``` ``` -- 禁用所有用户的聊天窗口 update res_users set odoobot_state = 'not_initialized'; ```
幻翼
2020年12月25日 18:07
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码