Odoo Help

Welcome!

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.

0

one2many field - Error [Closed]

By
Selverine
on 12/26/13, 12:48 PM 1,440 views

The Question has been closed

by
Sudhir Arya (SA)
on 01/05/2014 03:27:57

Hi everybody,

I would like to create a one2many field but it don't works. Someone have an idea?

ProgrammingError: operator does not exist: text = integer LINE 1: ...ng = 'fr_BE' AND type = 'model' AND value in (3)) U... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

My code:

class product_bat(osv.osv):
_name = 'product.bat'
_description = 'Product BAT'
_columns = {
    'name': fields.char('Name', size=64, required=False, translate=True),
}

product_bat()

class product_template(osv.osv):
_name = "product.template"
_description = "Product Template"

_columns = {
    'name': fields.char('Name', size=128, required=True, translate=True, select=True),
    'product_manager': fields.many2one('res.users','Product Manager'),
    'description': fields.text('Description',translate=True),
    'product_BAT': fields.one2many('product.bat', 'name', string='product BAT'),


                             <!-- <field name="product_BAT" colspan="4" nolabel="1" height="260">
                            <tree string="product_BAT">
                                    <field name="name"/> 
                            </tree>   
                            <form string="product_BAT" >
                                    <field name="name"/>   
                            </form>          
                        </field> -->
1

Sudhir Arya (SA)

--Sudhir Arya (SA)--
10150
| 6 8 8
Ahmedabad, India
--Sudhir Arya (SA)--

Working as an OpenERP/Odoo developer and a Team Leader 

Top 5 Odoo contributor On Stackoverflow

LinkedIn

Blog

Stackoverflow

Sudhir Arya (SA)
On 12/28/13, 12:31 PM

Whenever you create any one2many field for any object, that object must have many2one of the object in which you are creating one2many field.

For example:

You have object A and object B. Now you want to create one2many field of object A in object B. So you must create many2one field of object B in object A and then give reference of that many2one field in one2many field.


In your case you must create many2one field of object product.template in class product_bat like this:

'product_temp_id': fields.many2one('product.template', 'Template Id'),

and then you can define one2many field like this:

'product_BAT': fields.one2many('product.bat', 'product_temp_id', 'product BAT'),

You have to define the class first in which you have created one2many field.

Hope this will help you.

Hi Sudhir Arya. Thank you for your help. It works and I understand why :-). Just one other thing. I just have the possibility to create a new product_temp_id. Is it possible to have the list of the others that were created before? And choose if I want to create another one or use again an product_temp_id created before? Thanks!

Selverine
on 1/4/14, 11:25 AM
0
Ayyappan
On 12/27/13, 12:30 AM

The problem is because of your code. Use below one:

   class product_template(osv.osv):
       _name = "product.template"
       _description = "Product Template"

       _columns = {
                  'name': fields.char('Name', size=128, required=True, translate=True, select=True),
                  'product_manager': fields.many2one('res.users','Product Manager'),
                  'description': fields.text('Description',translate=True),
                  'product_BAT': fields.one2many('product.bat', 'product_temp_id', 'product BAT'),
       }

    product_template()

    class product_bat(osv.osv):
        _name = 'product.bat'
        _description = 'Product BAT'
        _columns = {
                  'product_temp_id': fields.many2one('product.template', 'Template Id'),
        }

     product_bat()

About This Community

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

Question tools

0 follower(s)

Stats

Asked: 12/26/13, 12:48 PM
Seen: 1440 times
Last updated: 3/16/15, 8:10 AM