[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 - <name>*). **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 <edm@odoo.com>
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user