-
Notifications
You must be signed in to change notification settings - Fork 1
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 #3 from CodeVenturers/vishnu
chore: validate template
- Loading branch information
Showing
4 changed files
with
67 additions
and
207 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
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
28 changes: 26 additions & 2 deletions
28
report_print/report_print/doctype/report_print_format/report_print_format.py
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 |
---|---|---|
@@ -1,8 +1,32 @@ | ||
# Copyright (c) 2024, Code Venturers and contributors | ||
# For license information, please see license.txt | ||
|
||
# import frappe | ||
import frappe | ||
from frappe import _, bold | ||
from frappe.utils.jinja import validate_template | ||
|
||
from frappe.model.document import Document | ||
|
||
|
||
class ReportPrintFormat(Document): | ||
pass | ||
def validate(self): | ||
if self.html: | ||
validate_template(self.html) | ||
|
||
@frappe.whitelist() | ||
def make_default(self): | ||
if self.disabled: | ||
frappe.throw(_("The document {} is disabled..".format(bold(self.name)))) | ||
|
||
if default_print := frappe.db.get_value( | ||
"Report Print Format", {"report": self.report, "default": 1}, "name" | ||
): | ||
report_print_doc = frappe.get_doc("Report Print Format", default_print) | ||
report_print_doc.db_set("default", 0) | ||
self.db_set("default", 1) | ||
|
||
frappe.msgprint( | ||
_("{0} is now default print format for {1} report").format( | ||
frappe.bold(self.name), frappe.bold(self.report) | ||
) | ||
) |