Odoo Help


how to implement a search function for a field of type many2one?

on 4/11/14, 8:00 AM 1,910 views

Hi, im trying to implement a simple search function in open erp 7. It will search and list all records based on management code, but the problem is management code is a type many2one and its a field in another model. when i run it, it gives me an error like this below.What do i need to change to make it work?

ProgrammingError: operator does not exist: integer ~~* unknown LINE 1: ...t_org_table" WHERE ("budget_org_table"."management_code" ilike '%12... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts

my xml code

  <record id="feature_search" model="ir.ui.view">
        <field name="name">management.feature_inventory.search</field>
        <field name="model">management.feature_inventory</field>
        <field name="arch" type="xml">
            <search string="Feature Inventory">
        <field name="management_code" string="Management Unit Code"/>
                <field name="year" string="Year"/>

my model

class feature_inventory(osv.osv):

_name = "management.feature_inventory"
_description = "Feature Inventory"
_rec_name = "feature_code"
_columns = {
    'feature_code' : fields.many2one("budget.feature_details","Code", required=True),
    'management_unit_code' : fields.many2one("budget.org_table", "Management Unit Code", required=True),
    'Total' : fields.integer("Total"),
    'condition_1' : fields.integer("Condition 1"),
    'condition_2' : fields.integer("Condition 2"),
    'condition_3' : fields.integer("Condition 3"),
    'year' : fields.integer("Year", size=64, required=True),
_sql_constraints = [
    ('feature_code_unique', 'UNIQUE(feature_code)', 'Each feature_code is unique.'),

please help...

Update your xml with management_unit_code instead of management_code and try.

on 4/11/14, 8:41 AM



| 5 5 7
Bikaner, India

OpenERP Developer at SunARC Technology

On 4/11/14, 9:09 AM

In python class use table name dot notation

_name = "management.feature.inventory"

If management_code field is another module u want to show in current model. Then using related field add in the current model and then shows the field in search view.

Refer the below link to add related field


thanks...that solved the problem

on 4/14/14, 8:19 AM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 4/11/14, 8:00 AM
Seen: 1910 times
Last updated: 3/16/15, 8:10 AM