在 one2many 的字段上使用"parent."表示法时不评估 attrs



我给股票赋了默认值。

这个默认值将决定表单行为的几个条件,包括我需要禁用行上的几个字段(stock.move),但是我很难在stock move字段上做attrs,因为我不能使用"parent"作为标记。

例如,我想做这样的事情

<xpath expr="/form/notebook/page/field[@name='move_lines']/form/group/field[@name='location_dest_id']" position="attributes">
    <attribute name="attrs">{'readonly': [('parent.type','=','out')]}</attribute> 
</xpath>

注意:我不能使用field。相关的原因是,如果我要创建一个新记录,就没有办法字段。相关的可以得到我在窗口操作上分配的默认值。

是否有任何方法来做Attrs使用父默认值作为条件?

请帮。

这里有个例子,请试试那个

Shipping Type = Sending Goods

时,attrs将生成readonly
<field name="location_dest_id" position="attributes">
    <attribute name="attrs">{'required': [('chained_picking_type','=','out')]}</attribute>
</field> 

通用答案

<field name="parent_id" position="attributes">
    <attribute name="attrs">{'required': [('parent_field_name','=','value_of_field')]}</attribute>
</field> 

最新更新