I've a 'school' module to work with students and teachers.
And I've a wizard which have a many2one field and want to hide it based on current model that we are standing.
I.e: we are standing on model 'school.teachers', then we will hide this field, and when we standing on model 'school.students', then we will show it.
Model:
teacher_id = fields.Many2one('school.teachers', string='Teachers', required=True)
View:
<field name="teacher_id"/>
Here's the full code:
https://github.com/saxsax1995/odoo-15-school/blob/master/school/wizard/create_calendar_wizard.py
https://github.com/saxsax1995/odoo-15-school/blob/master/school/wizard/create_calendar_wizard_view.xml
Please help, thanks.
You can set the invisible
attribute based on context
values.
The current model (active_model
) is passed in the context :
<field name="student_id" invisible="context.get('active_model')!='school.students'"/>