[RFQ Enhancement] Added button on supplier row to download PDF for particular supplier

This commit is contained in:
Rohit Waghchaure 2016-06-30 16:50:13 +05:30
parent 465b753848
commit fc1fa9a774
5 changed files with 118 additions and 11 deletions

View File

@ -2363,6 +2363,31 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -3006,7 +3031,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-06-08 17:30:39.470490",
"modified": "2016-06-30 13:40:39.440646",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Invoice",

View File

@ -7,7 +7,7 @@
cur_frm.add_fetch('contact', 'email_id', 'email_id')
frappe.ui.form.on("Request for Quotation",{
setup: function(frm){
setup: function(frm) {
frm.fields_dict["suppliers"].grid.get_field("contact").get_query = function(doc, cdt, cdn){
var d =locals[cdt][cdn];
return {
@ -29,7 +29,7 @@ frappe.ui.form.on("Request for Quotation",{
];
},
onload: function(frm){
onload: function(frm) {
frm.add_fetch('standard_reply', 'response', 'response');
if(!frm.doc.message_for_supplier) {
@ -37,7 +37,7 @@ frappe.ui.form.on("Request for Quotation",{
}
},
refresh: function(frm, cdt, cdn){
refresh: function(frm, cdt, cdn) {
if (frm.doc.docstatus === 1) {
frm.add_custom_button(__("Make Supplier Quotation"),
function(){ frm.trigger("make_suppplier_quotation") });
@ -54,7 +54,7 @@ frappe.ui.form.on("Request for Quotation",{
}
},
make_suppplier_quotation: function(frm){
make_suppplier_quotation: function(frm) {
var doc = frm.doc;
var dialog = new frappe.ui.Dialog({
title: __("For Supplier"),
@ -93,10 +93,24 @@ frappe.ui.form.on("Request for Quotation",{
})
frappe.ui.form.on("Request for Quotation Supplier",{
supplier: function(frm, cdt, cdn){
supplier: function(frm, cdt, cdn) {
var d = locals[cdt][cdn]
frappe.model.set_value(cdt, cdn, 'contact', '')
frappe.model.set_value(cdt, cdn, 'email_id', '')
},
download_pdf: function(frm, cdt, cdn) {
var child = locals[cdt][cdn]
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_idx="+encodeURIComponent(child.idx)
+"&no_letterhead=0"));
if(!w) {
msgprint(__("Please enable pop-ups")); return;
}
}
})

View File

@ -6,8 +6,9 @@ from __future__ import unicode_literals
import frappe, json
from frappe import _
from frappe.model.mapper import get_mapped_doc
from frappe.utils import get_url, random_string
from frappe.utils import get_url, random_string, cint
from frappe.utils.user import get_user_fullname
from frappe.utils.print_format import download_pdf
from frappe.desk.form.load import get_attachments
from frappe.core.doctype.communication.email import make
from erpnext.accounts.party import get_party_account_currency, get_party_details
@ -136,15 +137,20 @@ class RequestforQuotation(BuyingController):
def get_attachments(self):
attachments = [d.name for d in get_attachments(self.doctype, self.name)]
attachments.append(frappe.attach_print('Request for Quotation', self.name, doc=self))
attachments.append(frappe.attach_print(self.doctype, self.name, doc=self))
return attachments
@frappe.whitelist()
def send_supplier_emails(rfq_name):
check_portal_enabled('Request for Quotation')
rfq = frappe.get_doc("Request for Quotation", rfq_name)
if rfq.docstatus==1:
rfq.send_to_supplier()
def check_portal_enabled(reference_doctype):
if not frappe.db.get_value('Portal Menu Item',
{'reference_doctype': reference_doctype}, 'enabled'):
frappe.throw(_("Request for Quotation is disabled to access from portal, for more check portal settings."))
def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context
@ -152,7 +158,6 @@ def get_list_context(context=None):
list_context["show_sidebar"] = True
return list_context
# This method is used to make supplier quotation from material request form.
@frappe.whitelist()
def make_supplier_quotation(source_name, for_supplier, target_doc=None):
@ -226,3 +231,16 @@ def create_rfq_items(sq_doc, supplier, data):
"request_for_quotation_item": data.name,
"request_for_quotation": data.parent
})
@frappe.whitelist()
def get_pdf(doctype, name, supplier_idx):
doc = get_rfq_doc(doctype, name, supplier_idx)
if doc:
download_pdf(doctype, name, doc=doc)
def get_rfq_doc(doctype, name, supplier_idx):
if cint(supplier_idx):
doc = frappe.get_doc(doctype, name)
args = doc.get('suppliers')[cint(supplier_idx) - 1]
doc.update_supplier_part_no(args)
return doc

View File

@ -162,6 +162,31 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 1,
"bold": 0,
"collapsible": 0,
"fieldname": "download_pdf",
"fieldtype": "Button",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Download PDF",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
}
],
"hide_heading": 0,
@ -174,7 +199,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-06-30 02:01:54.130809",
"modified": "2016-06-30 12:47:23.564189",
"modified_by": "Administrator",
"module": "Buying",
"name": "Request for Quotation Supplier",

View File

@ -2193,6 +2193,31 @@
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"fieldname": "language",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Print Language",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"unique": 0
},
{
"allow_on_submit": 0,
"bold": 0,
@ -2419,7 +2444,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
"modified": "2016-06-09 15:11:04.042369",
"modified": "2016-06-30 13:42:23.310309",
"modified_by": "Administrator",
"module": "Stock",
"name": "Purchase Receipt",