Current state: custom CSS + vanilla Vue components Architecture: modular with composables, provide/inject pattern Ready for progressive migration to Quasar native components Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import frappe, os
|
|
os.chdir('/home/frappe/frappe-bench')
|
|
frappe.init('frontend', sites_path='/home/frappe/frappe-bench/sites')
|
|
frappe.connect()
|
|
|
|
ss = frappe.get_doc('Server Script', 'Address Autocomplete')
|
|
ss.script = """
|
|
query = frappe.form_dict.get("q", "")
|
|
if not query or len(query) < 3:
|
|
frappe.response["results"] = []
|
|
else:
|
|
words = query.strip().split()
|
|
conditions = []
|
|
params = {}
|
|
for i, w in enumerate(words):
|
|
key = "w" + str(i)
|
|
conditions.append("f_unaccent(address_full) ILIKE f_unaccent(%({})s)".format(key))
|
|
params[key] = "%" + w + "%"
|
|
|
|
where = " AND ".join(conditions)
|
|
|
|
results = frappe.db.sql(
|
|
"SELECT address_full, ville, code_postal, latitude, longitude "
|
|
"FROM rqa_addresses "
|
|
"WHERE " + where + " "
|
|
"ORDER BY "
|
|
"CASE WHEN code_postal LIKE 'J0L%%' THEN 0 WHEN code_postal LIKE 'J0S%%' THEN 1 ELSE 2 END, "
|
|
"length(address_full) "
|
|
"LIMIT 10",
|
|
params, as_dict=True)
|
|
|
|
frappe.response["results"] = results
|
|
"""
|
|
ss.save(ignore_permissions=True)
|
|
frappe.db.commit()
|
|
print('Fixed: AND-based word search')
|
|
frappe.destroy()
|