handling required attribute of a field

Asked by mm alam

Hi every one,

Is this possible to pro-grammatically handle the 'required=true' attribute of a field. In other words, can I leave the required attribute and make it required using the python file?

Actually I want to make the field required under some scenarios and vice versa in other scenarios.

Regards,

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.

Revision history for this message
qdp (OpenERP) (qdp) said :
#2

hi,

in this case the field shouldn't be required=True on the object (in the .py file) but only in the view (in the .xml file), you can then use the attribute "attrs" on that field in the view to make it readonly or not in function of some parameters:

readonly="0" attrs="{'readonly':[('field_to_test','=', 'condition_for_this_field_to_be_readonly')]}

Hope this helps,
Quenitn

Revision history for this message
qdp (OpenERP) (qdp) said :
#3

see above comment