This question has been flagged
2 Replies
7814 Views

 

I added a boolean field in my search view. When i grouped it, instead of the field name it shows true. I want remove the true showing in the filter view. I added string="field label" and name="field label" both are not working.

Then i listed and take search view, still shows wrongly.

Please suggest a method to search perfectly a boolean field.

How can i solve this?

For Eg:

'temporary_employees' : fields.boolean('Temporary Employees'),

 

<group string="Temporary Employees">
                        <filter string="Temporary Employees" icon="terp-gtk-select-all" domain="['&amp;',('temporary_employees',  '=', True)]" context="{'group_by':'temporary_employees'}"/>
                    </group>

When i take group by of the above field, search name shows as True/false instead of  Temporary Employees.

When we give filter string="Temporary Employees", group by name will shows the corresponding string name,right?But for boolean field it showing true/false in kanban view and in tree view showing checkbox. How can i get the dting in the group by?

 

 

Avatar
Discard

Hello Rosery, what do you want to do exactly ? Are you willing to make a similar filter as the 'customer' 'supplier' in Partners search view ? If not, could you post some example of what you want to do ?Regards

Author

Please check the updated question

Best Answer

Hello Rosey,

You can resolve your problem with read_group, you use following example for reference.

Example:

def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None, orderby=False,lazy=True):
        ret_val = super(res_partner, self).read_group(cr, uid, domain, fields, groupby, offset=offset, limit=limit, context=context, orderby=orderby,lazy=lazy)
        for rt in ret_val:
            if rt.has_key('customer'):
                if rt.get('customer', False):
                    rt['customer'] = 'Customer'
                else:
                    rt['customer'] = 'Not Customer'
        return ret_val

Here, customer is boolean field, when we group by boolean field it will display value means True or False but you can change the value of Display by using read_group method.

Thanks.

Avatar
Discard
Author

But it doesnt change the value. Still the same.

Where you want to change? This will replace true with 'Customer' on group title.

Author

I want to change in my custom module.

Author

I checked the code, but still the same in interface. But while debugging i get rt['customer'] = 'Customer'. not displaying in interface

rt['customer'] here customer means the Boolean field name. = 'Customer' means the string which you want to display.

Author

i gave my boolean field, when i printed the value,it is displaying in the debugging portion. But in interface still the same. True / False

Best Answer

So, let me get this straight. You created a boolean (true or false) and you want to group your results by this value. Then when you select the "group-by" it shows to unfoldable results, namely "true" and "false"? Is this correct?

If so, I can't think of any alternative way to do this. The value is going to be either true or false, there is no in between.

Avatar
Discard
Author

I know that. Can change true or false name occuring in the filter result by any attribute? I want to dispaly field name there in the filter view. Is it possible?