diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index 4c2298242c5..7c9ca01a5a7 100644 --- a/buying/doctype/purchase_order/purchase_order.js +++ b/buying/doctype/purchase_order/purchase_order.js @@ -27,8 +27,15 @@ wn.require('app/buying/doctype/purchase_common/purchase_common.js'); erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend({ refresh: function(doc, cdt, cdn) { this._super(); + this.frm.dashboard.reset(); if(doc.docstatus == 1 && doc.status != 'Stopped'){ + cur_frm.dashboard.add_progress(cint(doc.per_received) + wn._("% Received"), + doc.per_received); + cur_frm.dashboard.add_progress(cint(doc.per_billed) + wn._("% Billed"), + doc.per_billed); + + cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); if(flt(doc.per_received, 2) < 100) cur_frm.add_custom_button('Make Purchase Receipt', this.make_purchase_receipt); @@ -36,20 +43,15 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( cur_frm.add_custom_button('Make Invoice', this.make_purchase_invoice); if(flt(doc.per_billed, 2) < 100 || doc.per_received < 100) cur_frm.add_custom_button('Stop', cur_frm.cscript['Stop Purchase Order']); + } else if(doc.docstatus===0) { + cur_frm.cscript.add_from_mappers(); } if(doc.docstatus == 1 && doc.status == 'Stopped') cur_frm.add_custom_button('Unstop Purchase Order', cur_frm.cscript['Unstop Purchase Order']); }, - - get_items: function() { - wn.model.map_current_doc({ - method: "stock.doctype.material_request.material_request.make_purchase_order", - source_name: cur_frm.doc.indent_no, - }) - }, - + make_purchase_receipt: function() { wn.model.open_mapped_doc({ method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt", @@ -64,12 +66,36 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend( }) }, - get_supplier_quotation_items: function() { - wn.model.map_current_doc({ - method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order", - source_name: cur_frm.doc.supplier_quotation, - }) + add_from_mappers: function() { + cur_frm.add_custom_button(wn._('From Material Request'), + function() { + wn.model.map_current_doc({ + method: "stock.doctype.material_request.material_request.make_purchase_order", + source_doctype: "Material Request", + get_query_filters: { + material_request_type: "Purchase", + docstatus: 1, + status: ["!=", "Stopped"], + per_ordered: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); + + cur_frm.add_custom_button(wn._('From Supplier Quotation'), + function() { + wn.model.map_current_doc({ + method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order", + source_doctype: "Supplier Quotation", + get_query_filters: { + docstatus: 1, + status: ["!=", "Stopped"], + company: cur_frm.doc.company + } + }) + }); } + }); // for backward compatibility: combine new and previous states @@ -93,14 +119,6 @@ cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = fun AND `tabProject`.name LIKE "%s" ORDER BY `tabProject`.name ASC LIMIT 50'; } -cur_frm.fields_dict['indent_no'].get_query = function(doc) { - return 'SELECT DISTINCT `name` FROM `tabMaterial Request` \ - WHERE material_request_type="Purchase" and company = "' + doc.company - + '" and `docstatus` = 1 and `status` != "Stopped" \ - and ifnull(`per_ordered`,0) < 99.99 and %(key)s LIKE "%s" \ - ORDER BY `name` DESC LIMIT 50'; -} - cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){ $c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '', function(r, rt) { refresh_field(cur_frm.cscript.fname); diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt index d72fc58dcf5..d59d5176285 100644 --- a/buying/doctype/purchase_order/purchase_order.txt +++ b/buying/doctype/purchase_order/purchase_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-07-05 14:51:59", + "modified": "2013-07-08 15:12:46", "modified_by": "Administrator", "owner": "Administrator" }, @@ -183,59 +183,6 @@ "label": "Re-Calculate Values", "oldfieldtype": "Button" }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break" - }, - { - "description": "You can make a purchase order from multiple Material Requests. Select Material Requests one by one and click on the button below.", - "doctype": "DocField", - "fieldname": "indent_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Select Material Request", - "no_copy": 1, - "oldfieldname": "indent_no", - "oldfieldtype": "Link", - "options": "Material Request", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "hidden": 0, - "label": "Get Items", - "no_copy": 0, - "oldfieldtype": "Button", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "description": "You can make a purchase order from multiple Supplier Quotations. Select Supplier Quotations one by one and click on the button below.", - "doctype": "DocField", - "fieldname": "supplier_quotation", - "fieldtype": "Link", - "label": "Select Supplier Quotation", - "no_copy": 1, - "options": "Supplier Quotation", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_supplier_quotation_items", - "fieldtype": "Button", - "label": "Get Items", - "options": "get_supplier_quotation_items", - "print_hide": 1 - }, { "doctype": "DocField", "fieldname": "price_list_and_currency", @@ -269,7 +216,7 @@ "fieldtype": "Float", "hidden": 0, "label": "Exchange Rate", - "no_copy": 0, + "no_copy": 1, "oldfieldname": "conversion_rate", "oldfieldtype": "Currency", "print_hide": 1, diff --git a/buying/doctype/purchase_order_item/purchase_order_item.txt b/buying/doctype/purchase_order_item/purchase_order_item.txt index c561ed1763c..1ee27004df2 100755 --- a/buying/doctype/purchase_order_item/purchase_order_item.txt +++ b/buying/doctype/purchase_order_item/purchase_order_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:06", "docstatus": 0, - "modified": "2013-05-31 14:26:22", + "modified": "2013-07-08 13:51:42", "modified_by": "Administrator", "owner": "Administrator" }, @@ -32,7 +32,7 @@ "hidden": 0, "in_filter": 1, "label": "Reqd By Date", - "no_copy": 1, + "no_copy": 0, "oldfieldname": "schedule_date", "oldfieldtype": "Date", "print_hide": 1, @@ -121,7 +121,7 @@ "doctype": "DocField", "fieldname": "import_ref_rate", "fieldtype": "Currency", - "label": "Ref Rate ", + "label": "Price List Rate", "options": "currency", "print_hide": 1, "read_only": 0 diff --git a/buying/doctype/supplier_quotation/supplier_quotation.js b/buying/doctype/supplier_quotation/supplier_quotation.js index 8ecb6ea230e..ef688ec5cde 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.js +++ b/buying/doctype/supplier_quotation/supplier_quotation.js @@ -29,16 +29,25 @@ erpnext.buying.SupplierQuotationController = erpnext.buying.BuyingController.ext if (this.frm.doc.docstatus === 1) { cur_frm.add_custom_button("Make Purchase Order", this.make_purchase_order); + } + else if (this.frm.doc.docstatus===0) { + cur_frm.add_custom_button(wn._('From Material Request'), + function() { + wn.model.map_current_doc({ + method: "stock.doctype.material_request.material_request.make_supplier_quotation", + source_doctype: "Material Request", + get_query_filters: { + material_request_type: "Purchase", + docstatus: 1, + status: ["!=", "Stopped"], + per_ordered: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); } }, - - get_items: function() { - wn.model.map_current_doc({ - method: "stock.doctype.material_request.material_request.make_supplier_quotation", - source_name: cur_frm.doc.indent_no, - }) - }, - + make_purchase_order: function() { wn.model.open_mapped_doc({ method: "buying.doctype.supplier_quotation.supplier_quotation.make_purchase_order", @@ -62,14 +71,6 @@ cur_frm.fields_dict['quotation_items'].grid.get_field('project_name').get_query order by `tabProject`.name ASC LIMIT 50"; } -cur_frm.fields_dict['indent_no'].get_query = function(doc) { - return "select distinct `name` from `tabMaterial Request` \ - where material_request_type='Purchase' and company = \"" + doc.company + - "\" and `docstatus` = 1 and `status` != \"Stopped\" and \ - ifnull(`per_ordered`,0) < 99.99 and \ - %(key)s LIKE \"%s\" order by `name` desc limit 50"; -} - cur_frm.cscript.supplier_address = function(doc, dt, dn) { if (doc.supplier) { get_server_fields("get_supplier_address", JSON.stringify({supplier: doc.supplier, diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt index 95fe364d01a..0984ac7ffa6 100644 --- a/buying/doctype/supplier_quotation/supplier_quotation.txt +++ b/buying/doctype/supplier_quotation/supplier_quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:45", "docstatus": 0, - "modified": "2013-07-05 14:57:12", + "modified": "2013-07-08 15:14:48", "modified_by": "Administrator", "owner": "Administrator" }, @@ -168,32 +168,6 @@ "label": "Re-Calculate Values", "oldfieldtype": "Button" }, - { - "doctype": "DocField", - "fieldname": "section_break_14", - "fieldtype": "Section Break" - }, - { - "description": "You can make a purchase order from multiple Material Requests. Select Material Requests one by one and click on the button below.", - "doctype": "DocField", - "fieldname": "indent_no", - "fieldtype": "Link", - "hidden": 0, - "label": "Select Material Request", - "no_copy": 1, - "oldfieldname": "indent_no", - "oldfieldtype": "Link", - "options": "Material Request", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "hidden": 0, - "label": "Get Items", - "oldfieldtype": "Button" - }, { "doctype": "DocField", "fieldname": "currency_price_list", diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 98a8c42d981..877f65c2528 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -53,6 +53,25 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ } cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); } + + if (this.frm.doc.docstatus===0) { + cur_frm.add_custom_button(wn._('From Opportunity'), + function() { + wn.model.map_current_doc({ + method: "selling.doctype.opportunity.opportunity.make_quotation", + source_doctype: "Opportunity", + get_query_filters: { + docstatus: 1, + status: "Submitted", + enquiry_type: cur_frm.doc.order_type, + customer: cur_frm.doc.customer || undefined, + lead: cur_frm.doc.lead || undefined, + company: cur_frm.doc.company + } + }) + }); + } + if (!doc.__islocal) { cur_frm.communication_view = new wn.views.CommunicationList({ @@ -70,6 +89,10 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead"); this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer"); }, + + tc_name: function() { + this.get_terms(); + }, validate_company_and_party: function(party_field) { if(this.frm.doc.quotation_to == "Lead") { @@ -113,17 +136,6 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) { } -// ===================================================================================== -cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){ - var cond=''; - var cond1=''; - if(doc.order_type) cond = 'ifnull(`tabOpportunity`.enquiry_type, "") = "'+doc.order_type+'" AND'; - if(doc.customer) cond1 = '`tabOpportunity`.customer = "'+doc.customer+'" AND'; - else if(doc.lead) cond1 = '`tabOpportunity`.lead = "'+doc.lead+'" AND'; - - return repl('SELECT `tabOpportunity`.`name` FROM `tabOpportunity` WHERE `tabOpportunity`.`docstatus` = 1 AND `tabOpportunity`.status = "Submitted" AND %(cond)s %(cond1)s `tabOpportunity`.`name` LIKE "%s" ORDER BY `tabOpportunity`.`name` ASC LIMIT 50', {cond:cond, cond1:cond1}); -} - // Make Sales Order // ===================================================================================== cur_frm.cscript['Make Sales Order'] = function() { @@ -133,14 +145,6 @@ cur_frm.cscript['Make Sales Order'] = function() { }) } -//pull enquiry details -cur_frm.cscript.pull_enquiry_detail = function(doc,cdt,cdn){ - wn.model.map_current_doc({ - method: "selling.doctype.opportunity.opportunity.make_quotation", - source_name: cur_frm.doc.enq_no, - }) -} - // declare order lost //------------------------- cur_frm.cscript['Declare Order Lost'] = function(){ diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index fb77282573e..243963c9440 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:08", "docstatus": 0, - "modified": "2013-07-05 14:52:37", + "modified": "2013-07-08 15:51:41", "modified_by": "Administrator", "owner": "Administrator" }, @@ -344,42 +344,6 @@ "fieldtype": "Section Break", "read_only": 0 }, - { - "description": "To create Quotation against Opportunity, Select Opportunity No. and click on 'Pull Opportunity Details' ", - "doctype": "DocField", - "fieldname": "enq_no", - "fieldtype": "Link", - "hidden": 0, - "in_filter": 1, - "label": "Opportunity No", - "no_copy": 0, - "oldfieldname": "enq_no", - "oldfieldtype": "Link", - "options": "Opportunity", - "print_hide": 0, - "read_only": 0, - "report_hide": 0, - "search_index": 0 - }, - { - "doctype": "DocField", - "fieldname": "pull_enquiry_detail", - "fieldtype": "Button", - "hidden": 0, - "label": "Pull Opportunity Detail", - "no_copy": 0, - "oldfieldtype": "Button", - "print_hide": 0, - "read_only": 0, - "report_hide": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break34", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, { "doctype": "DocField", "fieldname": "net_total_export", @@ -634,24 +598,6 @@ "read_only": 0, "report_hide": 1 }, - { - "doctype": "DocField", - "fieldname": "column_break_54", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_56", - "fieldtype": "Section Break" - }, { "doctype": "DocField", "fieldname": "terms", diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index 7ba0bb43548..700a61a6f90 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -325,21 +325,18 @@ class DocType(TransactionBase): if so_status == 'Stopped': msgprint("You cannot do any transaction against Sales Order : '%s' as it is Stopped." %(ref_doc_name)) raise Exception - - - # ****** Check for Item.is_sales_item = 'Yes' and Item.docstatus != 2 ******* + def check_active_sales_items(self,obj): for d in getlist(obj.doclist, obj.fname): - if d.item_code: # extra condn coz item_code is not mandatory in RV - valid_item = webnotes.conn.sql("select docstatus,is_sales_item, is_service_item from tabItem where name = %s",d.item_code) - if valid_item and valid_item[0][0] == 2: - msgprint("Item : '%s' does not exist in system." %(d.item_code)) - raise Exception - sales_item = valid_item and valid_item[0][1] or 'No' - service_item = valid_item and valid_item[0][2] or 'No' - if sales_item == 'No' and service_item == 'No': - msgprint("Item : '%s' is neither Sales nor Service Item"%(d.item_code)) + if d.item_code: + item = webnotes.conn.sql("""select docstatus, is_sales_item, + is_service_item, default_income_account, default_expense_account from tabItem where name = %s""", + d.item_code, as_dict=True) + if item.sales_item == 'No' and item.service_item == 'No': + msgprint("Item : '%s' is neither Sales nor Service Item" % (d.item_code)) raise Exception + if d.income_account and not default_income_account: + webnotes.conn.set_value("Item", d.item_code, "default_income_account", d.income_account) # ************************************************************************************************************************************************** diff --git a/stock/doctype/material_request/material_request.js b/stock/doctype/material_request/material_request.js index 7efd49bf786..bd5ab8239be 100644 --- a/stock/doctype/material_request/material_request.js +++ b/stock/doctype/material_request/material_request.js @@ -52,16 +52,32 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten } cur_frm.add_custom_button('Send SMS', cur_frm.cscript.send_sms); + } + + if (this.frm.doc.docstatus===0) { + cur_frm.add_custom_button(wn._('From Sales Order'), + function() { + wn.model.map_current_doc({ + method: "selling.doctype.sales_order.sales_order.make_material_request", + source_doctype: "Sales Order", + get_query_filters: { + docstatus: 1, + status: ["!=", "Stopped"], + per_delivered: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); } if(doc.docstatus == 1 && doc.status == 'Stopped') cur_frm.add_custom_button('Unstop Material Request', cur_frm.cscript['Unstop Material Request']); - if(doc.material_request_type === "Transfer") { - cur_frm.toggle_display("sales_order_no", false); - cur_frm.fields_dict.indent_details.grid.set_column_disp("sales_order_no", false); - } + }, + + tc_name: function() { + this.get_terms(); }, validate_company_and_party: function(party_field) { @@ -71,14 +87,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten calculate_taxes_and_totals: function() { return; }, - - pull_sales_order_details: function(doc) { - wn.model.map_current_doc({ - method: "selling.doctype.sales_order.sales_order.make_material_request", - source_name: cur_frm.doc.sales_order_no, - }); - }, - + make_purchase_order: function() { wn.model.open_mapped_doc({ method: "stock.doctype.material_request.material_request.make_purchase_order", diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt index a5907c7bacf..0f1036bdaed 100644 --- a/stock/doctype/material_request/material_request.txt +++ b/stock/doctype/material_request/material_request.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-07 14:48:38", "docstatus": 0, - "modified": "2013-07-08 11:02:12", + "modified": "2013-07-08 15:40:01", "modified_by": "Administrator", "owner": "Administrator" }, @@ -98,44 +98,6 @@ "oldfieldtype": "Table", "options": "Material Request Item" }, - { - "doctype": "DocField", - "fieldname": "section_break1", - "fieldtype": "Section Break" - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "description": "One or multiple Sales Order no which generated this Material Request", - "doctype": "DocField", - "fieldname": "sales_order_no", - "fieldtype": "Link", - "label": "Sales Order No", - "no_copy": 1, - "oldfieldname": "sales_order_no", - "oldfieldtype": "Data", - "options": "Sales Order", - "print_width": "100px", - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "column_break5", - "fieldtype": "Column Break", - "print_width": "50%", - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "pull_sales_order_details", - "fieldtype": "Button", - "label": "Pull Sales Order Items" - }, { "default": "Give additional details about the indent.", "doctype": "DocField", @@ -308,13 +270,6 @@ "print_hide": 1, "report_hide": 1 }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button" - }, { "doctype": "DocField", "fieldname": "terms", diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 878dfe80288..1ebc5ae4638 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -68,7 +68,10 @@ class DocType(BuyingController): msgprint("Rejected Warehouse is necessary if there are rejections.") raise Exception - if not flt(d.qty) and flt(d.rejected_qty): + if not flt(d.received_qty) and flt(d.qty): + d.received_qty = flt(d.qty) - flt(d.rejected_qty) + + elif not flt(d.qty) and flt(d.rejected_qty): d.qty = flt(d.received_qty) - flt(d.rejected_qty) elif not flt(d.rejected_qty): diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt index 6a35c471acf..658dabb7b95 100755 --- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:10", "docstatus": 0, - "modified": "2013-05-31 14:26:41", + "modified": "2013-07-08 13:52:28", "modified_by": "Administrator", "owner": "Administrator" }, @@ -165,7 +165,7 @@ "doctype": "DocField", "fieldname": "purchase_ref_rate", "fieldtype": "Currency", - "label": "Ref Rate*", + "label": "Price List Rate*", "options": "Company:company:default_currency", "print_hide": 1, "read_only": 0