Merge pull request #5615 from rohitwaghchaure/v7_rfq_fixes

[RFQ Enhancement] Added button on supplier row to download PDF for particular supplier
This commit is contained in:
Rushabh Mehta 2016-07-04 10:58:33 +05:30 committed by GitHub
commit 2be94f7675
5 changed files with 118 additions and 11 deletions

View File

@ -2363,6 +2363,31 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -3006,7 +3031,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-06-08 17:30:39.470490", "modified": "2016-06-30 13:40:39.440646",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Accounts", "module": "Accounts",
"name": "Purchase Invoice", "name": "Purchase Invoice",

View File

@ -97,6 +97,20 @@ frappe.ui.form.on("Request for Quotation Supplier",{
var d = locals[cdt][cdn] var d = locals[cdt][cdn]
frappe.model.set_value(cdt, cdn, 'contact', '') frappe.model.set_value(cdt, cdn, 'contact', '')
frappe.model.set_value(cdt, cdn, 'email_id', '') 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 import frappe, json
from frappe import _ from frappe import _
from frappe.model.mapper import get_mapped_doc 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.user import get_user_fullname
from frappe.utils.print_format import download_pdf
from frappe.desk.form.load import get_attachments from frappe.desk.form.load import get_attachments
from frappe.core.doctype.communication.email import make from frappe.core.doctype.communication.email import make
from erpnext.accounts.party import get_party_account_currency, get_party_details from erpnext.accounts.party import get_party_account_currency, get_party_details
@ -136,15 +137,20 @@ class RequestforQuotation(BuyingController):
def get_attachments(self): def get_attachments(self):
attachments = [d.name for d in get_attachments(self.doctype, self.name)] 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 return attachments
@frappe.whitelist() @frappe.whitelist()
def send_supplier_emails(rfq_name): def send_supplier_emails(rfq_name):
check_portal_enabled('Request for Quotation')
rfq = frappe.get_doc("Request for Quotation", rfq_name) rfq = frappe.get_doc("Request for Quotation", rfq_name)
if rfq.docstatus==1: if rfq.docstatus==1:
rfq.send_to_supplier() 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): def get_list_context(context=None):
from erpnext.controllers.website_list_for_contact import get_list_context 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 list_context["show_sidebar"] = True
return list_context return list_context
# This method is used to make supplier quotation from material request form. # This method is used to make supplier quotation from material request form.
@frappe.whitelist() @frappe.whitelist()
def make_supplier_quotation(source_name, for_supplier, target_doc=None): 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_item": data.name,
"request_for_quotation": data.parent "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, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"unique": 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, "hide_heading": 0,
@ -174,7 +199,7 @@
"issingle": 0, "issingle": 0,
"istable": 1, "istable": 1,
"max_attachments": 0, "max_attachments": 0,
"modified": "2016-06-30 02:01:54.130809", "modified": "2016-06-30 12:47:23.564189",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Buying", "module": "Buying",
"name": "Request for Quotation Supplier", "name": "Request for Quotation Supplier",

View File

@ -2193,6 +2193,31 @@
"set_only_once": 0, "set_only_once": 0,
"unique": 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, "allow_on_submit": 0,
"bold": 0, "bold": 0,
@ -2419,7 +2444,7 @@
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"menu_index": 0, "menu_index": 0,
"modified": "2016-06-09 15:11:04.042369", "modified": "2016-06-30 13:42:23.310309",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Stock", "module": "Stock",
"name": "Purchase Receipt", "name": "Purchase Receipt",