Odoo Help


How can I make a field "required" based on the value of other field?

Tarek Mohamed Ibrahim
on 7/14/15, 9:18 AM 962 views

I found that a field could be made required based on the state of the record, using the state expression as follows:

'check_total': fields.float('Verification Total', digits_compute=dp.get_precision('Account'), readonly=True,  states={'draft':[('readonly',False)]}),

where this is a field in the account_invoice table

I need to extend this behavior to use any other field, how can I achieve this.

David Bertha
On 7/14/15, 9:32 AM

I don't know if it's possible on a field definition level, but on a view level it is :

<field name="default_debit_account_id" attrs="{'required':[('type','in', ('cash', 'bank'))]}" />

Thx for help, it worked fine. I 'm also pleased that I'm the first one who upvoted one of your answers.

Tarek Mohamed Ibrahim
on 7/16/15, 2:36 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 7/14/15, 9:18 AM
Seen: 962 times
Last updated: 7/15/15, 6:08 AM