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.
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
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
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.