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>
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