From 4cb5b627a19edd00ecc28753ddfea0bb6ed92444 Mon Sep 17 00:00:00 2001 From: Noah Jacob Date: Thu, 16 Dec 2021 23:06:48 +0530 Subject: [PATCH] fix: mapping to maintenance visit gets erased (#28917) * fix: mappings to maintenance visit gets erased * test: mapping of schedule to visit --- .../maintenance_schedule/test_maintenance_schedule.py | 9 +++++++-- .../doctype/maintenance_visit/maintenance_visit.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) 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() }); } },