Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
6304 Переглядів

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?


Аватар
Відмінити
Найкраща відповідь

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>
Аватар
Відмінити
Автор

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

Автор

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 ?

Автор

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.

Автор

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 Відповіді Переглядів Дія
0
квіт. 20
3624
1
жовт. 16
6458
1
лют. 25
2496
3
груд. 24
2133
2
бер. 24
2310