Merge pull request #2907 from rmehta/refactor-naming

[minor] refactor naming.py
This commit is contained in:
Nabin Hait 2017-03-21 19:21:25 +01:00 committed by GitHub
commit fefdfd6fdc
2 changed files with 8 additions and 8 deletions

View file

@ -187,20 +187,20 @@ def _set_amended_name(doc):
doc.name = am_prefix + '-' + str(am_id)
return doc.name
def append_number_if_name_exists(doc):
if frappe.db.exists(doc.doctype, doc.name):
def append_number_if_name_exists(doctype, name):
if frappe.db.exists(doctype, name):
last = frappe.db.sql("""select name from `tab{}`
where name regexp '^{}-[[:digit:]]+'
order by length(name) desc, name desc limit 1""".format(doc.doctype, doc.name))
order by length(name) desc, name desc limit 1""".format(doctype, name))
if last:
count = str(cint(last[0][0].rsplit("-", 1)[1]) + 1)
else:
count = "1"
doc.name = "{0}-{1}".format(doc.name, count)
name = "{0}-{1}".format(name, count)
return doc
return name
def de_duplicate(doctype, name):
original_name = name

View file

@ -91,7 +91,7 @@ frappe.ui.form.Toolbar = Class.extend({
set_indicator: function() {
if(this.frm.save_disabled)
return;
var indicator = frappe.get_indicator(this.frm.doc);
if(indicator) {
this.page.set_indicator(indicator[0], indicator[1]);
@ -173,13 +173,13 @@ frappe.ui.form.Toolbar = Class.extend({
}, true);
}
}
// feedback
if(!this.frm.doc.__unsaved) {
if(is_submittable && docstatus != 1)
return
this.page.add_menu_item(__("Ask a Feedback"), function() {
this.page.add_menu_item(__("Request Feedback"), function() {
feedback = new frappe.utils.Feedback();
feedback.manual_feedback_request(me.frm.doc);
}, true)