diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-11-11 16:10:44 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-11-11 16:10:44 +0700 |
| commit | c8ce7890c7174ea678da282e3fa04501b24951bc (patch) | |
| tree | f007d7bed000bdfa38f64d85af122f1d65b5c565 /indoteknik_custom/models/user_company_request.py | |
| parent | 4c2325d4a983ced3a25a9d53d7613a9186360b17 (diff) | |
| parent | 17d46cf9f4eede8177b2373c03d5b36123f712c1 (diff) | |
Merge branch 'production' into iman/request-renca-stock
Diffstat (limited to 'indoteknik_custom/models/user_company_request.py')
| -rw-r--r-- | indoteknik_custom/models/user_company_request.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/indoteknik_custom/models/user_company_request.py b/indoteknik_custom/models/user_company_request.py index 6d809385..86e66934 100644 --- a/indoteknik_custom/models/user_company_request.py +++ b/indoteknik_custom/models/user_company_request.py @@ -23,24 +23,25 @@ class UserCompanyRequest(models.Model): else: record.similar_company_ids = [(6, 0, [])] - def get_similar_companies(self, user_input): - query = """ - SELECT id - FROM res_partner - WHERE levenshtein(name::text, %s) < 3 - ORDER BY levenshtein(name::text, %s) ASC - """ - self.env.cr.execute(query, (user_input, user_input)) - return [row[0] for row in self.env.cr.fetchall()] + # def get_similar_companies(self, user_input): + # query = """ + # SELECT id + # FROM res_partner + # WHERE levenshtein(name::text, %s) < 3 + # ORDER BY levenshtein(name::text, %s) ASC + # """ + # self.env.cr.execute(query, (user_input, user_input)) + # return [row[0] for row in self.env.cr.fetchall()] def get_similar_companies(self, user_input): query = """ SELECT id FROM res_partner - WHERE name ILIKE %s OR levenshtein(name::text, %s) < 3 + WHERE (name ILIKE %s OR levenshtein(name::text, %s) < 3) + AND active = TRUE AND is_company = TRUE ORDER BY levenshtein(name::text, %s) ASC """ - # Using '%' to match the partial company name + # Menggunakan '%' untuk mencocokkan nama perusahaan sebagian self.env.cr.execute(query, ('%' + user_input + '%', user_input, user_input)) company_ids = [row[0] for row in self.env.cr.fetchall()] return company_ids |
