Skip to content

Commit

Permalink
[FIX] partner_identification: Infinite loop in search (OCA#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasley authored and pedrobaeza committed Jun 8, 2017
1 parent 2bc688e commit fa9b390
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion partner_identification/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
Expand Down
20 changes: 11 additions & 9 deletions partner_identification/models/res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _compute_identification(self, field_name, category_code):
'social_security', 'SSN',
),
search=lambda s, *a: s._search_identification(
'social_security', 'SSN', *a
'SSN', *a
),
)
Expand Down Expand Up @@ -86,7 +86,7 @@ def _inverse_identification(self, field_name, category_code):
'social_security', 'SSN',
),
search=lambda s, *a: s._search_identification(
'social_security', 'SSN', *a
'SSN', *a
),
)
Expand Down Expand Up @@ -136,8 +136,7 @@ def _inverse_identification(self, field_name, category_code):
))

@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:
Expand All @@ -152,19 +151,22 @@ def _search_identification(self, field_name, category_code,
'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),
]
2 changes: 1 addition & 1 deletion partner_identification/tests/test_res_partner.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ResPartner(models.Model):
'social_security', 'SSN',
),
search=lambda s, *a: s._search_identification(
'social_security', 'SSN', *a
'SSN', *a
),
)

Expand Down

0 comments on commit fa9b390

Please sign in to comment.