Stone
Stone

Reputation: 111

Attrs not evaluated when using "parent." notation on one2many's fields

I assigned default value on stock.picking object in Action XML.

This default value will determine few condition on form behavior, includes i need to disable few fields on the lines (stock.move), but it's hard for me to do attrs on stock move fields as i can't use "parent" as notation.

For example i want to do something like this

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

NB : i can't use field.related, reason as in if i'm creating a new record there're no way field.related can get the default value i assigned on window actions.

Is there any way to do Attrs using parent default value as condition?

Please help.

Upvotes: 0

Views: 1054

Answers (1)

Bhavesh Odedra
Bhavesh Odedra

Reputation: 11141

Here is example, please try that one.

This attrs will make readonly when Shipping Type = Sending Goods

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

Generic Answer

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

Hope this will help you.

Upvotes: 1

Related Questions