From 21499e820db46bde9f8c52cc2b5a4e92c4731f26 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Wed, 21 Sep 2016 16:49:58 +0530 Subject: [PATCH] [Enhancement] Supplier quotation added on supplier portal --- .../request_for_quotation/request_for_quotation.py | 2 +- .../supplier_quotation/supplier_quotation.py | 13 +++++++++++++ erpnext/controllers/website_list_for_contact.py | 8 ++++++-- erpnext/hooks.py | 9 +++++++++ erpnext/templates/includes/rfq.js | 5 ++++- erpnext/templates/pages/order.py | 4 ++-- 6 files changed, 35 insertions(+), 6 deletions(-) diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py index b01d3e844b..482a2aeaeb 100644 --- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py +++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py @@ -210,7 +210,7 @@ def create_supplier_quotation(doc): frappe.msgprint(_("Supplier Quotation {0} created").format(sq_doc.name)) return sq_doc.name except Exception: - return + return None def add_items(sq_doc, supplier, items): for data in items: diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 206dfa3026..144e982a04 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import frappe +from frappe import _ from frappe.utils import flt from frappe.model.mapper import get_mapped_doc @@ -54,6 +55,18 @@ class SupplierQuotation(BuyingController): pc = frappe.get_doc('Purchase Common') pc.validate_for_items(self) +def get_list_context(context=None): + from erpnext.controllers.website_list_for_contact import get_list_context + list_context = get_list_context(context) + list_context.update({ + 'show_sidebar': True, + 'show_search': True, + 'no_breadcrumbs': True, + 'title': _('Supplier Quotation'), + }) + + return list_context + @frappe.whitelist() def make_purchase_order(source_name, target_doc=None): def set_missing_values(source, target): diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py index 75c6e08bff..1abb7e7475 100644 --- a/erpnext/controllers/website_list_for_contact.py +++ b/erpnext/controllers/website_list_for_contact.py @@ -25,7 +25,10 @@ def get_transaction_list(doctype, txt=None, filters=None, limit_start=0, limit_p if not filters: filters = [] - filters.append((doctype, "docstatus", "=", 1)) + if doctype == 'Supplier Quotation': + filters.append((doctype, "docstatus", "<", 2)) + else: + filters.append((doctype, "docstatus", "=", 1)) if user != "Guest" and is_website_user(): parties_doctype = 'Request for Quotation Supplier' if doctype == 'Request for Quotation' else doctype @@ -112,7 +115,8 @@ def has_website_permission(doc, ptype, user, verbose=False): return frappe.get_all(doctype, filters=[(doctype, "customer", "in", customers), (doctype, "name", "=", doc.name)]) and True or False elif suppliers: - return frappe.get_all(doctype, filters=[(doctype, "suppliers", "in", suppliers), + fieldname = 'suppliers' if doctype == 'Request for Quotation' else 'supplier' + return frappe.get_all(doctype, filters=[(doctype, fieldname, "in", suppliers), (doctype, "name", "=", doc.name)]) and True or False else: return False diff --git a/erpnext/hooks.py b/erpnext/hooks.py index 19e915e46c..43ae234f68 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -67,6 +67,13 @@ website_route_rules = [ "parents": [{"title": _("Invoices"), "name": "invoices"}] } }, + {"from_route": "/quotations", "to_route": "Supplier Quotation"}, + {"from_route": "/quotations/", "to_route": "order", + "defaults": { + "doctype": "Supplier Quotation", + "parents": [{"title": _("Supplier Quotation"), "name": "quotations"}] + } + }, {"from_route": "/shipments", "to_route": "Delivery Note"}, {"from_route": "/shipments/", "to_route": "order", "defaults": { @@ -95,6 +102,7 @@ website_route_rules = [ portal_menu_items = [ {"title": _("Projects"), "route": "/project", "reference_doctype": "Project"}, {"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation"}, + {"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation"}, {"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order"}, {"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice"}, {"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note"}, @@ -109,6 +117,7 @@ portal_menu_items = [ has_website_permission = { "Sales Order": "erpnext.controllers.website_list_for_contact.has_website_permission", "Sales Invoice": "erpnext.controllers.website_list_for_contact.has_website_permission", + "Supplier Quotation": "erpnext.controllers.website_list_for_contact.has_website_permission", "Delivery Note": "erpnext.controllers.website_list_for_contact.has_website_permission", "Issue": "erpnext.support.doctype.issue.issue.has_website_permission", "Address": "erpnext.utilities.doctype.address.address.has_website_permission", diff --git a/erpnext/templates/includes/rfq.js b/erpnext/templates/includes/rfq.js index c63226c9bd..42dcc3a6c7 100644 --- a/erpnext/templates/includes/rfq.js +++ b/erpnext/templates/includes/rfq.js @@ -81,8 +81,11 @@ rfq = Class.extend({ }, btn: this, callback: function(r){ - $('.btn-sm').hide() frappe.unfreeze(); + if(r.message){ + $('.btn-sm').hide() + window.location.href = "/quotations/" + encodeURIComponent(r.message); + } } }) }) diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py index d390ebf438..1a4028085a 100644 --- a/erpnext/templates/pages/order.py +++ b/erpnext/templates/pages/order.py @@ -16,8 +16,8 @@ def get_context(context): context.parents = frappe.form_dict.parents context.payment_ref = frappe.db.get_value("Payment Request", {"reference_name": frappe.form_dict.name}, "name") - + context.enabled_checkout = frappe.get_doc("Shopping Cart Settings").enable_checkout - + if not context.doc.has_website_permission("read"): frappe.throw(_("Not Permitted"), frappe.PermissionError)