From 107099aac96a6ff36047a35166d79f2b16e2f0ef Mon Sep 17 00:00:00 2001 From: bhupen Date: Wed, 4 Jan 2017 17:01:16 +0530 Subject: [PATCH] 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 0323c2faf00..fc9cc3bc28c 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 144e982a04b..3a07c24e411 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 80f946e2204..df69063aae6 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 4fc536ebd42..a543ecd31fe 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