From 2c62d1bc22403cae353a40647ca32216a3340eb4 Mon Sep 17 00:00:00 2001 From: Swapnesh Shah Date: Fri, 22 May 2020 09:19:05 +0000 Subject: [PATCH] [FIX] base: Wrong 'default_type' on create kanban stage grouped by 'Customer' Issue Step done with "CRM" since main kanban view can be grouped by 'res.partner' model: - Install "CRM" app - Go to crm and group by "Customer". - Add a Column. Traceback is raised. Cause Wrong "default_type" in context ('opportunity' in this case) when creating new kanban stage and grouped by "Customer". Solution On "default_get" for "res.partner", if "default_type" is in context and not in 'type' selection choices field; then remove it from context. Cherry-pick of #47723 in 12.0 opw-2256905 closes odoo/odoo#52282 X-original-commit: e5796429c8adcbb929cb032cdfd2cbaba835b086 Signed-off-by: Nicolas Martinelli (nim) --- odoo/addons/base/models/res_partner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py index d4228c69c55..c00fc787542 100644 --- a/odoo/addons/base/models/res_partner.py +++ b/odoo/addons/base/models/res_partner.py @@ -714,6 +714,11 @@ class Partner(models.Model): If only an email address is received and that the regex cannot find a name, the name will have the email value. If 'force_email' key in context: must find the email address. """ + default_type = self._context.get('default_type') + if default_type and default_type not in self._fields['type'].selection: + context = dict(self._context) + context.pop('default_type') + self = self.with_context(context) name, email = self._parse_partner_name(name) if self._context.get('force_email') and not email: raise UserError(_("Couldn't create contact without email address!"))