Thursday 28 November 2013

Add tag in advance search


Hello All,

In openerp there is functionality so we can see the field with combination of more than one field, means field one is display with field 1+ field 2
ex. field 1 value = 'My Account' field 2 = '007' now with the use of name_search method we can concete both fields and its look like 'oo7/My Account' . Now, in this case its became very hard to search so openerp provides one way as a put a tag on search. So, its became eady to you what you want to search. Tags look like , 'name:YOUR_VALUE' , 'code:YOUR_VALUE'..

To do, you need to add following code,

+            if name and str(name).startswith('name:'):
+                acc_name = name.split(':')[1]
+                args += [('name', operator, acc_name)]
+                name = False
+            if name and str(name).startswith('code:'):
+                code = name.split(':')[1]
+                args += [('code', operator, code)]
+                name = False

You  can use it like following way,




..Enjoy..