Skip to content

Commit e24b92f

Browse files
[IMP] partner_identification*: move _search_duplicate
1 parent 79253c0 commit e24b92f

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

partner_identification/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{
1010
"name": "Partner Identification Numbers",
1111
"category": "Customer Relationship Management",
12-
"version": "16.0.1.0.2",
12+
"version": "16.0.1.0.3",
1313
"license": "AGPL-3",
1414
"depends": ["contacts"],
1515
"data": [

partner_identification/models/res_partner_id_category.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from random import randint
1212

13-
from odoo import _, fields, models
13+
from odoo import _, api, fields, models
1414
from odoo.exceptions import UserError, ValidationError
1515
from odoo.tools.safe_eval import safe_eval
1616

@@ -40,6 +40,20 @@ def _get_default_color(self):
4040
"Python validation code", help="Python code called to validate an id number."
4141
)
4242

43+
@api.model
44+
def _search_duplicate(self, category_id, id_number, force_active=False):
45+
"""Find duplicates for the given category and number."""
46+
domain = [
47+
("category_id", "=", category_id),
48+
("name", "=", id_number.name),
49+
("name", "!=", False),
50+
("id", "!=", id_number.id),
51+
]
52+
53+
if force_active:
54+
domain.append(("partner_id.active", "=", True))
55+
return self.env["res.partner.id_number"].search(domain)
56+
4357
def _validation_eval_context(self, id_number):
4458
self.ensure_one()
4559
return {"self": self, "id_number": id_number}

partner_identification_gln/__manifest__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"summary": """
66
This addon extends "Partner Identification Numbers"
77
to provide a number category for GLN registration""",
8-
"version": "16.0.1.0.0",
8+
"version": "16.0.1.0.1",
99
"license": "AGPL-3",
1010
"author": "Acsone S.A.,Odoo Community Association (OCA)",
1111
"website": "https://github.com/OCA/partner-contact",

partner_identification_gln/models/res_partner_id_category.py

+1-14
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import logging
55

6-
from odoo import api, models
6+
from odoo import models
77

88
_logger = logging.getLogger(__name__)
99

@@ -17,19 +17,6 @@
1717
class ResPartnerIdCategory(models.Model):
1818
_inherit = "res.partner.id_category"
1919

20-
@api.model
21-
def _search_duplicate(self, category_id, id_number, force_active=False):
22-
domain = [
23-
("category_id", "=", category_id),
24-
("name", "=", id_number.name),
25-
("name", "!=", False),
26-
("id", "!=", id_number.id),
27-
]
28-
29-
if force_active:
30-
domain.append(("partner_id.active", "=", True))
31-
return self.env["res.partner.id_number"].search(domain)
32-
3320
def validate_res_partner_gln(self, id_number):
3421
self.ensure_one()
3522
if not id_number:

0 commit comments

Comments
 (0)