[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) <nim@odoo.com>
This commit is contained in:
Swapnesh Shah
2020-06-02 16:13:30 +00:00
committed by Nasreddin (bon)
parent 7630ef3388
commit 2c62d1bc22
+5
View File
@@ -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!"))