Odoo 13升级模块时出现Field 'state'不存在错误求助
Odoo 13升级模块报错:Field 'state' does not exist
问题场景
升级模块时触发Odoo 13报错:Field 'state' does not exist,此前无此问题,且当前模块代码未做任何修改。当前模块的__manifest__.py已声明依赖fieldservice模块,但fsm.order模型的state字段是在另一个自定义模块中扩展添加的。
相关代码
view.xml
<record id="fsm_order_form" model="ir.ui.view"> <field name="name">fsm.order.form</field> <field name="model">fsm.order</field> <field name="inherit_id" ref='fieldservice.fsm_order_form'/> <field name="arch" type="xml"> <xpath expr="//notebook/page[@name='planning_page']/group" position="after"> <field name="planning_ids"> <tree string='Planning'> <field name="employee_id"/> <field name="role_id"/> <field name="start_datetime"/> <field name="end_datetime"/> <field name="allocated_hours"/> <field name="wage"/> </tree> </field> <group> <group class="oe_subtotal_footer oe_right" name="planning_hours"> <field name="planned_hours" widget="float_time"/> <field name="currency_id" invisible='1'/> <field name="planned_labour_cost" class="oe_subtotal_footer_separator" widget='monetary' options="{'currency_field': 'currency_id'}"/> </group> </group> </xpath> </field> </record>
manifest.py
'depends': ['base','web','mail','dms','project_stock_request','business_requirement','stock_request_customization','bi_job_cost_estimate_customer','planning','repair','project','quality_control','project_task_material','sale_timesheet','hr_timesheet','fieldservice','maintenance','mrp','maintenance_plan','bi_job_cost_estimate_customer'],
解决步骤
- 补充模块依赖:当前模块的
depends列表中缺少那个添加state字段的自定义模块,必须将其加入depends,确保Odoo加载当前模块前,先加载并初始化包含state字段的模块。 - 按顺序升级模块:先升级添加
state字段的自定义模块,再升级当前模块。可以在Odoo后台应用列表操作,也可以用命令行指定顺序:odoo-bin -c your_config.conf --update=添加state的模块名,当前模块名 - 验证模块状态:确认添加
state字段的自定义模块已安装、未被禁用,且最新代码已生效。 - 检查视图继承逻辑:虽然当前视图代码未直接使用
state字段,但原fieldservice.fsm_order_form视图可能依赖该字段,确保依赖链完整后,重新升级视图所在模块。
内容的提问来源于stack exchange,提问作者Khaalidi
相关产品推荐
相关产品推荐

