-
To show the data by group we have to add group rules in search view. Here we have added a group rules by status.
<group expand="1" string="Group By"> <filter string="Status" name="state" context="{'group_by':'status'}"/> </group>
-
Then we have to add context for this group in action window and add the default search for state inside
{}
. If we don't add the default search then it will be empty.<field name="context">{'search_default_state': 1}</field>
-
For filtering based on gender we have to add some filter rules.
<filter string="Male" name="male" domain="[('gender', '=', 'male')]"/> <filter string="Female" name="female" domain="[('gender', '=', 'female')]"/>
-
Then we have to add context for this filter in action window just like group.
<field name="context">{'search_default_state': 1, 'search_default_male': 1}</field>
-
To set domain for menu action we have created a sub-menu named
Kids Appointments
in theAppointments
menu. Then set a domain for kids based on age.<field name="domain">[('age', '<=', 10)]</field>
-
For showing the specific field values based on clicking the menu, we have to set
domain
field in the window action like below. Here we have to usefieldName
,condition
andfieldValue
inside the()
.# for single domain values <field name="domain">[('gender','=', 'female')]</field> # for multiple domain values 1. OR operation <field name="domain">['|', ('gender','=', 'female'), ('age', '<=', 10)]</field> 2. AND operation <field name="domain">[('gender','=', 'female'), ('age', '>=', 10)]</field>
-
To set the default value for a field we have set the
context
field in the window action like below. Here we have to usedefault_fieldName : fieldValue
inside{}
. Here we will set the default value ofgender
tomale
if we create male patients andfemale
otherwise.# for male <field name="context">{'default_gender' : 'male'}</field> # for female <field name="context">{'default_gender' : 'female'}</field>
-
To hide the gender field after clicking the
Patients
sub-menuMale Patients
orFemale patients
we have to use a context in the action window. And we have to add another attribute namedinvisible
in the specific field of the form view.# window action <field name="context">{'default_gender' : 'female', 'hide_gender' : 1}</field>
# form view <field name="gender" invisible="context.get('hide_gender')"/>