Odoo Help

0

one2many field - Error [Closed]

By
Selverine
on 12/26/13, 12:48 PM 2,215 views

The Question has been closed

by
Sudhir Arya (ERP Harbor Consulting Services)
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 (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11584
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
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 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.

Register

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)

Stats

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