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"));
|
}, __("Tools"));
|
||||||
|
|
||||||
frm.add_custom_button(__('Download PDF'), () => {
|
frm.add_custom_button(
|
||||||
var suppliers = [];
|
__("Download PDF"),
|
||||||
const fields = [{
|
() => {
|
||||||
fieldtype: 'Link',
|
frappe.prompt(
|
||||||
label: __('Select a Supplier'),
|
[
|
||||||
fieldname: 'supplier',
|
{
|
||||||
options: 'Supplier',
|
fieldtype: "Link",
|
||||||
reqd: 1,
|
label: "Select a Supplier",
|
||||||
get_query: () => {
|
fieldname: "supplier",
|
||||||
return {
|
options: "Supplier",
|
||||||
filters: [
|
reqd: 1,
|
||||||
["Supplier", "name", "in", frm.doc.suppliers.map((row) => {return row.supplier;})]
|
default: frm.doc.suppliers?.length == 1 ? frm.doc.suppliers[0].supplier : "",
|
||||||
]
|
get_query: () => {
|
||||||
}
|
return {
|
||||||
}
|
filters: [
|
||||||
}];
|
[
|
||||||
|
"Supplier",
|
||||||
frappe.prompt(fields, data => {
|
"name",
|
||||||
var child = locals[cdt][cdn]
|
"in",
|
||||||
|
frm.doc.suppliers.map((row) => {
|
||||||
var w = window.open(
|
return row.supplier;
|
||||||
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;
|
{
|
||||||
}
|
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?" +
|
||||||
|
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',
|
__("Tools")
|
||||||
'Download');
|
);
|
||||||
},
|
|
||||||
__("Tools"));
|
|
||||||
|
|
||||||
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
frm.page.set_inner_btn_group_as_primary(__("Create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
make_supplier_quotation: function(frm) {
|
make_supplier_quotation: function(frm) {
|
||||||
|
@ -389,10 +389,17 @@ def create_rfq_items(sq_doc, supplier, data):
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_pdf(doctype, name, supplier):
|
def get_pdf(doctype, name, supplier, print_format=None, language=None, letter_head=None):
|
||||||
doc = get_rfq_doc(doctype, name, supplier)
|
# permissions get checked in `download_pdf`
|
||||||
if doc:
|
if doc := get_rfq_doc(doctype, name, supplier):
|
||||||
download_pdf(doctype, name, doc=doc)
|
download_pdf(
|
||||||
|
doctype,
|
||||||
|
name,
|
||||||
|
print_format,
|
||||||
|
doc=doc,
|
||||||
|
language=language,
|
||||||
|
letter_head=letter_head or None,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_rfq_doc(doctype, name, supplier):
|
def get_rfq_doc(doctype, name, supplier):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user