fix: sider
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
index 075bd40..1e5773c 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.js
@@ -71,65 +71,69 @@
let options = "";
me.frm.call('get_pending_data', {data_type: "items"}).then(r =>{
- options = r.message
+ options = r.message;
- let schedule_id = "";
- let d = new frappe.ui.Dialog({
- title: __("Enter Visit Details"),
- fields: [{
- fieldtype: "Select",
- fieldname: "item_name",
- label: __("Item Name"),
- options: options,
- reqd: 1,
- onchange: function () {
- let field = d.get_field("scheduled_date");
- me.frm.call('get_pending_data',{item_name:this.value,data_type:"date"}).then(r =>{
- field.df.options = r.message;
- field.refresh();
- })
- }
- },
- {
- label: __('Scheduled Date'),
- fieldname: 'scheduled_date',
- fieldtype: 'Select',
- options: "",
- reqd: 1,
- onchange: function () {
- let field = d.get_field('item_name');
- me.frm.call(
- 'get_pending_data',
- {
- item_name: field.value,
- s_date: this.value,
- data_type: "id"
- }).then(r =>{
- schedule_id = r.message;
- })
- }
- },
- ],
- primary_action_label: 'Create Visit',
- primary_action(values) {
- frappe.call({
- method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
- args: {
- item_name: values.item_name,
- s_id: schedule_id,
- source_name: me.frm.doc.name,
- },
- callback: function (r) {
- if (!r.exc) {
- frappe.model.sync(r.message);
- frappe.set_route("Form", r.message.doctype, r.message.name);
- }
+ let schedule_id = "";
+ let d = new frappe.ui.Dialog({
+ title: __("Enter Visit Details"),
+ fields: [{
+ fieldtype: "Select",
+ fieldname: "item_name",
+ label: __("Item Name"),
+ options: options,
+ reqd: 1,
+ onchange: function () {
+ let field = d.get_field("scheduled_date");
+ me.frm.call('get_pending_data',
+ {
+ item_name: this.value,
+ data_type: "date"
+ }).then(r => {
+ field.df.options = r.message;
+ field.refresh();
+ });
}
- });
- d.hide();
- }
- });
- d.show();
+ },
+ {
+ label: __('Scheduled Date'),
+ fieldname: 'scheduled_date',
+ fieldtype: 'Select',
+ options: "",
+ reqd: 1,
+ onchange: function () {
+ let field = d.get_field('item_name');
+ me.frm.call(
+ 'get_pending_data',
+ {
+ item_name: field.value,
+ s_date: this.value,
+ data_type: "id"
+ }).then(r =>{
+ schedule_id = r.message;
+ });
+ }
+ },
+ ],
+ primary_action_label: 'Create Visit',
+ primary_action(values) {
+ frappe.call({
+ method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
+ args: {
+ item_name: values.item_name,
+ s_id: schedule_id,
+ source_name: me.frm.doc.name,
+ },
+ callback: function (r) {
+ if (!r.exc) {
+ frappe.model.sync(r.message);
+ frappe.set_route("Form", r.message.doctype, r.message.name);
+ }
+ }
+ });
+ d.hide();
+ }
+ });
+ d.show();
});
}, __('Create'));
}
@@ -154,9 +158,9 @@
set_no_of_visits: function (doc, cdt, cdn) {
var item = frappe.get_doc(cdt, cdn);
-
+ let me = this;
if (item.start_date && item.periodicity) {
- me.frm.call('validate_end_date_visits')
+ me.frm.call('validate_end_date_visits');
}
},
diff --git a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
index 0bc2e87..5d573c5 100644
--- a/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
+++ b/erpnext/maintenance/doctype/maintenance_schedule/maintenance_schedule.py
@@ -58,7 +58,7 @@
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])
- 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])
elif item.no_of_visits > no_of_visits:
@@ -93,8 +93,8 @@
frappe.msgprint(
_("Setting Events to {0}, since the Employee attached to the below Sales Persons does not have a User ID{1}").format(
self.owner, "<br>" + "<br>".join(no_email_sp)
- )
)
+ )
scheduled_date = frappe.db.sql("""select scheduled_date from
`tabMaintenance Schedule Detail` where sales_person=%s and item_code=%s and