Skip to Content
Menu
This question has been flagged
1 Reply
4976 Views

I am trying to hide fields in my order.lines view based on a sale.order field. My xpath code doesn't work:

Note: Sale order field = x_studio_sales_type and Order line field = x_studio_florist_notes

<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='name']" position="after">
<field name="x_studio_florist_notes" attrs="{'invisible':[//field[@name='x_studio_sales_type'], '=', 'Events']}"/>
</xpath>

Is there any way to achieve this?


Avatar
Discard
Best Answer

Hi Linda:

The syntax of the condition for invisible needs to be fixed. Try this

<xpath expr="//form[1]/sheet[1]/notebook[1]/page[@name='order_lines']/field[@name='order_line']/tree[1]/field[@name='name']" position="after">
<field name="x_studio_florist_notes" attrs="{'invisible':[('x_studio_sales_type', '=', 'Events')]}"/>
</xpath>
Avatar
Discard
Author

Thanks for the response, I did try this syntax to begin with but it didn't work either.

Error while validating constraint

unexpected EOF while parsing

('', 1, 54, "{'invisible': [('x_studio_sales_type', '=', 'Events')]")

Please post the name of the view you are trying to customize

Author

I'm trying to edit sale.view_order_line_tree using fields from sale.view_order_form

Tried it on sale.view_order_form and it works fine here. Can you post a screenshot of your view customization ?

Author

Not enough karma to post images on the forum. But you can find my form here https://ibb.co/6bkmXBy

The following syntax for the <field...../> part may be more appropriate in your situation.

<field name="x_studio_florist_notes" attrs="{'column_invisible':[('parent.x_studio_sales_type', '=', 'Events')]}"/>

The difference being that with "invisible", it will always display the column but hide/display the value in the column conditionally. With the second syntax, it will hide/display the whole column based on the condition. Since it looks like your custom field is defined at the Sales Order level, you need to use the "parent." to reference x_studio_sales_type.

Hope this helps.

Author

Thanks so much for helping me Paresh, using the above worked! Also for explaining the differences between the two "invisible" and "column_invisible".

Related Posts Replies Views Activity
0
Apr 20
2599
1
Oct 16
5059
2
Mar 24
708
2
Feb 24
1265
0
Jan 24
38