In Odoo v17, 'the _compute_display_name' method is used to compute the 'display_name' field. If you want to include the overridden value of 'name' in the 'display_name', you can modify the '_compute_display_name' method accordingly.
Here’s an example of how you might override the '_compute_display_name' method:
from odoo import api, fields, models
class YourModel(models.Model):
_inherit = 'your.model' # replace with your model name
display_name = fields.Char(compute='_compute_display_name')
@api.depends('name', 'parent_id.name') # depends on the fields that make up your name
def _compute_display_name(self):
for record in self:
names = [record.parent_id.name, record.name] # adjust this line based on your needs
record.display_name = ' / '.join(filter(None, names))
In this example, 'display_name' is computed based on the 'name' field and the 'name' field of the 'parent_id'. You should adjust the 'names' list based on your needs.
Remember to replace 'your.model' with the actual name of your model and adjust the '@api.depends' decorator and the names list according to your requirements. The 'filter(None, names)' part is used to remove any 'None' values from the 'names' list before joining them.
This should ensure that the overridden value of 'name' is included in the 'display_name' and thus in the default email sent when assigning an object to a user. Please test this solution thoroughly to ensure it works as expected in your specific use case. If you encounter any issues, feel free to ask for further assistance.
Regards,
Maciej Burzymowski