From 727249b3d858a294f180a081ebe873bcb22c0cc0 Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Thu, 31 Mar 2022 12:05:25 +0000 Subject: [PATCH] [IMP] survey: propagates name to title field with relational widget PURPOSE Currently, when creating a survey through the 'quick create' feature of a many2one field, the name input by the user is lost and not propagated to the survey title (the default behavior expects a 'name' field). This commit correctly takes the passed default_name into account and uses it to fill the survey title. LINKS Task-2810395 Part-of: odoo/odoo#87672 --- addons/survey/models/survey_survey.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/survey/models/survey_survey.py b/addons/survey/models/survey_survey.py index 6d0eefdf101..19df1658a1c 100644 --- a/addons/survey/models/survey_survey.py +++ b/addons/survey/models/survey_survey.py @@ -45,6 +45,15 @@ class Survey(models.Model): return False # could not generate a code + @api.model + def default_get(self, fields_list): + result = super().default_get(fields_list) + # allows to propagate the text one write in a many2one widget after + # clicking on 'Create and Edit...' to the popup form. + if 'title' in fields_list and not result.get('title') and self.env.context.get('default_name'): + result['title'] = self.env.context.get('default_name') + return result + # description title = fields.Char('Survey Title', required=True, translate=True) color = fields.Integer('Color Index', default=0)