diff --git a/erpnext/maintenance/doctype/maintenance_schedule/test_maintenance_schedule.py b/erpnext/maintenance/doctype/maintenance_schedule/test_maintenance_schedule.py index 37ea3fdac3..501712613a 100644 --- a/erpnext/maintenance/doctype/maintenance_schedule/test_maintenance_schedule.py +++ b/erpnext/maintenance/doctype/maintenance_schedule/test_maintenance_schedule.py @@ -56,9 +56,14 @@ class TestMaintenanceSchedule(unittest.TestCase): ms.submit() s_id = ms.get_pending_data(data_type = "id", item_name = i.item_name, s_date = expected_dates[1]) - test = make_maintenance_visit(source_name = ms.name, item_name = "_Test Item", s_id = s_id) + + # Check if item is mapped in visit. + test_map_visit = make_maintenance_visit(source_name = ms.name, item_name = "_Test Item", s_id = s_id) + self.assertEqual(len(test_map_visit.purposes), 1) + self.assertEqual(test_map_visit.purposes[0].item_name, "_Test Item") + visit = frappe.new_doc('Maintenance Visit') - visit = test + visit = test_map_visit visit.maintenance_schedule = ms.name visit.maintenance_schedule_detail = s_id visit.completion_status = "Partially Completed" diff --git a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js index 6f6ca61ebc..d2197a6877 100644 --- a/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js +++ b/erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js @@ -47,7 +47,7 @@ frappe.ui.form.on('Maintenance Visit', { frm.set_value({ status: 'Draft' }); } if (frm.doc.__islocal) { - frm.clear_table("purposes"); + frm.doc.maintenance_type == 'Unscheduled' && frm.clear_table("purposes"); frm.set_value({ mntc_date: frappe.datetime.get_today() }); } },