From feb07b02e4739f5d27adce56e15991e705a3f09a Mon Sep 17 00:00:00 2001
From: "Nasreddin (bon)" <bon@odoo.com>
Date: Wed, 3 Jun 2020 08:29:50 +0000
Subject: [PATCH] [FIX] base: Fix condition on selection field always
 evaluating to True

Part/Fix of commit #e579642

Issue

	The condition `default_type not in self._fields['type'].selection`
	always evaluate to True as the selection is list of (key, value)
	tuples.

Solution

	Replace the tuples by a list of possible values.

opw-2256905

closes odoo/odoo#52501

X-original-commit: 1b21c674c6de3ef96d7938c3e99b36d7cb2f2b6e
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
---
 odoo/addons/base/models/res_partner.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/odoo/addons/base/models/res_partner.py b/odoo/addons/base/models/res_partner.py
index c00fc787542e..6d3e86839b7e 100644
--- a/odoo/addons/base/models/res_partner.py
+++ b/odoo/addons/base/models/res_partner.py
@@ -715,7 +715,7 @@ class Partner(models.Model):
             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:
+        if default_type and default_type not in self._fields['type'].get_values(self.env):
             context = dict(self._context)
             context.pop('default_type')
             self = self.with_context(context)
-- 
GitLab