fix: fetch from more than one sales order in Maintenance Visit (#27186)

* fix: fetch from more than one sales order in Maintenance Visit (#26924)

* [fix] #26336

* fix(ux): make customer field reqd for fetching SO

# Conflicts:
#	erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js

* fix: resolve conflicts

Co-authored-by: Pawan Mehta <mehtapawan007@gmail.com>
Co-authored-by: Ankush Menat <ankush@iwebnotes.com>

(cherry picked from commit db69d1dc00)
This commit is contained in:
Frappe PR Bot
2021-08-26 23:05:45 +05:30
committed by GitHub
parent 1e428f9531
commit dc76094a9f
2 changed files with 15 additions and 9 deletions

View File

@@ -49,13 +49,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
if (this.frm.doc.docstatus===0) { if (this.frm.doc.docstatus===0) {
this.frm.add_custom_button(__('Maintenance Schedule'), this.frm.add_custom_button(__('Maintenance Schedule'),
function() { function () {
if (!me.frm.doc.customer) {
frappe.msgprint(__('Please select Customer first'));
return;
}
erpnext.utils.map_current_doc({ erpnext.utils.map_current_doc({
method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit", method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
source_doctype: "Maintenance Schedule", source_doctype: "Maintenance Schedule",
target: me.frm, target: me.frm,
setters: { setters: {
customer: me.frm.doc.customer || undefined, customer: me.frm.doc.customer,
}, },
get_query_filters: { get_query_filters: {
docstatus: 1, docstatus: 1,
@@ -80,13 +84,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
}) })
}, __("Get items from")); }, __("Get items from"));
this.frm.add_custom_button(__('Sales Order'), this.frm.add_custom_button(__('Sales Order'),
function() { function () {
if (!me.frm.doc.customer) {
frappe.msgprint(__('Please select Customer first'));
return;
}
erpnext.utils.map_current_doc({ erpnext.utils.map_current_doc({
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit", method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
source_doctype: "Sales Order", source_doctype: "Sales Order",
target: me.frm, target: me.frm,
setters: { setters: {
customer: me.frm.doc.customer || undefined, customer: me.frm.doc.customer,
}, },
get_query_filters: { get_query_filters: {
docstatus: 1, docstatus: 1,
@@ -99,4 +107,4 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
}, },
}); });
$.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm})); $.extend(cur_frm.cscript, new erpnext.maintenance.MaintenanceVisit({frm: cur_frm}));

View File

@@ -714,8 +714,7 @@ def make_maintenance_schedule(source_name, target_doc=None):
"doctype": "Maintenance Schedule Item", "doctype": "Maintenance Schedule Item",
"field_map": { "field_map": {
"parent": "sales_order" "parent": "sales_order"
}, }
"add_if_empty": True
} }
}, target_doc) }, target_doc)
@@ -741,8 +740,7 @@ def make_maintenance_visit(source_name, target_doc=None):
"field_map": { "field_map": {
"parent": "prevdoc_docname", "parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype" "parenttype": "prevdoc_doctype"
}, }
"add_if_empty": True
} }
}, target_doc) }, target_doc)