It's an error that happen when I want to install the module, and after hours of search on the internet, hours of just reading Odoo's code... I was able to install and run the module but still getting this error
I get the following error when updating the Module I cant figure out how to add the config_ok, I tried the following but still didn't work
I added
but no luck
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', '<', 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', '<=', 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>
Thank you in advance
There can be multiple reasons for this error:
If you haven't tried basic solution, first solution:
Activate developer mode
Open users and set filter to display
Inactive Set OdooBot as an internal user
Second solution: explicitly add xpath for missing field abov attribue xpath.
<xpath expr="//header/button[#name='action_update_quantity_on_hand']" position="before">
<field name="config_ok" />
</xpath>
Let me know, if any of above don't work.
In the product category, I added a product_ids field and I want to display it with a tree view showing name and default_code of products. For some reason I get the error "Field default_code does not exist"
<record id="view_product_category_qty_discount" model="ir.ui.view">
<field name="name">product.category.inherit.qty.discount.Config Hetlita</field>
<field name="model">product.category</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_category_form_view" />
<field name="arch" type="xml">
<form position="inside">
<group col="2" colspan="2">
<separator string="Quantity for discount" colspan="2"/>
<field name="qty_for_discount" />
</group>
<group>
<field name="product_ids" widget="many2many_tags"/>
<tree>
<field name="name"/>
<field name="default_code"/>
</tree>
</group>
</form>
</field>
</record>
class ProductCategory(models.Model):
_inherit = 'product.category'
qty_for_discount = fields.Float(string='Qty For Discount')
product_ids = fields.Many2many(
'product.template', string='Products')
That's because there is no default_code on model product.template but instead on its variants with model product.product. I would change the field on product.category to a One2Many on product.product:
product_ids = fields.One2many(
comodel_name='product.product',
inverse_name='categ_id',
string='Products')
And there is a mistake in your xml:
<group>
<field name="product_ids">
<tree>
<field name="name"/>
<field name="default_code"/>
</tree>
</field>
</group>
My custom module view looks like this
<odoo>
<data>
<record model="ir.ui.view" id="session_form_view">
<field name="name">item.form</field>
<field name="model">inventory.item</field>
<field name="arch" type="xml">
<form string="Items Form">
<sheet>
<group>
<field name="name"/>
<field name="code"/>
<field name="department"/>
<field name="state"/>
</group>
<group>
<field name="measurement" position="attributes">
<attribute name="attrs">{'invisible': [('state', '=', True)]}</attribute>
</field>
</group>
</sheet>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="items_tree">
<field name="name">Item</field>
<field name="res_model">inventory.item</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<!-- <field name="context" eval="{'state':True}" /> -->
</record>
<menuitem id="main_openacademy_menu" name="Inventory"></menuitem>
<menuitem id="openacademy_menu" name="Store" parent="main_openacademy_menu"></menuitem>
<menuitem id="store_items_menu" name="Store items" parent="openacademy_menu" action="items_tree"/>
</data>
</odoo>
I have a simple model
I want to hide/show based on the department drop down. But some how for a lot of cases attrs is not working. I am begginer and using odoo 10.
Thanks
How define gray footer under one2many_list for sum, eg.
https://postimg.org/image/jc9alzoeh/
Just in the embedded tree of your One2many field add sum="Title":
<field name="o2m_field_name" >
<tree>
...
<field name="field_name" sum="Total field name"/>
</tree>
<form>
....
...
</form>
</field
You just need to add sum attribute to the duration field.
An example with invoice lines:
<field name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}">
<tree string="Invoice Lines" editable="bottom">
<field name="sequence" widget="handle"/>
<field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
<field name="name"/>
<field name="company_id" invisible="1"/>
<field name="account_id" groups="account.group_account_user" domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '=', 'other')]" on_change="onchange_account_id(product_id, parent.partner_id, parent.type, parent.fiscal_position,account_id)"/>
<field name="account_analytic_id" groups="analytic.group_analytic_accounting" domain="[('type','!=','view'), ('company_id', '=', parent.company_id), ('state','not in',('close','cancelled'))]"/>
<field name="quantity"/>
<field name="uos_id" groups="product.group_uom" on_change="uos_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.currency_id, parent.company_id, context)"/>
<field name="price_unit"/>
<field name="discount" groups="sale.group_discount_per_so_line"/>
<field name="invoice_line_tax_id" widget="many2many_tags" context="{'type':parent.type}" domain="[('parent_id','=',False),('company_id', '=', parent.company_id)]"/>
<field name="price_subtotal" sum='Total'/>
</tree>
It should looks like:
<field name="field name" nolabel="1" widget="one2many_list">
<tree editable="bottom">
...
<field name="duration" sum='Total'/>
</tree>
</field>
Hi I have a mode Unit which inherits product.product.
I have defined the custom views for Unit and they work fine from the menu.
Property which inherits account.asset.assets has multiple units.
How do I call my custom unit views from the Property view?
When I click on Add an item I get the standard product form.
<record id="unit_form" model="ir.ui.view">
<field name="name">All Units</field>
<field name="model">product.product</field>
<field name="sequence">0</field>
<field name="arch" type="xml">
<form string="Unit">
<group>
<field name="property_id" widget="many2one" attrs="{'required': [('is_unit', '=', True)]}" />
<field name="is_unit" invisible="1" />
<field name="features_amenities_ids" placeholder="Features and Amenities" widget="many2many_tags" />
<field name="appliences_ids" placeholder="Apliences" widget="many2many_tags" />
<field name="lst_price" string="Rent" />
</group>
</form>
</field>
</record>
<record id="unit_tree" model="ir.ui.view">
<field name="name">All Units</field>
<field name="model">product.product</field>
<field name="arch" type="xml">
<tree string="Units" default_order='property_id,name'>
<field name="property_id" />
<field name="name" string="Unit#" />
</tree>
</field>
</record>
<record id="action_unit" model="ir.actions.act_window">
<field name="name">Units</field>
<field name="res_model">product.product</field>
<field name="view_mode">search, kanban,tree,form</field>
<field name="domain">[('is_unit', '=', True)]</field>
<field name="context">{'default_is_unit':1 }</field>
<field name="search_view_id" ref="unit_search"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to create a Unit.
</p>
<p>
Here you will find the all units.
</p>
</field>
</record>
<record id="action_unit_form" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="unit_form" />
<field name="view_mode">form</field>
<field name="sequence">10</field>
</record>
<record id="action_unit_tree" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="unit_tree" />
<field name="view_mode">tree</field>
<field name="sequence">9</field>
</record>
<record id="action_unit_kanban" model="ir.actions.act_window.view">
<field name="act_window_id" ref="action_unit" />
<field name="view_id" ref="product.product_kanban_view" />
<field name="view_mode">kanban</field>
<field name="sequence">8</field>
</record>
<menuitem action="action_unit" sequence="2"
id="menu_units_list" name="Units" parent="menu_property_sub"/>
This is from Property
<notebook colspan="4">
<page string="Units">
<field name="unit_ids" nolabel="1" widget="one2many" >
<tree string="Units">
<field name="name" string="Unit#"/>
</tree>
</field>
</page>
</notebook>
If you want to specify a view for many2one or one2many field:
<field name="m2o_id" context="{'form_view_ref': 'module_name.form_id'}"/>
hope this helps. there are other key word like tree_view_ref for tree views