fix: sider

This commit is contained in:
noahjacob 2021-05-20 14:20:50 +05:30
parent 08598238d7
commit 0169cd845a
2 changed files with 65 additions and 61 deletions

View File

@ -71,7 +71,7 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({
let options = ""; let options = "";
me.frm.call('get_pending_data', {data_type: "items"}).then(r =>{ me.frm.call('get_pending_data', {data_type: "items"}).then(r =>{
options = r.message options = r.message;
let schedule_id = ""; let schedule_id = "";
let d = new frappe.ui.Dialog({ let d = new frappe.ui.Dialog({
@ -84,10 +84,14 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({
reqd: 1, reqd: 1,
onchange: function () { onchange: function () {
let field = d.get_field("scheduled_date"); let field = d.get_field("scheduled_date");
me.frm.call('get_pending_data',{item_name:this.value,data_type:"date"}).then(r =>{ me.frm.call('get_pending_data',
{
item_name: this.value,
data_type: "date"
}).then(r => {
field.df.options = r.message; field.df.options = r.message;
field.refresh(); field.refresh();
}) });
} }
}, },
{ {
@ -106,7 +110,7 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({
data_type: "id" data_type: "id"
}).then(r =>{ }).then(r =>{
schedule_id = r.message; schedule_id = r.message;
}) });
} }
}, },
], ],
@ -154,9 +158,9 @@ erpnext.maintenance.MaintenanceSchedule = frappe.ui.form.Controller.extend({
set_no_of_visits: function (doc, cdt, cdn) { set_no_of_visits: function (doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn); var item = frappe.get_doc(cdt, cdn);
let me = this;
if (item.start_date && item.periodicity) { if (item.start_date && item.periodicity) {
me.frm.call('validate_end_date_visits') me.frm.call('validate_end_date_visits');
} }
}, },

View File

@ -58,7 +58,7 @@ class MaintenanceSchedule(TransactionBase):
if not item.no_of_visits or item.no_of_visits == 0: if not item.no_of_visits or item.no_of_visits == 0:
item.end_date = add_days(item.start_date, days_in_period[item.periodicity]) item.end_date = add_days(item.start_date, days_in_period[item.periodicity])
diff = date_diff(item.end_date, item.start_date ) + 1 diff = date_diff(item.end_date, item.start_date) + 1
item.no_of_visits = cint(diff / days_in_period[item.periodicity]) item.no_of_visits = cint(diff / days_in_period[item.periodicity])
elif item.no_of_visits > no_of_visits: elif item.no_of_visits > no_of_visits: