refactor: moved purpose table mandatory check to server

(cherry picked from commit b98c61f2a7)

# Conflicts:
#	erpnext/maintenance/doctype/maintenance_visit/maintenance_visit.js
This commit is contained in:
Noah Jacob
2021-12-17 13:46:46 +05:30
committed by mergify-bot
parent 0bb0a9d032
commit 93325c72f0
3 changed files with 11 additions and 3 deletions

View File

@@ -41,11 +41,14 @@ frappe.ui.form.on('Maintenance Visit', {
frm.set_value({ status: 'Draft' });
}
if (frm.doc.__islocal) {
<<<<<<< HEAD
<<<<<<< HEAD
frm.doc.maintenance_type == 'Unscheduled' && frm.clear_table("purposes");
=======
frm.clear_table("purposes");
>>>>>>> 4f52b86d7e (refactor: update_serial_no function and code cleanup)
=======
>>>>>>> b98c61f2a7 (refactor: moved purpose table mandatory check to server)
frm.set_value({ mntc_date: frappe.datetime.get_today() });
}
},

View File

@@ -179,8 +179,7 @@
"label": "Purposes",
"oldfieldname": "maintenance_visit_details",
"oldfieldtype": "Table",
"options": "Maintenance Visit Purpose",
"reqd": 1
"options": "Maintenance Visit Purpose"
},
{
"fieldname": "more_info",
@@ -294,10 +293,11 @@
"idx": 1,
"is_submittable": 1,
"links": [],
"modified": "2021-05-27 16:06:17.352572",
"modified": "2021-12-17 03:10:27.608112",
"modified_by": "Administrator",
"module": "Maintenance",
"name": "Maintenance Visit",
"naming_rule": "By \"Naming Series\" field",
"owner": "Administrator",
"permissions": [
{

View File

@@ -18,6 +18,10 @@ class MaintenanceVisit(TransactionBase):
if d.serial_no and not frappe.db.exists("Serial No", d.serial_no):
frappe.throw(_("Serial No {0} does not exist").format(d.serial_no))
def validate_purpose_table(self):
if not self.purposes:
frappe.throw(_("Add Items in the Purpose Table"), title="Purposes Required")
def validate_maintenance_date(self):
if self.maintenance_type == "Scheduled" and self.maintenance_schedule_detail:
item_ref = frappe.db.get_value('Maintenance Schedule Detail', self.maintenance_schedule_detail, 'item_reference')
@@ -29,6 +33,7 @@ class MaintenanceVisit(TransactionBase):
def validate(self):
self.validate_serial_no()
self.validate_maintenance_date()
self.validate_purpose_table()
def update_completion_status(self):
if self.maintenance_schedule_detail: