Skip to content

Commit

Permalink
refactor: moved purpose table mandatory check to server
Browse files Browse the repository at this point in the history
  • Loading branch information
noahjacob committed Dec 17, 2021
1 parent 90d3200 commit 95c30b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def validate_serial_no(self):
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')
Expand All @@ -29,6 +33,7 @@ def validate_maintenance_date(self):
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:
Expand Down

0 comments on commit 95c30b9

Please sign in to comment.