Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
7527 Weergaven

Is there a way to change whether the field is required or not based on some method or some other field in a different module?

Something that would work both on create and write?



Avatar
Annuleer
Beste antwoord

Create a related field and hide it in the form view, then write it into the attrs attribute of the view definition:

class my_model(osv.osv):
    _name = 'my.model'
    _columns = {
        # ...
        'other_field': fields.related('other_object_id', 'other_object_field', type='boolean', string='Other Field'),
    }
<field name="my_field" attrs="{'required': [('other_field','=',True)]}"/>
<field name="other_field" invisible="1"/>
Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
1
mrt. 15
7970
2
aug. 22
14939
0
jun. 22
2230
1
okt. 19
5529
2
sep. 19
6477