Odoo Help


syntax of creating one2many field

sneha antony
on 3/4/14, 4:06 AM 3,736 views

I want a grid in my form.So I am planning to use one2many field for the grid.But i cant understand How to create a one2many field for my requirement.The form contains certain customer details and the grid columns are date and status,having nothing to do with the form above.In this situation how can I create a one2many field ?What should be the "Object Relation" and the "Relation Field" when I create a one2many field for 2 columns date and status?Anybody please guide through a proper way so that I may correct my mistakes soon.




| 5 2 8
Ahmadabad, India
On 3/4/14, 4:32 AM


Refer the following example if it may help you:

class order(osv.osv): _description = "Orders" _name = "order.order"
_columns = {
'line_ids': fields.one2many('order.line','ordr_id',"Order Lines"), } order()

class order_line(osv.osv): _description = "Order Line" _name = "order.line"

_columns = {
    'ordr_id': fields.many2one('order.order', 'Order ID'),


If you are creating one2many field related to object2, object2 should have many2one field which is used in one2many field relation.

but according to my requirement I am creating a field which dont have any relation with any other components.In this case how to find the object 2?

sneha antony
on 3/4/14, 4:38 AM

i tried the code you provided.But there occured an error as raise except_orm('ValidateError', '\n'.join(error_msgs)) except_orm: ('ValidateError', u'Error occurred while validating the field(s) arch: Invalid XML for View Architecture!')

sneha antony
on 3/4/14, 4:51 AM

this problem occuring from ml file please check your xml file.

Krupesh Laiya
on 3/4/14, 5:47 AM

This error is due to invalid XML file. You can view the log file and there you can see the root of error.

on 3/4/14, 5:49 AM
Krupesh Laiya
On 3/4/14, 4:14 AM

first you must have to give many2one relation ship in source object (table)

    'fieldname_ids': fields.one2many('ObjectName', 'fieldname_id', 'Label', help='Help note'),

syntax is as above:

Object name : give model name or table name

fieldname_id : give many2one filed name of Object Name

Lable: lable to display

or visit following link

Fields details

I am havng doubt with the 'ObjectName', 'fieldname_id'.Yet not that clear with it.

sneha antony
on 3/4/14, 4:23 AM

Can you please suggest the code changes to be made in my .py and .xml file.I have been struggling with this issue for the past 2 days.

sneha antony
on 3/4/14, 4:26 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: 3/4/14, 4:06 AM
Seen: 3736 times
Last updated: 3/16/15, 8:10 AM