Odoo 14:One2many 字段中的域过滤器 Function.prototype.apply 的第二个参数必须是数组

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

我在 Odoo 12 中有此代码,运行很好,一旦我们迁移到 Odoo 14,单击“角色”字段时会出现错误。

代码错误

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

第一个视图 view

堆栈跟踪 error message

正在像这样填充现场角色:

查看:

<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>

模型中的变量:

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)

Odoo 14 有语法更新吗?

当我们在xml端使用属性应用域时,它应该是列表样式而不是双引号。例如

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

并且不要忘记关闭 xpath 标记。我在你的问题中看不到它。