Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
5362 Näkymät

I want to set the class of my form depending on an object condition. Here is a example of what I'm trying to do with pseudo code:

<record model="ir.ui.view" id="my_demo_record_view">
<field name="name">my_demo.record.form</field>
<field name="model">my_demo.record</field>
<field name="arch" type="xml">
if ('priority', '=', 'important'):
<form class="my_demo_important_form" string="Record Form">
else:
<form string="Record Form">
...
</form>
</field>
</record>


Avatar
Hylkää
Paras vastaus

Hi, I guess for a form view it is impossible without redefining JavaScript of a form view rendering. In kanban it would be fine, since you can apply qweb 't-attf-', but not for a form view.

Surely, you may still use the attrs invisible for the whole form, e.g. <form attrs="{'invisible': [('priority', '=', 'important')]}" class='my_demo_important_form'/>. However, it would be hardly a good solution, since you would need to duplicate your form within the single view, and all fields would be duplicated as well.

Avatar
Hylkää