The string or label of a field cannot be dynamically changed from XML in Odoo at this time. To change the label of a field dynamically, we have to use some Python code. Within Odoo 18, we utilize the get_views() function to run Python code when a form view loads. The field_view_get() method was used in previous versions (before Odoo 16) for this purpose.
Introduced in Odoo 16 and improved upon in Odoo 18, the get_views() method is a potent tool. Whether it's a form, tree, kanban, or any other kind of view, its purpose is to assist developers in dynamically customizing views according to particular criteria.
When a model's views are loaded, the get_views() method is called. To add custom Python logic and dynamically change the view depending on specific criteria, you can override this function in your model.
You may take advantage of Odoo's best design and make the user experience more natural and context-sensitive by overriding get_views().
The get_view() function dynamically modifies views by adding particular logic or changing their structure.
Advantages of get_view() over the field_view_get()
a) We can access multiple views by using a single function. Eg: Form, Tree, Kanban, or any other views simultaneously.
b) This makes it possible to customize views based on departments, user roles, or custom fields, enabling more extensive customization.
c) get_views() enhances performance, particularly when handling large datasets, by minimizing redundant server calls and providing greater flexibility in view rendering.
Let's now examine how the field label or string can be dynamically changed using the _get_view method.
Think about this: we have two businesses, and we need to modify the label for a field in the "stock.picking" model according to each business.
According to the active firm, we wish to modify the label of the "Source Document" field in this case. When "My Company B" is the active firm, the field label changes to "Doc Number," and when "My Company A" is the active company, the label changes to "Order Reference."
Let's see how it is possible.

First, we wish to inherit the "stock.picking" model in order to accomplish the aforementioned goal. The _get_view() method must be called in order to access the field "Source Document" in "stock.picking" every time the form view is loaded.
from odoo import api, models
class StockPicking(models.Model):
_inherit = 'stock.picking'
@api.model
def _get_view(self, view_id=None, view_type='form', **options):
arch, view = super()._get_view(view_id, view_type, **options)
active_company = self.env.company
if view_type == 'form' and active_company.name == 'My Company B':
for node in arch.xpath("//field[@name='origin']"):
node.set('string', 'Doc Number')
if view_type == 'form' and active_company.name == 'My Company A':
for node in arch.xpath("//field[@name='origin']"):
node.set('string', 'Order Reference')
return arch, view
Here _get_view() method is overridden to manipulate the form view XML dynamically before it is rendered.
arch, view = super()._get_view(...) gets the XML view definition (arch) and the view record (view).
arch is an XML tree (parsed), allowing XPath operations.
If the view is a form and the active company is "My Company B", it finds the <field name="origin"> in the XML and sets its label (string) to "Doc Number".

If the view is a form and the active company is "My Company A", it finds the <field name="origin"> in the XML and sets its label (string) to "Order Reference".

When you reload the page, you can see that the string in Company A has changed to Order Reference, but the string in Company B has remained unchanged.
Here's how you use the _get_view method to dynamically update the field's label or string.
To read more about How to Dynamically Change the String of a Field Using _get_view in Odoo 17, refer to our blog How to Dynamically Change the String of a Field Using _get_view in Odoo 17.