fix: mapping to maintenance visit gets erased (#28917)

* fix: mappings to maintenance visit gets erased

* test: mapping of schedule to visit
This commit is contained in:
Noah Jacob 2021-12-16 23:06:48 +05:30 committed by GitHub
parent 6ba8f7644d
commit 4cb5b627a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -56,9 +56,14 @@ class TestMaintenanceSchedule(unittest.TestCase):
ms.submit() ms.submit()
s_id = ms.get_pending_data(data_type = "id", item_name = i.item_name, s_date = expected_dates[1]) 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 = frappe.new_doc('Maintenance Visit')
visit = test visit = test_map_visit
visit.maintenance_schedule = ms.name visit.maintenance_schedule = ms.name
visit.maintenance_schedule_detail = s_id visit.maintenance_schedule_detail = s_id
visit.completion_status = "Partially Completed" visit.completion_status = "Partially Completed"

View File

@ -47,7 +47,7 @@ frappe.ui.form.on('Maintenance Visit', {
frm.set_value({ status: 'Draft' }); frm.set_value({ status: 'Draft' });
} }
if (frm.doc.__islocal) { 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() }); frm.set_value({ mntc_date: frappe.datetime.get_today() });
} }
}, },