Odoo 14自定义模块出现问题



这是一个错误,当我想安装模块时,在互联网上搜索了几个小时,只阅读了Odoo的代码。。。我能够安装并运行模块,但仍然收到这个错误

我在更新模块时遇到了以下错误,我不知道如何添加config_ok,我尝试了以下操作,但仍然无法使用

我补充道
但没有运气

Field config_ok used in attrs.invisible ({'invisible': ['|', ('config_ok','=',True), ('product_variant_count', '<=', 1)]}) must be present in view but is missing.
View name: product.template.common.form
Error context:
view: ir.ui.view(2092,)
xmlid: product_template_form_view_inherit
view.model: product.template
view.parent: ir.ui.view(878,)
file: /home/odoo/src/user/product_configurator/views/product_view.xml

<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="product_template_form_view_procurement_button" model="ir.ui.view">
<field name="name">product.template_procurement.form.inherit</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="stock.product_template_form_view_procurement_button"/>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='action_update_quantity_on_hand']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('product_variant_count', '&lt;', 1), ('type', '!=', 'product')]}</attribute>
</xpath>
</field>
</record>
<record id="product_template_form_view_inherite" model="ir.ui.view">
<field name="name">product.template.common.form</field>
<field name="model">product.template</field>
<field name="priority">16</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//header/button[@name='%(product.product_attribute_value_action)d']" position="attributes">
<attribute name="attrs">{'invisible': ['|', ('config_ok','=',True), ('product_variant_count', '&lt;=', 1)]}</attribute>
</xpath>
<div name="button_box" position="inside">
<button class="oe_stat_button" name="toggle_config"
type="object" icon="fa-wrench" groups="product_configurator.group_product_configurator_manager">
<field name="config_ok"  options='{"active": "Configurable", "inactive": "Standard"}' widget="boolean_button"/>
</button>
</div>
</field>
</record>
<record id="product_template_form_view" model="ir.ui.view">
<field name="name">product.configurator.product.template.form</field>
<field name="model">product.template</field>
<field name="priority">16</field>
<field name="inherit_id" ref="product.product_template_only_form_view"/>
<field name="arch" type="xml">
<xpath expr='//header' position="inside">
<button class="oe_stat_button" name="get_product_attribute_values_action"
attrs="{'invisible': ['|', ('attribute_line_ids', '=', []), ('config_ok', '=', False)]}"
groups="product_configurator.group_product_configurator_manager"
type="object"
string="Variant Prices">
</button>
<button name="configure_product"
class="oe_highlight"
type="object"
string="Configure Product"
groups="product_configurator.group_product_configurator"
attrs="{'invisible': [('config_ok', '=', False)]}"/>
</xpath>
<xpath expr="//label[@for='purchase_ok' or @for='sale_ok']" position="after">
<div class="oe_left" name="options" groups="base.group_user">
<field name="id" invisible="True"/>
</div>
</xpath>
<!-- Product attributes -->
<xpath expr="//field[@name='attribute_line_ids']" position="attributes">
<attribute name="context">{
'show_attribute': False,
'attribute_line_ids': attribute_line_ids,
}</attribute>
</xpath>
<!-- TODO: Implement a method to hide this field for non-configurable product templates -->
<xpath expr="//field[@name='attribute_line_ids']/tree/field[@name='value_ids']" position="after">
<field name="default_val"
domain="[('id', 'in', value_ids)]"
context="{'show_attribute': False}"
options="{'no_create': True, 'no_create_edit': True}"
invisible="not context.get('default_config_ok', False)"/>
<field name="required" invisible="not context.get('default_config_ok', False)"/>
<field name="multi" invisible="not context.get('default_config_ok', False)" attrs="{'readonly': [('custom','=',True)]}" force_save="1"/>
<field name="custom" invisible="not context.get('default_config_ok', False)" attrs="{'readonly': [('multi','=',True)]}" force_save="1"/>
</xpath>
<xpath expr="//field[@name='attribute_line_ids']/tree/field[@name='value_ids']" position="attributes">
<attribute name="attrs">{'required': [('custom','!=',True)]}</attribute>
</xpath>
<xpath expr="//field[@name='attribute_line_ids']/tree/field[@name='attribute_id']" position="attributes">
<attribute name="context">{'flag_config_ok': not parent and context.get('default_config_ok', False) or parent.config_ok}</attribute>
</xpath>
<xpath expr="//field[@name='attribute_line_ids']/tree/field[@name='attribute_id']" position="before">
<field name="sequence" widget="handle"/>
</xpath>
<!-- TODO: Apply domains so only values from template are available -->
<xpath expr="//notebook/page[@name='variants']" position="after">
<page string="Configurator" name="configurator" attrs="{'invisible': [('config_ok','=',False)]}" groups="product_configurator.group_product_configurator">
<separator colspan="4" string="Configuration Restrictions" name="configurator_restrictions"/>
<field name="config_line_ids"
attrs="{'readonly': [('attribute_line_ids','=',[])]}"
context="{'show_attribute': False}">
<tree string="Attribute Value Dependencies" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="attribute_line_id"
domain="[('product_tmpl_id','=',parent.id)]"
options="{'no_create': True, 'no_create_edit': True}"/>
<!-- # TODO: Find a more elegant way to restrict the value_ids -->
<field name="attr_line_val_ids"
widget="many2many_tags"
invisible="True"/>
<field name="value_ids"
widget="many2many_tags"
attrs="{'readonly': [('attribute_line_id','=',False)]}"
domain="[('id','in',attr_line_val_ids)]"
options="{'no_create': True, 'no_create_edit': True}"
context="{'show_attribute': False}"/>
<field name="domain_id" context="{'product_tmpl_id': product_tmpl_id or active_id or parent.id, 'product_attribute_ids': template_attribute_ids}"/>
<field name="product_tmpl_id" invisible="1"/>
<field name="template_attribute_ids" invisible="1"/>
</tree>
</field>
<separator colspan="4" string="Configuration Steps" name="configurator_steps"/>
<field name="config_step_line_ids"
attrs="{'readonly': [('attribute_line_ids','=',[])]}">
<tree string="Configuration Steps" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="config_step_id"/>
<field name="attribute_line_ids"
domain="[('product_tmpl_id', '=', parent.id)]"
options="{'no_create': True, 'no_create_edit': True}"
widget="many2many_tags"/>
</tree>
</field>
<separator colspan="4" string="Configuration Images" name="configurator_images"/>
<field name="config_image_ids">
<tree editable="bottom" string="Configuration Images">
<field name="sequence" widget="handle"/>
<field name="name"/>
<field name="value_ids" widget="many2many_tags" context="{'_cfg_product_tmpl_id': parent.id}"/>
<field name="image_1920" widget="image" height="30px"/>
</tree>
</field>
<field name="attribute_line_val_ids" invisible="1"/>
<field name="attribute_value_line_ids" invisible="1">
<tree string="Attribute value lines" editable="bottom" context="{'default_product_tmpl_id': self.id}">
<field name="product_tmpl_id" invisible="1"/>
<field name="attribute_id" invisible="1"/>
<field name="sequence" widget="handle"/>
<field name="value_id"
domain="[('id', 'in', parent.attribute_line_val_ids)]"/>
<field name="value_ids"
domain="[
('id', 'in', parent.attribute_line_val_ids),
('attribute_id', '!=', attribute_id)
]" widget="many2many_tags"/>
</tree>
</field>
<separator string="Variant Name" colspan="4" groups="product_configurator.group_product_configurator_manager"/>
<field name="mako_tmpl_name" groups="product_configurator.group_product_configurator_manager"/>
</page>
</xpath>
<xpath expr="//field[@name='default_code']" position="attributes">
<attribute name="attrs">{'invisible': [('config_ok','=',True)]}</attribute>
</xpath>
</field>
</record>
<record id="product_template_search_view" model="ir.ui.view">
<field name="name">product.configurator.product.template.search.view</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_search_view"/>
<field name="arch" type="xml">
<xpath expr="//filter[@name='filter_to_sell']" position="after">
<separator/>
<filter string="Standard Products" name="filter_standard_products" domain="[('config_ok','=',False)]"/>
<filter string="Configurable Products" name="filter_config_ok" domain="[('config_ok','=',True)]"/>
</xpath>
</field>
</record>
<record id="template_view_tree_configurable" model="ir.ui.view">
<field name="name">product.template.product.tree</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_tree_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='default_code']" position="attributes">
<attribute name="invisible">context.get('default_config_ok', 0)</attribute>
</xpath>
</field>
</record>
<record id="product_template_kanban_view_inherited" model="ir.ui.view">
<field name="name">Product.template.product.kanban</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="//kanban" position="inside">
<field name="config_ok"/>
</xpath>
<xpath expr="//div/div[2]" position="before">
<div class="pull-right" groups="product_configurator.group_product_configurator" attrs="{'invisible': [('config_ok', '=', False)]}">
<a name="configure_product" type="object">
<i class="fa fa-wrench fa-lg"></i>
</a>
</div>
</xpath>
</field>
</record>
<record id="product_form_view_custom_vals_inherit" model="ir.ui.view">
<field name="name">product.configurator.form.view.custom.vals</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr='//header' position="inside">
<button string="Variant Prices" type="object"
name="get_product_attribute_values_action"
attrs="{'invisible': ['|', ('product_template_attribute_value_ids', '=', False), ('config_ok', '=', False)]}"
groups="product_configurator.group_product_configurator_manager"/>
<button name="reconfigure_product" groups="product_configurator.group_product_configurator"
class="oe_highlight"
type="object"
string="Reconfigure Product"
attrs="{'invisible': [('config_ok','=',False)]}"/>
</xpath>
<xpath expr="//button[@name='toggle_config']" position="attributes">
<attribute name="invisible">1</attribute>
</xpath>
<xpath expr="//div[@name='options']" position="inside">
<field name="config_preset_ok" attrs="{'invisible': [('config_ok', '=', False)]}"/>
<label for="config_preset_ok" attrs="{'invisible': [('config_ok', '=', False)]}"/>
</xpath>
</field>
</record>
<record id="product_variant_easy_edit_view_inherit" model="ir.ui.view">
<field name="name">product.product.view.form.easy</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_variant_easy_edit_view"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="//field[@name='active']" position="after">
<field name="config_ok" invisible="1"/>
<field name="config_preset_ok" attrs="{'invisible': [('config_ok', '=', False)]}"/>
</xpath>
<xpath expr="//field[@name='weight']" position="attributes">
<attribute name="attrs">{'readonly': [('config_ok', '=', True)]}</attribute>
</xpath>
</field>
</record>
<record id="product_kanban_view_inherited" model="ir.ui.view">
<field name="name">Product Kanban</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_kanban_view"/>
<field name="arch" type="xml">
<xpath expr="//kanban" position="inside">
<field name="config_ok"/>
</xpath>
<xpath expr="//div/div[2]/strong[hasclass('o_kanban_record_title')]" position="after">
<div class="pull-right" groups="product_configurator.group_product_configurator" attrs="{'invisible': [('config_ok', '=', False)]}">
<a name="reconfigure_product" type="object" class="fa fa-repeat fa-lg">
</a>
</div>
</xpath>
</field>
</record>
</data>
</odoo>

提前感谢

此错误可能有多种原因:

如果您还没有尝试过基本解决方案,第一个解决方案

  1. 激活开发者模式
  2. 打开用户并设置要显示的筛选器
  3. 非活动设置OdooBot为内部用户

第二个解决方案:为缺少字段abov attribue xpath显式添加xpath

<xpath expr="//header/button[@name='action_update_quantity_on_hand']" position="before">
<field name="config_ok" />
</xpath>

如果以上任何一项都不起作用,请告诉我。

最新更新