feat: more control when printing RFQ
This commit is contained in:
parent
21c86bd649
commit
ce9626fead
@ -57,44 +57,93 @@ frappe.ui.form.on("Request for Quotation",{
|
||||
});
|
||||
}, __("Tools"));
|
||||
|
||||
frm.add_custom_button(__('Download PDF'), () => {
|
||||
var suppliers = [];
|
||||
const fields = [{
|
||||
fieldtype: 'Link',
|
||||
label: __('Select a Supplier'),
|
||||
fieldname: 'supplier',
|
||||
options: 'Supplier',
|
||||
frm.add_custom_button(
|
||||
__("Download PDF"),
|
||||
() => {
|
||||
frappe.prompt(
|
||||
[
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: "Select a Supplier",
|
||||
fieldname: "supplier",
|
||||
options: "Supplier",
|
||||
reqd: 1,
|
||||
default: frm.doc.suppliers?.length == 1 ? frm.doc.suppliers[0].supplier : "",
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: [
|
||||
["Supplier", "name", "in", frm.doc.suppliers.map((row) => {return row.supplier;})]
|
||||
]
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
frappe.prompt(fields, data => {
|
||||
var child = locals[cdt][cdn]
|
||||
|
||||
[
|
||||
"Supplier",
|
||||
"name",
|
||||
"in",
|
||||
frm.doc.suppliers.map((row) => {
|
||||
return row.supplier;
|
||||
}),
|
||||
],
|
||||
],
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "Section Break",
|
||||
label: "Print Settings",
|
||||
fieldname: "print_settings",
|
||||
collapsible: 1,
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: "Print Format",
|
||||
fieldname: "print_format",
|
||||
options: "Print Format",
|
||||
get_query: () => {
|
||||
return {
|
||||
filters: {
|
||||
doc_type: "Request for Quotation",
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: "Language",
|
||||
fieldname: "language",
|
||||
options: "Language",
|
||||
},
|
||||
{
|
||||
fieldtype: "Link",
|
||||
label: "Letter Head",
|
||||
fieldname: "letter_head",
|
||||
options: "Letter Head",
|
||||
},
|
||||
],
|
||||
(data) => {
|
||||
var w = window.open(
|
||||
frappe.urllib.get_full_url("/api/method/erpnext.buying.doctype.request_for_quotation.request_for_quotation.get_pdf?"
|
||||
+"doctype="+encodeURIComponent(frm.doc.doctype)
|
||||
+"&name="+encodeURIComponent(frm.doc.name)
|
||||
+"&supplier="+encodeURIComponent(data.supplier)
|
||||
+"&no_letterhead=0"));
|
||||
if(!w) {
|
||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||
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",
|
||||
language: data.language || frappe.boot.lang,
|
||||
letter_head: data.letter_head || "",
|
||||
}).toString()
|
||||
)
|
||||
);
|
||||
if (!w) {
|
||||
frappe.msgprint(__("Please enable pop-ups"));
|
||||
return;
|
||||
}
|
||||
},
|
||||
'Download PDF for Supplier',
|
||||
'Download');
|
||||
"Download PDF for Supplier",
|
||||
"Download"
|
||||
);
|
||||
},
|
||||
__("Tools"));
|
||||
__("Tools")
|
||||
);
|
||||
|
||||
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||
frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
make_supplier_quotation: function(frm) {
|
||||
|
@ -389,10 +389,17 @@ def create_rfq_items(sq_doc, supplier, data):
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_pdf(doctype, name, supplier):
|
||||
doc = get_rfq_doc(doctype, name, supplier)
|
||||
if doc:
|
||||
download_pdf(doctype, name, doc=doc)
|
||||
def get_pdf(doctype, name, supplier, print_format=None, language=None, letter_head=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,
|
||||
letter_head=letter_head or None,
|
||||
)
|
||||
|
||||
|
||||
def get_rfq_doc(doctype, name, supplier):
|
||||
|
Loading…
x
Reference in New Issue
Block a user