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.


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

on 9/6/13, 5:15 AM 1,567 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

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

0 follower(s)


Asked: 9/6/13, 5:15 AM
Seen: 1567 times
Last updated: 3/27/15, 6:37 PM