Inheritance is used to add or replace a field into a particular view in odoo. Inheritance specs are comprised of an element locator, to match the inherited element in the parent view, and the children element that will be used to modify the inherited element.
There are three types of element locators for matching a target element:
- An xpath element with an expr attribute. expr is an XPath expression applied to the current arch, the first node it finds is the match.
- a field element with a name attribute matches the first field with the same name. All other attributes are ignored during matching.
- Any other element: the first element with the same name and identical attributes (ignoring position and version attributes) is matched.
1. How to Replace Field
in Tree View Odoo 15
www.cybrosys.com
2. INTRODUCTION
Inheritance is used to add or replace a field into a particular view in odoo. Inheritance specs are
comprised of an element locator, to match the inherited element in the parent view, and the
children element that will be used to modify the inherited element. There are three types of
element locators for matching a target element:
An xpath element with an expr attribute. expr is an XPath expression applied to the current
arch, the first node it finds is the match.
A field element with a name attribute, matches the first field with the same name. All other
attributes are ignored during matching.
Any other element: the first element with the same name and identical attributes (ignoring
position and version attributes) is matched.
3. ❖ Here we have a date field, We have to replace the date field with a date time field.
4. ❖ For that let’s going to the pycharm, we have to inherit the field in the ‘sale.order’ model.
5. ❖ Then, let us replace the ‘expected_date’ field in the tree view. So that we have to create the
view form. First we have to replace the ‘expected_date’ in the form view.
6. ❖ In the xml view the ‘inherited_id’ is the ‘external_id’ of the model, So that Open a sale order >
Debug Button > Edit: View Form > External ID
7. ❖ After Upgrading the module, Let’s check the field in the ‘sale.order model. Here you can see
the Field is updated into ‘valid_date’.
8. ❖ Then we have to replace this field in the tree view, for that let’s create the view.
9. ❖ In the xml view the ‘inherited_id’ is the ‘external_id’ of the model, So that Open a sale order
tree > Debug Button > Edit: View Form > External ID
10. ❖ After Upgrading the module, Let’s check the field in the ‘sale.order model. Here you can see
the Field is updated into ‘valid_date’.
11. ❖ Then we have to provide a date in the replaced field.
12. ❖ After check the tree view, we have to see the field is changed here.
13. For More
Details
Check our company website for related blogs and Odoo
book.
Odoo Book V15
Check our YouTube channel for functional and technical
videos in Odoo.
How to Replace Field in Tree View Odoo 15