-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from navariltd/staging
fix: drop_meter_reading api
- Loading branch information
Showing
4 changed files
with
100 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import frappe | ||
|
||
@frappe.whitelist(allow_guest=True) | ||
def drop_meter_reading(): | ||
try: | ||
meter_readings = frappe.get_all("Meter Reading", pluck="name") | ||
for reading in meter_readings: | ||
frappe.delete_doc("Meter Reading", reading) | ||
|
||
meter_reading_items = frappe.get_all("Meter Reading Item", pluck="name") | ||
for item in meter_reading_items: | ||
frappe.delete_doc("Meter Reading Item", item) | ||
|
||
meter_reading_rates = frappe.get_all("Meter Reading Rate", pluck="name") | ||
for rate in meter_reading_rates: | ||
frappe.delete_doc("Meter Reading Rate", rate) | ||
|
||
frappe.db.commit() | ||
|
||
return { | ||
"status": "success", | ||
"message": "All entries in Meter Reading, Meter Reading Item, and Meter Reading Rate have been successfully deleted." | ||
} | ||
|
||
except Exception as e: | ||
frappe.log_error(f"An error occurred while deleting records: {str(e)}", "Drop Reading Error") | ||
return {"status": "error", "message": str(e)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters