Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({

if (this.frm.doc.docstatus===0) {
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({
method: "erpnext.maintenance.doctype.maintenance_schedule.maintenance_schedule.make_maintenance_visit",
source_doctype: "Maintenance Schedule",
target: me.frm,
setters: {
customer: me.frm.doc.customer || undefined,
customer: me.frm.doc.customer,
},
get_query_filters: {
docstatus: 1,
Expand All @@ -80,13 +84,17 @@ erpnext.maintenance.MaintenanceVisit = frappe.ui.form.Controller.extend({
})
}, __("Get items from"));
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({
method: "erpnext.selling.doctype.sales_order.sales_order.make_maintenance_visit",
source_doctype: "Sales Order",
target: me.frm,
setters: {
customer: me.frm.doc.customer || undefined,
customer: me.frm.doc.customer,
},
get_query_filters: {
docstatus: 1,
Expand All @@ -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}));
6 changes: 2 additions & 4 deletions erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ def make_maintenance_schedule(source_name, target_doc=None):
"doctype": "Maintenance Schedule Item",
"field_map": {
"parent": "sales_order"
},
"add_if_empty": True
}
}
}, target_doc)

Expand All @@ -741,8 +740,7 @@ def make_maintenance_visit(source_name, target_doc=None):
"field_map": {
"parent": "prevdoc_docname",
"parenttype": "prevdoc_doctype"
},
"add_if_empty": True
}
}
}, target_doc)

Expand Down