콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

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.

아바타
취소
베스트 답변

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.

작성자

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.

베스트 답변

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?

작성자

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!')

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

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

관련 게시물 답글 화면 활동
0
4월 17
4806
1
2월 19
3931
1
1월 19
9722
0
2월 16
3946
1
1월 25
1828