Odoo Help


Is the python code correct?but it shows type cast error

on 9/6/13, 5:15 AM 2,423 views


fields :

customer_id : integer(customer id)

oderline_ids : one2many(customer.order.line,order_id)


fields :

order_id : integer(order id)

product_id: many2one(product.product)

quantity : float

Error:ProgrammingError: operator does not exist: text = integer

No operator matches the given name and argument type(s). You might need to add explicit type casts.

How to solve it?

i want to work this module like product (sale order line) in sale order.

You have to change the type of order_id to many2one, because when we are trying to create a one2many fields we have to give an inverse relationship on the table in which the first table is pointing to. Thanks

Abhishek H Menon
on 9/6/13, 8:33 AM


You should begin to read the memento of OpenERP:
In the sale order line, the field is a one2many, the one2many must be linked at a many2one.

class Order(osv.Model):
    _name = 'model.order'
    _columns = {
        'line_ids': fields.one2many(
            'model.order.line',  # the OrderLine._name
            'order_id',  # the many2one linked with this one2many on the order line
            'Order line'),  # Label of the field

# WARNING the class with the one2many must be define before
# the class with the many2one
class OrderLine(osv.Model):
    _name = 'model.order.line'
    _columns = {
        'order_id': fields.many2one(
            'model.order',  # the Order._name 
            'Order'),  # The label of the field

Warning, in the xml, you mustn't put the many2one field in the one2many field view, because the field won't be filled. If you need this field then make the view like that:

<field name="line_ids" context="{'default_order_id': active_id}">
    <!-- the default_ (field) in the context replace the _default = {} of the model-->
        <field name="order_id"/>

Thanks i got my answer.

on 9/6/13, 8:00 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: 9/6/13, 5:15 AM
Seen: 2423 times
Last updated: 3/27/15, 6:37 PM