Odoo Help

Welcome!

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.

0

syntax of creating one2many field

By
sneha antony
on 3/4/14, 4:06 AM 2,294 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.

0

Nehal

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

Hi,

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'),
}

order_line()

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.

Nehal
on 3/4/14, 5:49 AM
0
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

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)

Stats

Asked: 3/4/14, 4:06 AM
Seen: 2294 times
Last updated: 3/16/15, 8:10 AM