requested changes implemented

This commit is contained in:
Rucha Mahabal 2019-07-10 11:11:03 +05:30
parent f1d413d9c8
commit 73df6d2887
5 changed files with 7 additions and 7 deletions

View file

@ -532,7 +532,7 @@ class DocType(Document):
def make_repeatable(self):
"""If allow_auto_repeat is set, add auto_repeat custom field."""
if self.allow_auto_repeat:
if not frappe.db.sql("SELECT `fieldname` FROM `tabCustom Field` WHERE `fieldname`='auto_repeat' and `dt`=%s",self.name):
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat', 'dt': self.name}):
insert_after = self.fields[len(self.fields) - 1].fieldname
df = dict(fieldname='auto_repeat', label='Auto Repeat', fieldtype='Link', options='Auto Repeat', insert_after=insert_after, read_only=1, no_copy=1, print_hide=1)
create_custom_field(self.name, df)

View file

@ -113,7 +113,7 @@ class CustomizeForm(Document):
#If allow_auto_repeat is set, add auto_repeat custom field.
if self.allow_auto_repeat:
if not frappe.db.sql("SELECT `fieldname` FROM `tabCustom Field` WHERE `fieldname`='auto_repeat' and `dt`=%s",self.doc_type):
if not frappe.db.exists('Custom Field', {'fieldname': 'auto_repeat', 'dt': self.doc_type}):
insert_after = self.fields[len(self.fields) - 1].fieldname
df = dict(fieldname='auto_repeat', label='Auto Repeat', fieldtype='Link', options='Auto Repeat', insert_after=insert_after, read_only=1, no_copy=1, print_hide=1)
create_custom_field(self.doc_type, df)

View file

@ -29,7 +29,7 @@ frappe.ui.form.on('Auto Repeat', {
refresh: function(frm) {
//if document is not saved do not show schedule and document link
if(!frm.doc.__unsaved) {
if (!frm.is_dirty()) {
let label = __('View {0}', [__(frm.doc.reference_doctype)]);
frm.add_custom_button(__(label),
function() {

View file

@ -89,8 +89,8 @@ frappe.ui.form.Sidebar = Class.extend({
}
},
show_auto_repeat_status: function(){
if(this.frm.meta.allow_auto_repeat && this.frm.doc.auto_repeat){
show_auto_repeat_status: function() {
if (this.frm.meta.allow_auto_repeat && this.frm.doc.auto_repeat) {
const me = this;
frappe.call({
method: "frappe.client.get_value",
@ -101,7 +101,7 @@ frappe.ui.form.Sidebar = Class.extend({
},
fieldname: ["frequency"]
},
callback: function(res){
callback: function(res) {
me.sidebar.find(".auto-repeat-status").html(__("Repeats {0}", [res.message.frequency]));
me.sidebar.find(".auto-repeat-status").on("click", function(){
frappe.set_route("Form", "Auto Repeat", me.frm.doc.auto_repeat);

View file

@ -202,7 +202,7 @@ frappe.ui.form.Toolbar = Class.extend({
},
can_repeat: function() {
return this.frm.meta.allow_auto_repeat
&& !this.frm.doc.__islocal
&& !this.frm.is_new()
&& !this.frm.doc.auto_repeat;
},
can_save: function() {