Search code examples
pythonpython-3.xodooodoo-14

Odoo 14: Domain filter in a One2many field second argument to Function.prototype.apply must be an array


I had this code in Odoo 12 and running fine once we migrated to Odoo 14 gives an error when clicking the Roles field.

Code Error

Traceback:
Error: second argument to Function.prototype.apply must be an array

First View view

Stacktrace error message

the field role is being populated like this:

View:

<odoo>
  <data>
    <record id="product_pricelist_item_form_inherit" model="ir.ui.view">
      <field name="name">product.pricelist.item.inherit</field>
      <field name="model">product.pricelist.item</field>
      <field name="inherit_id" ref="product.product_pricelist_item_form_view"/>
      <field name="arch" type="xml">

       <xpath expr="//field[@name='product_tmpl_id']" position="attributes">
       <attribute name="string">Roles</attribute>
       <attribute name="domain">"[('is_employee','=', True)]"</attribute>

    </record>
  </data>
</odoo>

variables in model:

item_ids = fields.One2many('product.pricelist.item', 'pricelist_id', 'Pricelist Items',copy=True, default=False)
    
is_employee = fields.Boolean(string='Is an Employee', default=True)

Is there syntax updates for Odoo 14?


Solution

  • When we apply domain using attributes in xml side, it should be list style instead of double quotes. For example

    <attribute name="domain">[('is_employee','=', True)]</attribute>
    

    And don't forget to close xpath tag. I cannot see it in your question.