From 107099aac96a6ff36047a35166d79f2b16e2f0ef Mon Sep 17 00:00:00 2001 From: bhupen Date: Wed, 4 Jan 2017 17:01:16 +0530 Subject: [PATCH 1/2] you can make quotation from supplier quotation --- .../supplier_quotation/supplier_quotation.js | 10 ++++++ .../supplier_quotation/supplier_quotation.py | 23 ++++++++++++- .../supplier_quotation_dashboard.py | 3 +- .../selling/doctype/quotation/quotation.json | 32 ++++++++++++++++++- 4 files changed, 65 insertions(+), 3 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js index 0323c2faf0..fc9cc3bc28 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.js @@ -11,6 +11,9 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext cur_frm.add_custom_button(__("Purchase Order"), this.make_purchase_order, __("Make")); cur_frm.page.set_inner_btn_group_as_primary(__("Make")); + cur_frm.add_custom_button(__("Quotation"), this.make_quotation, + __("Make")); + } else if (this.frm.doc.docstatus===0) { cur_frm.add_custom_button(__('Material Request'), @@ -35,6 +38,13 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order", frm: cur_frm }) + }, + make_quotation: function() { + frappe.model.open_mapped_doc({ + method: "erpnext.buying.doctype.supplier_quotation.supplier_quotation.make_quotation", + frm: cur_frm + }) + } }); diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 144e982a04..3a07c24e41 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -97,8 +97,29 @@ def make_purchase_order(source_name, target_doc=None): }, "Purchase Taxes and Charges": { "doctype": "Purchase Taxes and Charges", - "add_if_empty": True }, }, target_doc, set_missing_values) return doclist + +@frappe.whitelist() +def make_quotation(source_name, target_doc=None): + def set_missing_values(source, target): + quotation = frappe.get_doc(target) + + doclist = get_mapped_doc("Supplier Quotation", source_name, { + "Supplier Quotation": { + "doctype": "Quotation", + "field_map": { + "name": "supplier_quotation", + } + }, + "Supplier Quotation Item": { + "doctype": "Quotation Item", + "condition": lambda doc: frappe.db.get_value("Item", doc.item_code, "is_sales_item")==1, + "add_if_empty": True + } + }, target_doc, set_missing_values) + + return doclist + diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py index 80f946e220..df69063aae 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation_dashboard.py @@ -11,11 +11,12 @@ def get_data(): 'transactions': [ { 'label': _('Related'), - 'items': ['Purchase Order'] + 'items': ['Purchase Order', 'Quotation'] }, { 'label': _('Reference'), 'items': ['Material Request', 'Request for Quotation', 'Project'] }, ] + } diff --git a/erpnext/selling/doctype/quotation/quotation.json b/erpnext/selling/doctype/quotation/quotation.json index 4fc536ebd4..a543ecd31f 100644 --- a/erpnext/selling/doctype/quotation/quotation.json +++ b/erpnext/selling/doctype/quotation/quotation.json @@ -2336,6 +2336,35 @@ "search_index": 0, "set_only_once": 0, "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "supplier_quotation", + "fieldtype": "Link", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Supplier Quotation", + "length": 0, + "no_copy": 0, + "options": "Supplier Quotation", + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 } ], "hide_heading": 0, @@ -2350,7 +2379,7 @@ "istable": 0, "max_attachments": 1, "menu_index": 0, - "modified": "2016-11-07 05:58:07.587479", + "modified": "2017-01-04 06:28:07.269867", "modified_by": "Administrator", "module": "Selling", "name": "Quotation", @@ -2537,5 +2566,6 @@ "sort_order": "DESC", "timeline_field": "customer", "title_field": "title", + "track_changes": 0, "track_seen": 0 } \ No newline at end of file From 59a67c3586f9f5a29a7e27a658ef6ba37ab8dbcc Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 5 Jan 2017 14:58:30 +0530 Subject: [PATCH 2/2] Update supplier_quotation.py --- .../buying/doctype/supplier_quotation/supplier_quotation.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py index 3a07c24e41..30899c81cc 100644 --- a/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py +++ b/erpnext/buying/doctype/supplier_quotation/supplier_quotation.py @@ -104,9 +104,6 @@ def make_purchase_order(source_name, target_doc=None): @frappe.whitelist() def make_quotation(source_name, target_doc=None): - def set_missing_values(source, target): - quotation = frappe.get_doc(target) - doclist = get_mapped_doc("Supplier Quotation", source_name, { "Supplier Quotation": { "doctype": "Quotation", @@ -119,7 +116,7 @@ def make_quotation(source_name, target_doc=None): "condition": lambda doc: frappe.db.get_value("Item", doc.item_code, "is_sales_item")==1, "add_if_empty": True } - }, target_doc, set_missing_values) + }, target_doc) return doclist