Merge branch 'master' into develop
This commit is contained in:
commit
0a8664c3b7
2 changed files with 5 additions and 9 deletions
|
|
@ -14,7 +14,7 @@ import os, sys, importlib, inspect, json
|
|||
from .exceptions import *
|
||||
from .utils.jinja import get_jenv, get_template, render_template, get_email_from_template
|
||||
|
||||
__version__ = '10.0.17'
|
||||
__version__ = '10.0.18'
|
||||
__title__ = "Frappe Framework"
|
||||
|
||||
local = Local()
|
||||
|
|
|
|||
|
|
@ -202,17 +202,13 @@ def _set_amended_name(doc):
|
|||
def append_number_if_name_exists(doctype, value, fieldname='name', separator='-'):
|
||||
exists = frappe.db.exists(doctype,
|
||||
value if fieldname == 'name' else {fieldname: value})
|
||||
|
||||
|
||||
regex = '^{value}{separator}[[:digit:]]+'.format(value=re.escape(value), separator=separator)
|
||||
if exists:
|
||||
# should be escaped 2 times since
|
||||
# python string will parse the first escape
|
||||
escaped_value = re.escape(re.escape(value))
|
||||
|
||||
last = frappe.db.sql("""select {fieldname} from `tab{doctype}`
|
||||
where {fieldname} regexp '^{value}{separator}[[:digit:]]+'
|
||||
where {fieldname} regexp %s
|
||||
order by length({fieldname}) desc,
|
||||
{fieldname} desc limit 1""".format(doctype=doctype,
|
||||
value=escaped_value, fieldname=fieldname, separator=separator))
|
||||
{fieldname} desc limit 1""".format(doctype=doctype, fieldname=fieldname), regex)
|
||||
|
||||
if last:
|
||||
count = str(cint(last[0][0].rsplit(separator, 1)[1]) + 1)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue