[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
This commit is contained in:
Patrick Hoste
2022-04-20 16:41:02 +02:00
parent d541cef5b5
commit 727249b3d8
+9
View File
@@ -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)