This question has been flagged
3 Replies
6277 Views

customer.order

fields :

customer_id : integer(customer id)

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

customer.order.line

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.

Avatar
Discard

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

Best Answer

Hi,

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-->
    <tree>
        <field name="order_id"/>
    </tree>
</field>
Avatar
Discard

Thanks i got my answer.