Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default templates for erpnext #210

Merged
merged 8 commits into from
Apr 16, 2024
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"attached_to_doctype": "Print Format",
"attached_to_field": "print_designer_preview_img",
"attached_to_name": "Sales Invoice PD Format v2",
"content_hash": "360404e78fedf97c58269738b5e58b64",
"creation": "2024-04-16 19:22:32.564571",
"docstatus": 0,
"doctype": "File",
"file_name": "print_designer-sales_invoice_pd_format_v2-preview.jpg",
"file_size": 148126,
"file_type": "JPG",
"file_url": "/private/files/print_designer-sales_invoice_pd_format_v2-preview.jpg",
"folder": "Home",
"idx": 0,
"is_attachments_folder": 0,
"is_folder": 0,
"is_home_folder": 0,
"is_private": 1,
"modified": "2024-04-16 19:22:32.564571",
"modified_by": "Administrator",
"name": "040d5e33f6",
"owner": "Administrator",
"uploaded_to_dropbox": 0,
"uploaded_to_google_drive": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"attached_to_doctype": "Print Format",
"attached_to_field": "print_designer_preview_img",
"attached_to_name": "Sales Order PD v2",
"content_hash": "37ff9dd2c9e9a1de2aa350a2336a56eb",
"creation": "2024-04-16 19:07:23.829817",
"docstatus": 0,
"doctype": "File",
"file_name": "print_designer-sales_order_pd_v2-preview6a56eb.jpg",
"file_size": 154063,
"file_type": "JPG",
"file_url": "/private/files/print_designer-sales_order_pd_v2-preview6a56eb.jpg",
"folder": "Home",
"idx": 0,
"is_attachments_folder": 0,
"is_folder": 0,
"is_home_folder": 0,
"is_private": 1,
"modified": "2024-04-16 19:07:23.829817",
"modified_by": "Administrator",
"name": "9ec0db389d",
"owner": "Administrator",
"uploaded_to_dropbox": 0,
"uploaded_to_google_drive": 0
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions print_designer/default_templates/erpnext/sales_order_pd_v2.json

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions print_designer/print_designer/client_scripts/print.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: revisit and properly implement this client script
frappe.pages["print"].on_page_load = function (wrapper) {
frappe.require(["pdfjs.bundle.css", "print_designer.bundle.css"]);
frappe.ui.make_app_page({
Expand Down Expand Up @@ -398,10 +399,22 @@ frappe.ui.form.PrintView = class PrintView extends frappe.ui.form.PrintView {
if (
frappe.meta
.get_print_formats(this.frm.doctype)
.includes(this.toolbar_print_format_selector.$input.val()) ||
!this.frm.meta.default_print_format
.includes(this.toolbar_print_format_selector.$input.val())
)
return;
if (!this.frm.meta.default_print_format) {
let pd_print_format = "";
if (this.frm.doctype == "Sales Invoice") {
pd_print_format = "Sales Invoice PD Format v2";
} else if (this.frm.doctype == "Sales Order") {
pd_print_format = "Sales Order PD v2";
}
if (pd_print_format) {
this.print_format_selector.val(pd_print_format);
this.toolbar_print_format_selector.$input.val(pd_print_format);
}
return;
}
this.toolbar_print_format_selector.$input.empty();
this.toolbar_print_format_selector.$input.val(this.frm.meta.default_print_format);
}
Expand Down
Loading