From 4d37739dd3ede937e93e8328fa6a147462efc241 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 15:45:50 +0530 Subject: [PATCH] fix(Vehicle): allow doc renaming and add test (backport #41729) (#41785) * fix(Vehicle): allow doc renaming and add test (#41729) fix(Vehicle): allow renaming doc and add test (cherry picked from commit c76f466528e2e6651df5d72e14f9418b8d5bec65) # Conflicts: # erpnext/setup/doctype/vehicle/vehicle.json * fix: resolve conflicts for backporting --------- Co-authored-by: Viny Selopal <52369157+vinyselopal@users.noreply.github.com> Co-authored-by: Viny Selopal --- erpnext/setup/doctype/vehicle/test_vehicle.py | 26 +++++++++++++++++++ erpnext/setup/doctype/vehicle/vehicle.json | 6 +++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/erpnext/setup/doctype/vehicle/test_vehicle.py b/erpnext/setup/doctype/vehicle/test_vehicle.py index 97fe651122c..3cd52386284 100644 --- a/erpnext/setup/doctype/vehicle/test_vehicle.py +++ b/erpnext/setup/doctype/vehicle/test_vehicle.py @@ -26,3 +26,29 @@ class TestVehicle(unittest.TestCase): } ) vehicle.insert() + + def test_renaming_vehicle(self): + license_plate = random_string(10).upper() + + vehicle = frappe.get_doc( + { + "doctype": "Vehicle", + "license_plate": license_plate, + "make": "Skoda", + "model": "Slavia", + "last_odometer": 5000, + "acquisition_date": frappe.utils.nowdate(), + "location": "Mumbai", + "chassis_no": "1234EFGH", + "uom": "Litre", + "vehicle_value": frappe.utils.flt(500000), + } + ) + vehicle.insert() + + new_license_plate = random_string(10).upper() + frappe.rename_doc("Vehicle", license_plate, new_license_plate) + + self.assertEqual( + new_license_plate, frappe.db.get_value("Vehicle", new_license_plate, "license_plate") + ) diff --git a/erpnext/setup/doctype/vehicle/vehicle.json b/erpnext/setup/doctype/vehicle/vehicle.json index b19d45924fb..c76719e4b92 100644 --- a/erpnext/setup/doctype/vehicle/vehicle.json +++ b/erpnext/setup/doctype/vehicle/vehicle.json @@ -2,7 +2,8 @@ "allow_copy": 0, "allow_guest_to_view": 0, "allow_import": 0, - "allow_rename": 0, + "actions": [], + "allow_rename": 1, "autoname": "field:license_plate", "beta": 0, "creation": "2016-09-03 03:33:27.680331", @@ -834,7 +835,8 @@ "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2022-06-27 14:48:30.813359", + "links": [], + "modified": "2024-05-31 06:38:15.399283", "modified_by": "Administrator", "module": "Setup", "name": "Vehicle",