Przeglądaj źródła

Merge pull request #4811 from netchampfaris/hotfix-naming-escape

Hotfix naming escape
version-14
Prateeksha Singh 7 lat temu
committed by GitHub
rodzic
commit
851e3aa393
Nie znaleziono w bazie danych klucza dla tego podpisu ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 4 dodań i 1 usunięć
  1. +4
    -1
      frappe/model/naming.py

+ 4
- 1
frappe/model/naming.py Wyświetl plik

@@ -199,11 +199,14 @@ def _set_amended_name(doc):

def append_number_if_name_exists(doctype, name, fieldname='name', separator='-'):
if frappe.db.exists(doctype, name):
# should be escaped 2 times since
# python string will parse the first escape
escaped_name = re.escape(re.escape(name))
last = frappe.db.sql("""select name from `tab{doctype}`
where {fieldname} regexp '^{name}{separator}[[:digit:]]+'
order by length({fieldname}) desc,
{fieldname} desc limit 1""".format(doctype=doctype,
name=name, fieldname=fieldname, separator=separator))
name=escaped_name, fieldname=fieldname, separator=separator))

if last:
count = str(cint(last[0][0].rsplit("-", 1)[1]) + 1)


Ładowanie…
Anuluj
Zapisz