Skip to content

Latest commit

 

History

History
104 lines (69 loc) · 4.05 KB

9_groupFilter.md

File metadata and controls

104 lines (69 loc) · 4.05 KB

Set Default GroupBy For Menu Action

  • 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>

    groupFilter1

Set Default Filter For Menu

  • 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>

    groupFilter2

Set Domain For Menu Action

  • To set domain for menu action we have created a sub-menu named Kids Appointments in the Appointments menu. Then set a domain for kids based on age.

    <field name="domain">[('age', '&lt;=', 10)]</field>

    groupFilter3

Default Field Value using Context Based On Menu

  • 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 use fieldName, condition and fieldValue 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', '&lt;=', 10)]</field>
    2. AND operation
    <field name="domain">[('gender','=', 'female'), ('age', '&gt;=', 10)]</field>

    menus8

  • To set the default value for a field we have set the context field in the window action like below. Here we have to use default_fieldName : fieldValue inside {}. Here we will set the default value of gender to male if we create male patients and female otherwise.

    # for male
    <field name="context">{'default_gender' : 'male'}</field>
    
    # for female
    <field name="context">{'default_gender' : 'female'}</field>

    menus7 menus9

Hide Fields Based On Context value

  • To hide the gender field after clicking the Patients sub-menu Male Patients or Female patients we have to use a context in the action window. And we have to add another attribute named invisible 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')"/>

    menus10

🚀 Happy Coding ! 🔥