Hello I am using odoo v.13. I only know how to add new label using fields_view_get but I don't know how to add new fields. Anyone can guide me? or can you show me how to do it? thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Účetnictví
- Sklad
- PoS
- Project
- MRP
This question has been flagged
1
Odpovědět
3457
Zobrazení
Hi,
Try this,
def fields_view_get(self, view_id=None, view_type='form', toolbar=False,
submenu=False):
result = super(ClassName, self).fields_view_get(view_id=view_id,
view_type=view_type,
toolbar=toolbar,
submenu=submenu)
all_fields = {}
xml_form = etree.Element('form', {'string': tools.ustr('Test')})
all_fields['new_field_name'] = {
'type': 'many2one',
'string': 'String For Field',
'relation': 'co_model_name',
}
etree.SubElement(xml_group, 'field', {
'name': 'new_field_name',
'nolabel': '0',
'colspan': '4',
'options': "{'no_create': True, 'no_open':True}",
})
root = xml_form.getroottree()
result['arch'] = etree.tostring(root)
result['fields'] = all_fields
return result
Thanks
Hello I am trying to use your given code and it works but there's a problem. The view is destroyed. What do I put in xml_group is this the xml_id of the form view? but when I put the xml_id of the form view I encountered an error.
and also I replace the test inside tools.ustr with my form view id. Is it right? Sorry I am new ind lxml and odoo.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit seRelated Posts | Odpovědi | Zobrazení | Aktivita | |
---|---|---|---|---|
|
4
kvě 24
|
12267 | ||
|
1
dub 24
|
2962 | ||
|
0
lis 23
|
1821 | ||
|
1
zář 23
|
1888 | ||
|
2
srp 23
|
4201 |