From f9cd4ff2137a909d54d18fe5b3f7cce2fdab7f86 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Thu, 8 Jun 2017 04:03:31 -0700 Subject: [PATCH] [FIX] partner_identification: Infinite loop in search (#436) --- partner_identification/__openerp__.py | 2 +- partner_identification/models/res_partner.py | 20 ++++++++++--------- .../tests/test_res_partner.py | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/partner_identification/__openerp__.py b/partner_identification/__openerp__.py index 9567bc487..e54d2c0aa 100644 --- a/partner_identification/__openerp__.py +++ b/partner_identification/__openerp__.py @@ -11,7 +11,7 @@ { 'name': 'Partner Identification Numbers', 'category': 'Customer Relationship Management', - 'version': '10.0.1.1.0', + 'version': '10.0.1.1.1', 'depends': [ 'sales_team', ], diff --git a/partner_identification/models/res_partner.py b/partner_identification/models/res_partner.py index d4dcf2086..0c56f3b7a 100644 --- a/partner_identification/models/res_partner.py +++ b/partner_identification/models/res_partner.py @@ -44,7 +44,7 @@ class ResPartner(models.Model): 'social_security', 'SSN', ), search=lambda s, *a: s._search_identification( - 'social_security', 'SSN', *a + 'SSN', *a ), ) @@ -86,7 +86,7 @@ class ResPartner(models.Model): 'social_security', 'SSN', ), search=lambda s, *a: s._search_identification( - 'social_security', 'SSN', *a + 'SSN', *a ), ) @@ -136,8 +136,7 @@ class ResPartner(models.Model): )) @api.model - def _search_identification(self, field_name, category_code, - operator, value): + def _search_identification(self, category_code, operator, value): """ Search method for an identification field. Example: @@ -152,19 +151,22 @@ class ResPartner(models.Model): 'social_security', 'SSN', ), search=lambda s, *a: s._search_identification( - 'social_security', 'SSN', *a + 'SSN', *a ), ) Args: - field_name (str): Name of field to set. category_code (str): Category code of the Identification type. + operator (str): Operator of domain. + value (str): Value to search for. Returns: list: Domain to search with. """ - - return [ - (field_name, operator, value), + id_numbers = self.env['res.partner.id_number'].search([ + ('name', operator, value), ('category_id.code', '=', category_code), + ]) + return [ + ('id_numbers.id', 'in', id_numbers.ids), ] diff --git a/partner_identification/tests/test_res_partner.py b/partner_identification/tests/test_res_partner.py index 15e455f57..c06670b8d 100644 --- a/partner_identification/tests/test_res_partner.py +++ b/partner_identification/tests/test_res_partner.py @@ -18,7 +18,7 @@ class ResPartner(models.Model): 'social_security', 'SSN', ), search=lambda s, *a: s._search_identification( - 'social_security', 'SSN', *a + 'SSN', *a ), )