Skip to content

Commit

Permalink
refactor: download RFQ PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Feb 14, 2023
1 parent f7fd30f commit 8e40c04
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ frappe.ui.form.on("Request for Quotation",{
frappe.urllib.get_full_url(
"/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?" +
new URLSearchParams({
doctype: frm.doc.doctype,
name: frm.doc.name,
supplier: data.supplier,
print_format: data.print_format || "Standard",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@


import json
from typing import Optional

import frappe
from frappe import _
Expand Down Expand Up @@ -388,24 +389,26 @@ def create_rfq_items(sq_doc, supplier, data):


@frappe.whitelist()
def get_pdf(doctype, name, supplier, print_format=None, language=None, letterhead=None):
# permissions get checked in `download_pdf`
if doc := get_rfq_doc(doctype, name, supplier):
download_pdf(
doctype,
name,
print_format,
doc=doc,
language=language,
letterhead=letterhead or None,
)


def get_rfq_doc(doctype, name, supplier):
def get_pdf(
name: str,
supplier: str,
print_format: Optional[str] = None,
language: Optional[str] = None,
letterhead: Optional[str] = None,
):
doc = frappe.get_doc("Request for Quotation", name)
if supplier:
doc = frappe.get_doc(doctype, name)
doc.update_supplier_part_no(supplier)
return doc

# permissions get checked in `download_pdf`
download_pdf(
doc.doctype,
doc.name,
print_format,
doc=doc,
language=language,
letterhead=letterhead or None,
)


@frappe.whitelist()
Expand Down

0 comments on commit 8e40c04

Please sign in to comment.