From 48f796f4d30dee2db6c584ec08f4a60e4d4f2c41 Mon Sep 17 00:00:00 2001 From: Ethan Vincent Date: Wed, 13 Mar 2024 09:57:22 +0100 Subject: [PATCH] [FIX] product: set disp. name to New if creating **Current behavior:** When creating a new product template record, the tab title will be *Odoo - False* until a new name is saved rather than *Odoo - New*. **Expected behavior:** When creating a new record in a form view, the tab title will be *Odoo - New* until the `name` field is filled out and the record gets saved (at which point it will be *Odoo - *). **Steps to reproduce:** 1. Install `sale_management` and go to the product list view 2. Create a new product, observe the misnamed tab title **Cause of the issue:** In `product.template`'s _compute_display_name() method, some of the default values can have a 'False' (str) value which will evaluate to True (bool), setting the name to 'False'. **Fix:** Set the display_name field to a False (bool) value if the current record does not have a name field set. opw-3793588 closes odoo/odoo#157258 Signed-off-by: Morgane Demesmaeker --- addons/product/models/product_template.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py index 2efd62e23d8..2153e0928cc 100644 --- a/addons/product/models/product_template.py +++ b/addons/product/models/product_template.py @@ -519,7 +519,10 @@ class ProductTemplate(models.Model): @api.depends('name', 'default_code') def _compute_display_name(self): for template in self: - template.display_name = '{}{}'.format(template.default_code and '[%s] ' % template.default_code or '', template.name) + template.display_name = False if not template.name else ( + '{}{}'.format( + template.default_code and '[%s] ' % template.default_code or '', template.name + )) @api.model def _name_search(self, name, domain=None, operator='ilike', limit=None, order=None):