Saturday, September 20, 2025
1 change · 18.0
New functionality added to Odoo
This change adds a safer way for developers to extend existing view settings without replacing them entirely. It reduces the risk of accidental configuration loss when adapting screens, helping customizations remain more reliable during upgrades and maintenance.
Original PR description
This commit introduces a new `merge` attribute to the `<attribute>` tag, allowing developers to safely merge existing dictionary-based or list-based attributes in XML view inheritance. Problem:…
This commit introduces a new `merge` attribute to the `<attribute>` tag, allowing developers to safely merge existing dictionary-based or list-based attributes in XML view inheritance.
Problem:
Currently, when a developer needs to extend an attribute like `options` or `domain` in an inherited view, they must completely redefine the attribute, which can lead to unintended overwrites of properties set in the base view. For example, to add a new option, one must copy all existing options, which is tedious and brittle.
Solution:
The new `merge` attribute provides a declarative way to extend these attributes. When specified on an `<attribute>` tag, it intelligently merges its value with the existing attribute value on the target node. For dictionary-based attributes like `options`, it performs a dictionary update. For list-based attributes like `domain`, it extends the list.
Usage Example:
Given an existing field with a base `options` attribute: `<field name="supplier_id" options="{'no_open': 1, 'no_create': 1}"/>`
A developer can now extend this in an inherited view without overwriting: `<attribute name="options" merge="{'list_view_ref':'cm_product.cm_product_supplierinfo_tree_view'}"/>`
The result will be a combined `options` attribute: `options="{'no_open': 1, 'no_create': 1, 'list_view_ref': 'cm_product.cm_product_supplierinfo_tree_view'}"`
Description of the issue/feature this PR addresses:
Current behavior before PR:
Desired behavior after PR is merged:
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr