Odoo Help


This community 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.


Error when directly entered to my many2one field?

on 11/16/14, 12:26 AM 1,193 views

Hi, I got an error message below when directly entered to my price_id field, unlike other
fields when you directly entered value it will automatically show to lines with "create "value"" and "create and edit.." but in price_id field showing error but if I click OK button I can continue save.

Is there any wrong with the below code?

class test_product(osv.Model):
    _name = "test.product"

    _columns = {
        'prodcode_id': fields.many2one("abs.prod.desc", 'Product Code'),
        'description_id': fields.many2one('abs.desc', 'Description'),
        'description': fields.related('description_id', type='many2one', relation='abs.desc', string='Description',),
        'price_id': fields.many2one('abs.price', 'Price', ondelete='cascade'),
        'price': fields.related('price_id','name', type='float', string='Price', ondelete='cascade'),
    def onchange_prodcode(self, cr, uid, ids, prodcode_id, context=None):
        if prodcode_id:
            description_id = self.pool.get('abs.prod.desc').browse(cr, uid, prodcode_id, context).description_id.id
            price_id = self.pool.get('abs.prod.desc').browse(cr, uid, prodcode_id, context).price_id.id
            return {'value':{'description_id':description_id, 'price_id':price_id}}
        return {}

class descriptionproduct(osv.osv):
    _description="Description Product"
    _name = 'abs.prod.desc'
    _columns = {
        'name': fields.char('Code', size=64, required=True,),
        'description_id': fields.many2one('abs.desc', 'Description', required=True),
        'price_id': fields.many2one('abs.price', 'Price', required=True),
class description(osv.osv):
    _name = 'abs.desc'
    _description = 'Description'
    _columns = {
        'name': fields.char('Description Name', size=64, required=True,),

class productprice(osv.osv):
    _description="Product Price"
    _name = 'abs.prod.price'
    _columns = {
        'price_id': fields.many2one('abs.price', 'Price', required=True),
        'name': fields.float('Price', digits=(12,2)),

class price(osv.osv):
    _name = 'abs.price'
    _description = 'Price'
    _columns = {
        'name': fields.float('Price', digits=(12,2)),


    <record id="test_product_submenu_action" model="ir.actions.act_window">
        <field name="name">Products</field>
        <field name="res_model">test.product</field>
        <field name="view_type">form</field>
        <field name="view_mode">tree,form</field>
        <field name="help" type="html">
            <p class="oe_view_nocontent_create">Click Create to add a new Products record.</p>
    <record id="test_product_form_view" model="ir.ui.view">
        <field name="name">test.product.form.vew</field>
        <field name="model">test.product</field>
        <field name="type">form</field>
        <field name="arch" type="xml">
            <form string="Product" version="7.0">
                    <field name="prodcode_id" class="oe_no_button" placeholder="Product Code" style="width: 37%%" on_change="onchange_prodcode(prodcode_id)"/>
                    <field name="description_id" class="oe_no_button" placeholder="Description" style="width: 37%%"/>
                    <field name="price_id" class="oe_no_button" placeholder="Price" style="width: 37%%"/>

    <record id="test_product_tree_view" model="ir.ui.view">
        <field name="name">test.product.tree.view</field>
        <field name="view_type">tree</field>
        <field name="model">test.product</field>
        <field name="arch" type="xml">
        <tree string="Inventory">
              <field name="prodcode_id" string="CODE"/>
              <field name="description_id" string="Description"/>
              <field name="price_id" string="Price"/>


Client Traceback (most recent call last): File "/home/philip/wsorig/openerp/web/addons/web/http.py", line 204, in dispatch response["result"] = method(self, **self.params) File "/home/philip/wsorig/openerp/web/addons/web/controllers/main.py", line 1128, in call_kw return self._call_kw(req, model, method, args, kwargs) File "/home/philip/wsorig/openerp/web/addons/web/controllers/main.py", line 1120, in _call_kw return getattr(req.session.model(model), method)(*args, **kwargs) File "/home/philip/wsorig/openerp/web/addons/web/session.py", line 42, in proxy result = self.proxy.execute_kw(self.session._db, self.session._uid, self.session._password, self.model, method, args, kw) File "/home/philip/wsorig/openerp/web/addons/web/session.py", line 30, in proxy_method result = self.session.send(self.service_name, method, *args) File "/home/philip/wsorig/openerp/web/addons/web/session.py", line 103, in send raise xmlrpclib.Fault(openerp.tools.ustr(e), formatted_info) Server Traceback (most recent call last): File "/home/philip/wsorig/openerp/web/addons/web/session.py", line 89, in send return openerp.netsvc.dispatch_rpc(service_name, method, args) File "/home/philip/wsorig/openerp/server/openerp/netsvc.py", line 296, in dispatch_rpc result = ExportService.getService(service_name).dispatch(method, params) File "/home/philip/wsorig/openerp/server/openerp/service/web_services.py", line 626, in dispatch res = fn(db, uid, *params) File "/home/philip/wsorig/openerp/server/openerp/osv/osv.py", line 190, in execute_kw return self.execute(db, uid, obj, method, *args, **kw or {}) File "/home/philip/wsorig/openerp/server/openerp/osv/osv.py", line 132, in wrapper return f(self, dbname, *args, **kwargs) File "/home/philip/wsorig/openerp/server/openerp/osv/osv.py", line 199, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) File "/home/philip/wsorig/openerp/server/openerp/osv/osv.py", line 187, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) File "/home/philip/wsorig/openerp/server/openerp/osv/orm.py", line 2410, in name_search return self._name_search(cr, user, name, args, operator, context, limit) File "/home/philip/wsorig/openerp/server/openerp/osv/orm.py", line 2441, in _name_search ids = self._search(cr, user, args, limit=limit, context=context, access_rights_uid=access_rights_uid) File "/home/philip/wsorig/openerp/server/openerp/osv/orm.py", line 4939, in _search cr.execute('SELECT "%s".id FROM ' % self._table + from_clause + where_str + order_by + limit_str + offset_str, where_clause_params) File "/home/philip/wsorig/openerp/server/openerp/sql_db.py", line 161, in wrapper return f(self, *args, **kwargs) File "/home/philip/wsorig/openerp/server/openerp/sql_db.py", line 226, in execute res = self._obj.execute(query, params) ProgrammingError: operator does not exist: numeric ~~* unknown LINE 1: ...bs_price"."id" IS NULL) AND ("abs_price"."name" ilike '%34... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

On 11/16/14, 8:03 AM

"name" is a special field name and must be of type "char".

It cannot be of type float as in your abs.prod.price and abs.price models.

Check https://www.odoo.com/documentation/8.0/reference/orm.html#model-reference "reserved field names" section.

if I change to char I have problem to my function which is calculating the price:

def get_daysales(self, cr, uid, ids, name, arg, context):
res = {}
for daysales in self.browse(cr, uid, ids, context):
res[daysales.id] = daysales.price * 7
return res

on 11/16/14, 8:47 AM

name is a reserved field name, you cannot go against that. Just name it "price_value" for example and modify your function get_daysales to have: res[daysales.id] = daysales.price.price_value * 7

on 11/16/14, 9:06 AM

I don't get what you mean could you please very specific to the above code, what to change and what to remove. thanks for the response

on 11/16/14, 10:04 AM

I want only to directly entered value as float to my price field on to my existing code.

on 11/16/14, 10:11 AM

already tried change the my field name from name to price_value but I got error that's why Im very confuse, I am new from odoo7

on 11/16/14, 10:15 AM

any update here

on 11/19/14, 12:26 PM


on 11/24/14, 10:50 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 11/16/14, 12:26 AM
Seen: 1193 times
Last updated: 3/16/15, 8:10 AM