Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
29156 Zobrazení

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.

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Autor

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

Autor

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.

Nejlepší odpověď

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.

Avatar
Zrušit
Autor

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?

Autor

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.

Related Posts Odpovědi Zobrazení Aktivita
0
dub 17
4658
1
úno 19
3834
1
led 19
9571
0
úno 16
3848
1
led 25
1647