diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 1b952ddcbc5..27ca6fcf62f 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -51,7 +51,38 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext wn.set_route("general-ledger"); }); } - + + if(doc.docstatus===0) { + cur_frm.add_custom_button(wn._('From Purchase Order'), + function() { + wn.model.map_current_doc({ + method: "buying.doctype.purchase_order.purchase_order.make_purchase_invoice", + source_doctype: "Purchase Order", + get_query_filters: { + supplier: cur_frm.doc.supplier || undefined, + docstatus: 1, + status: ["!=", "Stopped"], + per_billed: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); + + cur_frm.add_custom_button(wn._('From Purchase Receipt'), + function() { + wn.model.map_current_doc({ + method: "stock.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", + source_doctype: "Purchase Receipt", + get_query_filters: { + supplier: cur_frm.doc.supplier || undefined, + docstatus: 1, + company: cur_frm.doc.company + } + }) + }); + + } + this.is_opening(doc); }, @@ -68,22 +99,11 @@ erpnext.accounts.PurchaseInvoiceController = erpnext.buying.BuyingController.ext this.calculate_total_advance("Purchase Invoice", "advance_allocation_details"); this.frm.refresh_fields(); }, - - get_items: function() { - if(doc.purchase_order_main) { - wn.model.map_current_doc({ - method: "buying.doctype.purchase_order.purchase_order.make_purchase_invoice", - source_name: cur_frm.doc.purchase_order_main, - }) - } - else if(doc.purchase_receipt_main) { - wn.model.map_current_doc({ - method: "selling.doctype.purchase_receipt.purchase_receipt.make_purchase_invoice", - source_name: cur_frm.doc.purchase_receipt_main, - }) - } - } - + + tc_name: function() { + this.get_terms(); + }, + }); // for backward compatibility: combine new and previous states diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 059073aeec3..56be688a812 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -43,17 +43,6 @@ class DocType(BuyingController): 'target_ref_field': 'import_amount', 'source_field': 'import_amount', 'percent_join_field': 'purchase_order', - }, - { - 'source_dt': 'Purchase Invoice Item', - 'target_dt': 'Purchase Receipt Item', - 'join_field': 'pr_detail', - 'target_field': 'billed_amt', - 'target_parent_dt': 'Purchase Receipt', - 'target_parent_field': 'per_billed', - 'target_ref_field': 'import_amount', - 'source_field': 'import_amount', - 'percent_join_field': 'purchase_receipt', }] def validate(self): @@ -65,7 +54,6 @@ class DocType(BuyingController): self.check_conversion_rate() self.validate_bill_no_date() self.validate_bill_no() - self.validate_reference_value() self.validate_credit_acc() self.clear_unallocated_advances("Purchase Invoice Advance", "advance_allocation_details") self.check_for_acc_head_of_supplier() @@ -244,12 +232,9 @@ class DocType(BuyingController): msgprint("Supplier name %s do not match with supplier name of %s %s." %(self.doc.supplier,cstr(d.purchase_receipt))) raise Exception , " Validation Error " - # Validate values with reference document - #---------------------------------------- def validate_reference_value(self): - get_obj('DocType Mapper', 'Purchase Order-Purchase Invoice', with_children = 1).validate_reference_value(self, self.doc.name) - - + pass + # Validate PO and PR # ------------------- def validate_po_pr(self, d): diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.txt b/accounts/doctype/purchase_invoice/purchase_invoice.txt index 6c1e24d7886..779b0564040 100755 --- a/accounts/doctype/purchase_invoice/purchase_invoice.txt +++ b/accounts/doctype/purchase_invoice/purchase_invoice.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-21 16:16:39", "docstatus": 0, - "modified": "2013-07-05 14:51:53", + "modified": "2013-07-08 18:03:17", "modified_by": "Administrator", "owner": "Administrator" }, @@ -31,6 +31,7 @@ "parent": "Purchase Invoice", "parentfield": "permissions", "parenttype": "DocType", + "permlevel": 0, "read": 1, "report": 1 }, @@ -212,12 +213,6 @@ "options": "Purchase Invoice Item", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "recalculate", @@ -226,44 +221,6 @@ "oldfieldtype": "Button", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "section_break_17", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "description": "Select Items from Purchase Order", - "doctype": "DocField", - "fieldname": "purchase_order_main", - "fieldtype": "Link", - "label": "Purchase Order", - "oldfieldname": "purchase_order_main", - "oldfieldtype": "Link", - "options": "Purchase Order", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Select Items from Purchase Receipt", - "doctype": "DocField", - "fieldname": "purchase_receipt_main", - "fieldtype": "Link", - "label": "Purchase Receipt", - "oldfieldname": "purchase_receipt_main", - "oldfieldtype": "Link", - "options": "Purchase Receipt", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "label": "Get Items", - "oldfieldtype": "Button", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "currency_price_list", @@ -694,12 +651,6 @@ "options": "Terms and Conditions", "print_hide": 1 }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions" - }, { "doctype": "DocField", "fieldname": "terms", @@ -836,69 +787,50 @@ "read_only": 0, "reqd": 0 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Accounts Manager", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "role": "Accounts Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Accounts User", - "submit": 0, - "write": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Purchase User", - "submit": 0 - }, - { - "amend": 0, - "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "role": "Purchase User", - "submit": 0, - "write": 1 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, "role": "Accounts User", "submit": 1, "write": 1 }, { + "amend": 0, + "cancel": 0, + "create": 1, + "doctype": "DocPerm", + "role": "Purchase User", + "submit": 0, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, "doctype": "DocPerm", "match": "supplier", - "permlevel": 0, - "role": "Supplier" + "role": "Supplier", + "submit": 0, + "write": 0 + }, + { + "amend": 1, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "role": "Accounts Manager", + "submit": 1, + "write": 1 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "role": "Auditor", + "submit": 0, + "write": 0 } ] \ No newline at end of file diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 2c07eafd8eb..7203a1ce9ee 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -66,8 +66,44 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if(doc.outstanding_amount!=0) cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher); } + + 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_sales_invoice", + source_doctype: "Sales Order", + get_query_filters: { + docstatus: 1, + status: ["!=", "Stopped"], + per_billed: ["<", 99.99], + customer: cur_frm.doc.customer || undefined, + company: cur_frm.doc.company + } + }) + }); + + cur_frm.add_custom_button(wn._('From Delivery Note'), + function() { + wn.model.map_current_doc({ + method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice", + source_doctype: "Delivery Note", + get_query_filters: { + docstatus: 1, + customer: cur_frm.doc.customer || undefined, + company: cur_frm.doc.company + } + }) + }); + + } + cur_frm.cscript.hide_fields(doc, dt, dn); }, + + tc_name: function() { + this.get_terms(); + }, is_pos: function() { if(cint(this.frm.doc.is_pos)) { @@ -122,9 +158,8 @@ $.extend(cur_frm.cscript, new erpnext.accounts.SalesInvoiceController({frm: cur_ // Hide Fields // ------------ cur_frm.cscript.hide_fields = function(doc, cdt, cdn) { - par_flds = ['project_name', 'due_date', 'sales_order_main', - 'delivery_note_main', 'get_items', 'is_opening', 'conversion_rate', - 'source', 'cancel_reason', 'total_advance', 'gross_profit', + par_flds = ['project_name', 'due_date', 'is_opening', 'conversion_rate', + 'source', 'total_advance', 'gross_profit', 'gross_profit_percent', 'get_advances_received', 'advance_adjustment_details', 'sales_partner', 'commission_rate', 'total_commission', 'advances']; @@ -190,41 +225,14 @@ cur_frm.cscript.is_opening = function(doc, dt, dn) { if (doc.is_opening == 'Yes') unhide_field('aging_date'); } -// Get Items based on SO or DN Selected -cur_frm.cscript.get_items = function(doc, dt, dn) { - if(doc.delivery_note_main) { - wn.model.map_current_doc({ - method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice", - source_name: cur_frm.doc.delivery_note_main, - }) - } - else if(doc.sales_order_main) { - wn.model.map_current_doc({ - method: "selling.doctype.sales_order.sales_order.make_sales_invoice", - source_name: cur_frm.doc.sales_order_main, - }) - } -} - - - //Make Delivery Note Button //----------------------------- cur_frm.cscript['Make Delivery Note'] = function() { - - var doc = cur_frm.doc - n = wn.model.make_new_doc_and_get_name('Delivery Note'); - $c('dt_map', args={ - 'docs':wn.model.compress([locals['Delivery Note'][n]]), - 'from_doctype':doc.doctype, - 'to_doctype':'Delivery Note', - 'from_docname':doc.name, - 'from_to_list':"[['Sales Invoice','Delivery Note'],['Sales Invoice Item','Delivery Note Item'],['Sales Taxes and Charges','Sales Taxes and Charges'],['Sales Team','Sales Team']]" - }, function(r,rt) { - loaddoc('Delivery Note', n); - } - ); + wn.model.open_mapped_doc({ + method: "accounts.doctype.sales_invoice.sales_invoice.make_delivery_note", + source_name: cur_frm.doc.name + }) } cur_frm.cscript.make_bank_voucher = function() { @@ -399,8 +407,6 @@ cur_frm.fields_dict.delivery_note_main.get_query = function(doc) { } } - - cur_frm.cscript.income_account = function(doc, cdt, cdn){ cur_frm.cscript.copy_account_in_all_row(doc, cdt, cdn, "income_account"); } diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index c1556363bcc..fbc30c9e51d 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -51,20 +51,6 @@ class DocType(SellingController): 'percent_join_field': 'sales_order', 'status_field': 'billing_status', 'keyword': 'Billed' - }, - { - 'source_dt': 'Sales Invoice Item', - 'target_dt': 'Delivery Note Item', - 'join_field': 'dn_detail', - 'target_field': 'billed_amt', - 'target_parent_dt': 'Delivery Note', - 'target_parent_field': 'per_billed', - 'target_ref_field': 'export_amount', - 'source_field': 'export_amount', - 'percent_join_field': 'delivery_note', - 'status_field': 'billing_status', - 'keyword': 'Billed', - 'no_tolerance': True, }] diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index 7dc68917934..e4da69eef15 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.txt +++ b/accounts/doctype/sales_invoice/sales_invoice.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:05", "docstatus": 0, - "modified": "2013-07-05 14:54:19", + "modified": "2013-07-08 17:05:43", "modified_by": "Administrator", "owner": "Administrator" }, @@ -350,52 +350,6 @@ "print_hide": 1, "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "description": "Select Items from Sales Order", - "doctype": "DocField", - "fieldname": "sales_order_main", - "fieldtype": "Link", - "label": "Sales Order", - "oldfieldname": "sales_order_main", - "oldfieldtype": "Link", - "options": "Sales Order", - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Select Items from Delivery Note", - "doctype": "DocField", - "fieldname": "delivery_note_main", - "fieldtype": "Link", - "label": "Delivery Note", - "oldfieldname": "delivery_note_main", - "oldfieldtype": "Link", - "options": "Delivery Note", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "label": "Get Items", - "oldfieldtype": "Button", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break25", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, { "doctype": "DocField", "fieldname": "net_total_export", @@ -789,25 +743,6 @@ "print_hide": 1, "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "column_break_71", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_73", - "fieldtype": "Section Break" - }, { "doctype": "DocField", "fieldname": "terms", diff --git a/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt b/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt index e84c597b1df..a9a18e72930 100644 --- a/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt +++ b/accounts/report/delivered_items_to_be_billed/delivered_items_to_be_billed.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-25 10:38:57", + "creation": "2013-05-02 15:20:25", "docstatus": 0, - "modified": "2013-05-01 11:56:43", + "modified": "2013-07-08 11:08:23", "modified_by": "Administrator", "owner": "Administrator" }, @@ -10,7 +10,7 @@ "doctype": "Report", "is_standard": "Yes", "name": "__common__", - "query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc", + "query": "select \n `tabDelivery Note`.`name` as \"Delivery Note:Link/Delivery Note:120\",\n`tabDelivery Note`.`customer` as \"Customer:Link/Customer:120\",\n`tabDelivery Note`.`status` as \"Status\",\n `tabDelivery Note`.`posting_date` as \"Date:Date\",\n `tabDelivery Note`.`project_name` as \"Project\",\n `tabDelivery Note Item`.item_code as \"Item:Link/Item:120\",\n `tabDelivery Note Item`.amount as \"Amount:Currency:110\",\n (`tabDelivery Note Item`.billed_amt * ifnull(`tabDelivery Note`.conversion_rate, 1)) as \"Billed Amount:Currency:110\",\n (ifnull(`tabDelivery Note Item`.amount,0) - (ifnull(`tabDelivery Note Item`.billed_amt,0) * ifnull(`tabDelivery Note`.conversion_rate, 1))) as \"Pending Amount:Currency:120\",\n `tabDelivery Note Item`.item_name as \"Item Name::150\",\n `tabDelivery Note Item`.description as \"Description:Data:200\",\n `tabDelivery Note Item`.prevdoc_docname as \"Sales Order:Link/Sales Order:120\",\n `tabDelivery Note Item`.prevdoc_date as \"SO Date:Date:100\",\n `tabDelivery Note`.address_display as \"Customer Address::150\"\nfrom\n `tabDelivery Note`, `tabDelivery Note Item`\nwhere\n `tabDelivery Note Item`.`parent` = `tabDelivery Note`.`name`\n and `tabDelivery Note`.docstatus = 1\n and `tabDelivery Note`.status != \"Stopped\"\n and ifnull(`tabDelivery Note Item`.billed_amt,0) < ifnull(`tabDelivery Note Item`.export_amount,0)\norder by `tabDelivery Note`.posting_date asc", "ref_doctype": "Sales Invoice", "report_name": "Delivered Items To Be Billed", "report_type": "Query Report" diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 2d20e3c84f7..4bccce09198 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -231,16 +231,6 @@ class DocType(BuyingController): else: chk_dupl_itm.append(f) - def validate_reference_value(self, obj): - ref_doc = [] - for d in getlist(obj.doclist, obj.fname): - if d.prevdoc_doctype and d.prevdoc_docname and d.prevdoc_doctype not in ref_doc: - mapper_name = d.prevdoc_doctype + '-' + obj.doc.doctype - get_obj('DocType Mapper', mapper_name, with_children = 1).\ - validate_reference_value(obj, obj.doc.name) - ref_doc.append(d.prevdoc_doctype) - - # Check for Stopped status def check_for_stopped_status(self, doctype, docname): stopped = sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" % @@ -248,7 +238,10 @@ class DocType(BuyingController): if stopped: msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % ( doctype, docname), raise_exception=1) - + + def validate_reference_value(self, obj=None): + pass + # Check Docstatus of Next DocType on Cancel AND of Previous DocType on Submit def check_docstatus(self, check, doctype, docname , detail_doctype = ''): diff --git a/buying/doctype/purchase_order/purchase_order.js b/buying/doctype/purchase_order/purchase_order.js index ae91e39e4aa..1283ebc434f 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,40 @@ 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 + } + }) + }); + }, + + tc_name: function() { + this.get_terms(); + }, + }); // for backward compatibility: combine new and previous states diff --git a/buying/doctype/purchase_order/purchase_order.py b/buying/doctype/purchase_order/purchase_order.py index 169dcaaef7f..10d45344f62 100644 --- a/buying/doctype/purchase_order/purchase_order.py +++ b/buying/doctype/purchase_order/purchase_order.py @@ -44,23 +44,13 @@ class DocType(BuyingController): utilities.validate_status(self.doc.status, ["Draft", "Submitted", "Stopped", "Cancelled"]) - # Step 2:=> get Purchase Common Obj pc_obj = get_obj(dt='Purchase Common') - - - # Step 4:=> validate for items pc_obj.validate_for_items(self) - - # Get po date pc_obj.get_prevdoc_date(self) - - # validate_doc + self.validate_doc(pc_obj) - - # Check for stopped status self.check_for_stopped_status(pc_obj) - - # sub-contracting + self.validate_for_subcontracting() self.update_raw_materials_supplied("po_raw_material_details") @@ -244,7 +234,6 @@ def make_purchase_receipt(source_name, target_doclist=None): def make_purchase_invoice(source_name, target_doclist=None): from webnotes.model.mapper import get_mapped_doclist - def set_missing_values(source, target): bean = webnotes.bean(target) bean.run_method("set_missing_values") @@ -254,7 +243,8 @@ def make_purchase_invoice(source_name, target_doclist=None): target.conversion_factor = 1 target.import_amount = flt(obj.import_amount) - flt(obj.billed_amt) target.amount = target.import_amount / flt(source_parent.conversion_rate) - target.qty = target.amount / flt(obj.purchase_rate) + if flt(obj.purchase_rate): + target.qty = target.amount / flt(obj.purchase_rate) doclist = get_mapped_doclist("Purchase Order", source_name, { "Purchase Order": { diff --git a/buying/doctype/purchase_order/purchase_order.txt b/buying/doctype/purchase_order/purchase_order.txt index d72fc58dcf5..f9e8375e103 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 17:49:29", "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, @@ -541,13 +488,6 @@ "options": "Terms and Conditions", "print_hide": 1 }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button" - }, { "doctype": "DocField", "fieldname": "terms", diff --git a/buying/doctype/purchase_order/test_purchase_order.py b/buying/doctype/purchase_order/test_purchase_order.py index 85420d84930..e70de97df67 100644 --- a/buying/doctype/purchase_order/test_purchase_order.py +++ b/buying/doctype/purchase_order/test_purchase_order.py @@ -32,10 +32,13 @@ class TestPurchaseOrder(unittest.TestCase): po = webnotes.bean("Purchase Order", po.doc.name) po.submit() pr = make_purchase_receipt(po.doc.name) + pr[0]["supplier_warehouse"] = "_Test Warehouse 1" self.assertEquals(pr[0]["doctype"], "Purchase Receipt") self.assertEquals(len(pr), len(test_records[0])) + webnotes.bean(pr).insert() + def test_make_purchase_invocie(self): from buying.doctype.purchase_order.purchase_order import make_purchase_invoice @@ -50,10 +53,12 @@ class TestPurchaseOrder(unittest.TestCase): self.assertEquals(pi[0]["doctype"], "Purchase Invoice") self.assertEquals(len(pi), len(test_records[0])) + + webnotes.bean(pi).insert() def test_subcontracting(self): po = webnotes.bean(copy=test_records[0]) - po.insert() + po.insert() self.assertEquals(len(po.doclist.get({"parentfield": "po_raw_material_details"})), 2) def test_warehouse_company_validation(self): 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 ffa23d8f4b4..d0f1948ef03 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", 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/buying/doctype/supplier_quotation/test_supplier_quotation.py b/buying/doctype/supplier_quotation/test_supplier_quotation.py index 0210b7fdc8a..7e772cc4d7a 100644 --- a/buying/doctype/supplier_quotation/test_supplier_quotation.py +++ b/buying/doctype/supplier_quotation/test_supplier_quotation.py @@ -36,6 +36,8 @@ class TestPurchaseOrder(unittest.TestCase): self.assertEquals(po[0]["doctype"], "Purchase Order") self.assertEquals(len(po), len(sq.doclist)) + webnotes.bean(po).insert() + test_records = [ [ { @@ -45,7 +47,7 @@ test_records = [ "doctype": "Supplier Quotation", "fiscal_year": "_Test Fiscal Year 2013", "transaction_date": "2013-02-12", - "is_subcontracted": "Yes", + "is_subcontracted": "No", "supplier": "_Test Supplier", "supplier_name": "_Test Supplier", "net_total": 5000.0, diff --git a/buying/utils.py b/buying/utils.py index 23d55938a28..886b460e935 100644 --- a/buying/utils.py +++ b/buying/utils.py @@ -85,7 +85,8 @@ def _get_basic_details(args, item_bean): "item_tax_rate": json.dumps(dict(([d.tax_type, d.tax_rate] for d in item_bean.doclist.get({"parentfield": "item_tax"})))), "batch_no": None, - "expense_head": item.purchase_account, + "expense_head": item.purchase_account \ + or webnotes.conn.get_value("Company", args.company, "default_expense_account"), "cost_center": item.cost_center }) diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index e58eb03ca95..a44ceba9c32 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -34,6 +34,9 @@ class BuyingController(StockController): def validate(self): super(BuyingController, self).validate() + if self.doc.supplier and not self.doc.supplier_name: + self.doc.supplier_name = webnotes.conn.get_value("Supplier", + self.doc.supplier, "supplier_name") self.validate_stock_or_nonstock_items() self.validate_warehouse_belongs_to_company() @@ -47,11 +50,13 @@ class BuyingController(StockController): for fieldname, val in self.get_default_address_and_contact("supplier").items(): if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname): self.doc.fields[fieldname] = val - + self.set_missing_item_details(get_item_details) - + def set_supplier_defaults(self): - self.doc.fields.update(self.get_default_supplier_address(self.doc.fields)) + for fieldname, val in self.get_default_address_and_contact("supplier").items(): + if self.meta.get_field(fieldname): + self.doc.fields[fieldname] = val def get_purchase_tax_details(self): self.doclist = self.doc.clear_table(self.doclist, "purchase_tax_details") diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py index d1ce3ccf1db..e3e43e471d0 100644 --- a/hr/doctype/salary_slip/salary_slip.py +++ b/hr/doctype/salary_slip/salary_slip.py @@ -62,7 +62,8 @@ class DocType(TransactionBase): self.doclist = self.doc.clear_table(self.doclist, 'earning_details') self.doclist = self.doc.clear_table(self.doclist, 'deduction_details') - get_obj('DocType Mapper', 'Salary Structure-Salary Slip').dt_map('Salary Structure', 'Salary Slip', struct, self.doc, self.doclist, "[['Salary Structure', 'Salary Slip'],['Salary Structure Earning', 'Salary Slip Earning'],['Salary Structure Deduction','Salary Slip Deduction']]") + from hr.doctype.salary_structure.salary_structure import make_salary_slip + make_salary_slip(struct, self.doclist) basic_info = sql("select bank_name, bank_ac_no, esic_card_no, pf_number from `tabEmployee` where name ='%s'" % self.doc.employee) self.doc.bank_name = basic_info[0][0] diff --git a/hr/doctype/salary_structure/salary_structure.py b/hr/doctype/salary_structure/salary_structure.py index d7777561f84..f890024f70c 100644 --- a/hr/doctype/salary_structure/salary_structure.py +++ b/hr/doctype/salary_structure/salary_structure.py @@ -22,8 +22,6 @@ from webnotes.model.doc import addchild, make_autoname from webnotes import msgprint, _ sql = webnotes.conn.sql - - class DocType: def __init__(self,doc,doclist=[]): diff --git a/manufacturing/doctype/production_order/production_order.js b/manufacturing/doctype/production_order/production_order.js index 4c41d947150..77dce03d587 100644 --- a/manufacturing/doctype/production_order/production_order.js +++ b/manufacturing/doctype/production_order/production_order.js @@ -28,8 +28,8 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { if(doc.docstatus===0 && !doc.__islocal) { cur_frm.set_intro("Submit this Production Order for further processing."); } else if(doc.docstatus===1) { - var percent = flt(doc.produced_qty) / doc.qty * 100; - cur_frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete")); + var percent = flt(doc.produced_qty) / flt(doc.qty) * 100; + cur_frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent); if(doc.status === "Stopped") { cur_frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop"); diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index c76a87f6b86..2d5b5fa3c5d 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -76,9 +76,9 @@ class DocType: (self.doc.sales_order, self.doc.production_item))[0][0] # total qty in SO so_qty = flt(so_item_qty) + flt(dnpi_qty) - + if ordered_qty_against_so > so_qty: - msgprint("""Total production order qty for item: %s against sales order: %s \ + webnotes.msgprint("""Total production order qty for item: %s against sales order: %s \ will be %s, which is greater than sales order qty (%s). Please reduce qty or remove the item.""" % (self.doc.production_item, self.doc.sales_order, diff --git a/patches/december_2012/remove_project_mapper.py b/patches/december_2012/remove_project_mapper.py deleted file mode 100644 index 39aae6b764b..00000000000 --- a/patches/december_2012/remove_project_mapper.py +++ /dev/null @@ -1,6 +0,0 @@ -import webnotes - -def execute(): - from webnotes.model import delete_doc - for d in ["Project-Sales Order", "Project-Delivery Note", "Project-Sales Invoice"]: - delete_doc("DocType Mapper", d) \ No newline at end of file diff --git a/patches/february_2013/p06_material_request_mappers.py b/patches/february_2013/p06_material_request_mappers.py deleted file mode 100644 index 374588b6e0e..00000000000 --- a/patches/february_2013/p06_material_request_mappers.py +++ /dev/null @@ -1,7 +0,0 @@ -import webnotes - -def execute(): - webnotes.reload_doc("buying", "DocType Mapper", "Material Request-Purchase Order") - webnotes.reload_doc("buying", "DocType Mapper", "Material Request-Supplier Quotation") - webnotes.reload_doc("buying", "DocType Mapper", "Sales Order-Material Request") - webnotes.reload_doc("stock", "DocType Mapper", "Material Request-Stock Entry") \ No newline at end of file diff --git a/patches/july_2012/reload_pr_po_mapper.py b/patches/july_2012/reload_pr_po_mapper.py deleted file mode 100644 index a53e3ddf8fd..00000000000 --- a/patches/july_2012/reload_pr_po_mapper.py +++ /dev/null @@ -1,5 +0,0 @@ -from __future__ import unicode_literals -def execute(): - import webnotes - from webnotes.modules import reload_doc - reload_doc('buying', 'DocType Mapper', 'Material Request-Purchase Order') \ No newline at end of file diff --git a/patches/july_2012/supplier_quotation.py b/patches/july_2012/supplier_quotation.py deleted file mode 100644 index 0a1ab35ef9b..00000000000 --- a/patches/july_2012/supplier_quotation.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import unicode_literals -import webnotes - -def execute(): - """sync supplier quotatoin and create supplier quotation mappers""" - webnotes.reload_doc('buying', 'doctype', 'supplier_quotation') - webnotes.reload_doc('buying', 'doctype', 'supplier_quotation_item') - webnotes.reload_doc('buying', 'doctype', 'purchase_order') - webnotes.reload_doc('buying', 'doctype', 'purchase_order_item') - - from webnotes.modules import reload_doc - reload_doc('buying', 'DocType Mapper', 'Material Request-Supplier Quotation') - reload_doc('buying', 'DocType Mapper', 'Supplier Quotation-Purchase Order') - \ No newline at end of file diff --git a/patches/july_2013/p01_remove_doctype_mappers.py b/patches/july_2013/p01_remove_doctype_mappers.py index 901b1b6cb04..8aa69b82b48 100644 --- a/patches/july_2013/p01_remove_doctype_mappers.py +++ b/patches/july_2013/p01_remove_doctype_mappers.py @@ -1,4 +1,8 @@ import webnotes def execute(): - for m in webnotes.conn.sql("select name from `tabDocType Mapper`"): - webnotes.delete_doc("DocType Mapper", m[0]) \ No newline at end of file + webnotes.conn.sql("""drop table if exists `tabDocType Mapper`""") + webnotes.conn.sql("""drop table if exists `tabTable Mapper Detail`""") + webnotes.conn.sql("""drop table if exists `tabField Mapper Detail`""") + webnotes.delete_doc("DocType", "DocType Mapper") + webnotes.delete_doc("DocType", "Table Mapper Detail") + webnotes.delete_doc("DocType", "Field Mapper Detail") \ No newline at end of file diff --git a/patches/mar_2012/so_rv_mapper_fix.py b/patches/mar_2012/so_rv_mapper_fix.py deleted file mode 100644 index e018cf56ace..00000000000 --- a/patches/mar_2012/so_rv_mapper_fix.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import unicode_literals -def execute(): - import webnotes - count = webnotes.conn.sql("""SELECT COUNT(*) FROM `tabTable Mapper Detail` - WHERE parent='Sales Order-Sales Invoice' - AND from_table='Sales Order Item'""") - if count and count[0][0]==2: - webnotes.conn.sql("""DELETE FROM `tabTable Mapper Detail` - WHERE parent='Sales Order-Sales Invoice' - AND from_table='Sales Order Item' - AND validation_logic='docstatus = 1'""") diff --git a/patches/october_2012/reload_gl_mapper.py b/patches/october_2012/reload_gl_mapper.py deleted file mode 100644 index 50a5ab5ac74..00000000000 --- a/patches/october_2012/reload_gl_mapper.py +++ /dev/null @@ -1,6 +0,0 @@ -def execute(): - return # deprecated - import webnotes - from webnotes.modules import reload_doc - reload_doc("accounts", "GL Mapper", "Purchase Invoice") - reload_doc("accounts", "GL Mapper", "Purchase Invoice with write off") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index ad01ce60eb6..434c132241f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -20,7 +20,6 @@ patch_list = [ "execute:webnotes.reload_doc('core', 'doctype', 'docperm') # 2013-04-07", "execute:webnotes.reload_doc('core', 'doctype', 'report')", "execute:webnotes.reload_doc('core', 'doctype', 'doctype') # 2013-07-04", - "patches.mar_2012.so_rv_mapper_fix", "patches.mar_2012.clean_property_setter", "patches.april_2012.naming_series_patch", "patches.mar_2012.cleanup_control_panel", @@ -73,7 +72,6 @@ patch_list = [ "patches.july_2012.bin_permission", "patches.july_2012.project_patch_repeat", "patches.july_2012.repost_stock_due_to_wrong_packing_list", - "patches.july_2012.supplier_quotation", "patches.august_2012.task_allocated_to_assigned", "patches.august_2012.change_profile_permission", "patches.august_2012.repost_billed_amt", @@ -89,7 +87,6 @@ patch_list = [ "patches.september_2012.deprecate_account_balance", "patches.september_2012.profile_delete_permission", "patches.october_2012.update_permission", - "patches.october_2012.reload_gl_mapper", "patches.october_2012.fix_wrong_vouchers", "patches.october_2012.company_fiscal_year_docstatus_patch", "patches.october_2012.update_account_property", @@ -124,7 +121,6 @@ patch_list = [ "patches.december_2012.rebuild_item_group_tree", "patches.december_2012.address_title", "patches.december_2012.delete_form16_print_format", - "patches.december_2012.remove_project_mapper", "patches.december_2012.update_print_width", "patches.january_2013.remove_bad_permissions", "patches.january_2013.holiday_list_patch", @@ -171,7 +167,6 @@ patch_list = [ "execute:webnotes.delete_doc('DocType', 'Service Quotation')", "execute:webnotes.delete_doc('DocType', 'Service Order Detail')", "execute:webnotes.delete_doc('DocType', 'Service Quotation Detail')", - "patches.february_2013.p06_material_request_mappers", "execute:webnotes.delete_doc('Page', 'Query Report')", "patches.february_2013.repost_reserved_qty", "execute:webnotes.reload_doc('core', 'doctype', 'report') # 2013-02-25", @@ -221,7 +216,6 @@ patch_list = [ "patches.april_2013.p05_update_file_data", "patches.april_2013.p06_update_file_size", "patches.april_2013.p05_fixes_in_reverse_modules", - "execute:webnotes.delete_doc('DocType Mapper', 'Delivery Note-Packing Slip')", "patches.april_2013.p07_rename_cost_center_other_charges", "patches.april_2013.p06_default_cost_center", "execute:webnotes.reset_perms('File Data')", @@ -244,6 +238,7 @@ patch_list = [ "patches.june_2013.p03_buying_selling_for_price_list", "patches.june_2013.p04_fix_event_for_lead_oppty_project", "patches.june_2013.p05_remove_search_criteria_reports", + "execute:webnotes.delete_doc('Report', 'Sales Orders Pending To Be Delivered')", "patches.june_2013.p05_remove_unused_doctypes", "patches.june_2013.p06_drop_unused_tables", "patches.june_2013.p07_taxes_price_list_for_territory", diff --git a/selling/doctype/installation_note/installation_note.py b/selling/doctype/installation_note/installation_note.py index 62c5b66f331..74c94781624 100644 --- a/selling/doctype/installation_note/installation_note.py +++ b/selling/doctype/installation_note/installation_note.py @@ -65,8 +65,7 @@ class DocType(TransactionBase): 'Installation Date') def validate_reference_value(self): - mapper = get_obj('DocType Mapper', 'Delivery Note-Installation Note', with_children = 1) - mapper.validate_reference_value(self, self.doc.name) + pass def is_serial_no_added(self, item_code, serial_no): ar_required = webnotes.conn.get_value("Item", item_code, "has_serial_no") diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 97fd7142053..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,29 +145,6 @@ cur_frm.cscript['Make Sales Order'] = function() { }) } -//pull enquiry details -cur_frm.cscript.pull_enquiry_detail = function(doc,cdt,cdn){ - - var callback = function(r,rt){ - if(r.message){ - doc.quotation_to = r.message; - - if(doc.quotation_to == 'Lead') { - unhide_field('lead'); - } - else if(doc.quotation_to == 'Customer') { - unhide_field(['customer','customer_address','contact_person','territory','customer_group']); - } - refresh_many(['quotation_details','quotation_to','customer','customer_address', - 'contact_person', 'lead', 'address_display', 'contact_display', 'contact_mobile', - 'contact_email', 'territory', 'customer_group', 'order_type']); - } - } - - $c_obj(make_doclist(doc.doctype, doc.name),'pull_enq_details','',callback); - -} - // declare order lost //------------------------- cur_frm.cscript['Declare Order Lost'] = function(){ diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index 69177f45f76..3f0974ed0c5 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -37,26 +37,11 @@ class DocType(SellingController): def onload(self): self.add_communication_list() - # Pull Opportunity Details - # -------------------- - def pull_enq_details(self): - self.doclist = self.doc.clear_table(self.doclist, 'quotation_details') - get_obj('DocType Mapper', 'Opportunity-Quotation').dt_map('Opportunity', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Opportunity', 'Quotation'],['Opportunity Item', 'Quotation Item']]") - - self.get_adj_percent() - - return self.doc.quotation_to - # Get contact person details based on customer selected # ------------------------------------------------------ def get_contact_details(self): return get_obj('Sales Common').get_contact_details(self,0) - - -# QUOTATION DETAILS TRIGGER FUNCTIONS -# ================================================================================ - # Get Item Details # ----------------- def get_item_details(self, args=None): @@ -83,20 +68,12 @@ class DocType(SellingController): # -------------------------------------------------------------- def get_adj_percent(self, arg=''): get_obj('Sales Common').get_adj_percent(self) - - -# OTHER CHARGES TRIGGER FUNCTIONS -# ==================================================================================== - # Get Tax rate if account type is TAX # ----------------------------------- def get_rate(self,arg): return get_obj('Sales Common').get_rate(arg) - -# VALIDATE -# ============================================================================================== # Fiscal Year Validation # ---------------------- 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..b53662e44ff 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 from tabItem where name = %s""", + d.item_code, as_dict=True)[0] + if item.is_sales_item == 'No' and item.is_service_item == 'No': + msgprint("Item : '%s' is neither Sales nor Service Item" % (d.item_code)) raise Exception + if d.income_account and not item.default_income_account: + webnotes.conn.set_value("Item", d.item_code, "default_income_account", d.income_account) # ************************************************************************************************************************************************** @@ -368,291 +365,3 @@ class DocType(TransactionBase): dt = webnotes.conn.sql("select transaction_date from `tab%s` where name = '%s'" % (d.prevdoc_doctype, d.prevdoc_docname)) d.prevdoc_date = (dt and dt[0][0]) and dt[0][0].strftime('%Y-%m-%d') or '' - def update_prevdoc_detail(self, is_submit, obj): - StatusUpdater(obj, is_submit).update() - - - - -# -# make item code readonly if (detail no is set) -# - - -class StatusUpdater: - """ - Updates the status of the calling records - - From Delivery Note - - Update Delivered Qty - - Update Percent - - Validate over delivery - - From Sales Invoice - - Update Billed Amt - - Update Percent - - Validate over billing - - From Installation Note - - Update Installed Qty - - Update Percent Qty - - Validate over installation - """ - def __init__(self, obj, is_submit): - self.obj = obj # caller object - self.is_submit = is_submit - self.tolerance = {} - self.global_tolerance = None - - def update(self): - self.update_all_qty() - self.validate_all_qty() - - def validate_all_qty(self): - """ - Validates over-billing / delivery / installation in Delivery Note, Sales Invoice, Installation Note - To called after update_all_qty - """ - if self.obj.doc.doctype=='Delivery Note': - self.validate_qty({ - 'source_dt' :'Delivery Note Item', - 'compare_field' :'delivered_qty', - 'compare_ref_field' :'qty', - 'target_dt' :'Sales Order Item', - 'join_field' :'prevdoc_detail_docname' - }) - elif self.obj.doc.doctype=='Sales Invoice': - self.validate_qty({ - 'source_dt' :'Sales Invoice Item', - 'compare_field' :'billed_amt', - 'compare_ref_field' :'export_amount', - 'target_dt' :'Sales Order Item', - 'join_field' :'so_detail' - }) - self.validate_qty({ - 'source_dt' :'Sales Invoice Item', - 'compare_field' :'billed_amt', - 'compare_ref_field' :'export_amount', - 'target_dt' :'Delivery Note Item', - 'join_field' :'dn_detail' - }, no_tolerance =1) - elif self.obj.doc.doctype=='Installation Note': - self.validate_qty({ - 'source_dt' :'Installation Item Details', - 'compare_field' :'installed_qty', - 'compare_ref_field' :'qty', - 'target_dt' :'Delivery Note Item', - 'join_field' :'dn_detail' - }, no_tolerance =1) - - - def get_tolerance_for(self, item_code): - """ - Returns the tolerance for the item, if not set, returns global tolerance - """ - if self.tolerance.get(item_code): - return self.tolerance[item_code] - - tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0) - - if not tolerance: - if self.global_tolerance == None: - self.global_tolerance = flt(webnotes.conn.get_value('Stock Settings',None,'tolerance') or 0) - tolerance = self.global_tolerance - - self.tolerance[item_code] = tolerance - return tolerance - - def check_overflow_with_tolerance(self, item, args): - """ - Checks if there is overflow condering a relaxation tolerance - """ - - # check if overflow is within tolerance - tolerance = self.get_tolerance_for(item['item_code']) - overflow_percent = ((item[args['compare_field']] - item[args['compare_ref_field']]) / item[args['compare_ref_field']]) * 100 - - if overflow_percent - tolerance > 0.01: - item['max_allowed'] = flt(item[args['compare_ref_field']] * (100+tolerance)/100) - item['reduce_by'] = item[args['compare_field']] - item['max_allowed'] - - msgprint(""" - Row #%(idx)s: Max %(compare_ref_field)s allowed for Item %(item_code)s against %(parenttype)s %(parent)s is %(max_allowed)s. - - If you want to increase your overflow tolerance, please increase tolerance %% in Global Defaults or Item master. - - Or, you must reduce the %(compare_ref_field)s by %(reduce_by)s - - Also, please check if the order item has already been billed in the Sales Order""" % item, raise_exception=1) - - def validate_qty(self, args, no_tolerance=None): - """ - Validates qty at row level - """ - # get unique transactions to update - for d in self.obj.doclist: - if d.doctype == args['source_dt'] and d.fields.get(args["join_field"]): - args['name'] = d.fields[args['join_field']] - - # get all qty where qty > compare_field - item = webnotes.conn.sql("""select item_code, `%(compare_ref_field)s`, - `%(compare_field)s`, parenttype, parent from `tab%(target_dt)s` - where `%(compare_ref_field)s` < `%(compare_field)s` - and name="%(name)s" and docstatus=1 - """ % args, as_dict=1) - if item: - item = item[0] - item['idx'] = d.idx - item['compare_ref_field'] = args['compare_ref_field'].replace('_', ' ') - - if not item[args['compare_ref_field']]: - msgprint("As %(compare_ref_field)s for item: %(item_code)s in %(parenttype)s: %(parent)s is zero, system will not check over-delivery or over-billed" % item) - elif no_tolerance: - item['reduce_by'] = item[args['compare_field']] - item[args['compare_ref_field']] - if item['reduce_by'] > .01: - msgprint(""" - Row #%(idx)s: Max %(compare_ref_field)s allowed for Item %(item_code)s against - %(parenttype)s %(parent)s is """ % item - + cstr(item[args['compare_ref_field']]) + """. - - You must reduce the %(compare_ref_field)s by %(reduce_by)s""" % item, raise_exception=1) - - else: - self.check_overflow_with_tolerance(item, args) - - - def update_all_qty(self): - """ - Updates delivered / billed / installed qty in Sales Order & Delivery Note - """ - if self.obj.doc.doctype=='Delivery Note': - self.update_qty({ - 'target_field' :'delivered_qty', - 'target_dt' :'Sales Order Item', - 'target_parent_dt' :'Sales Order', - 'target_parent_field' :'per_delivered', - 'target_ref_field' :'qty', - 'source_dt' :'Delivery Note Item', - 'source_field' :'qty', - 'join_field' :'prevdoc_detail_docname', - 'percent_join_field' :'prevdoc_docname', - 'status_field' :'delivery_status', - 'keyword' :'Delivered' - }) - - elif self.obj.doc.doctype=='Sales Invoice': - self.update_qty({ - 'target_field' :'billed_amt', - 'target_dt' :'Sales Order Item', - 'target_parent_dt' :'Sales Order', - 'target_parent_field' :'per_billed', - 'target_ref_field' :'export_amount', - 'source_dt' :'Sales Invoice Item', - 'source_field' :'export_amount', - 'join_field' :'so_detail', - 'percent_join_field' :'sales_order', - 'status_field' :'billing_status', - 'keyword' :'Billed' - }) - - self.update_qty({ - 'target_field' :'billed_amt', - 'target_dt' :'Delivery Note Item', - 'target_parent_dt' :'Delivery Note', - 'target_parent_field' :'per_billed', - 'target_ref_field' :'export_amount', - 'source_dt' :'Sales Invoice Item', - 'source_field' :'export_amount', - 'join_field' :'dn_detail', - 'percent_join_field' :'delivery_note', - 'status_field' :'billing_status', - 'keyword' :'Billed' - }) - - if cint(self.obj.doc.is_pos) == 1: - self.update_qty({ - 'target_field' :'delivered_qty', - 'target_dt' :'Sales Order Item', - 'target_parent_dt' :'Sales Order', - 'target_parent_field' :'per_delivered', - 'target_ref_field' :'qty', - 'source_dt' :'Sales Invoice Item', - 'source_field' :'qty', - 'join_field' :'so_detail', - 'percent_join_field' :'sales_order', - 'status_field' :'delivery_status', - 'keyword' :'Delivered' - }) - - if self.obj.doc.doctype=='Installation Note': - self.update_qty({ - 'target_field' :'installed_qty', - 'target_dt' :'Delivery Note Item', - 'target_parent_dt' :'Delivery Note', - 'target_parent_field' :'per_installed', - 'target_ref_field' :'qty', - 'source_dt' :'Installation Note Item', - 'source_field' :'qty', - 'join_field' :'prevdoc_detail_docname', - 'percent_join_field' :'prevdoc_docname', - 'status_field' :'installation_status', - 'keyword' :'Installed' - }) - - - def update_qty(self, args): - """ - Updates qty at row level - """ - # condition to include current record (if submit or no if cancel) - if self.is_submit: - args['cond'] = ' or parent="%s"' % self.obj.doc.name - else: - args['cond'] = ' and parent!="%s"' % self.obj.doc.name - - # update quantities in child table - for d in self.obj.doclist: - if d.doctype == args['source_dt']: - # updates qty in the child table - args['detail_id'] = d.fields.get(args['join_field']) - - if args['detail_id']: - webnotes.conn.sql(""" - update - `tab%(target_dt)s` - set - %(target_field)s = (select sum(%(source_field)s) from `tab%(source_dt)s` where `%(join_field)s`="%(detail_id)s" and (docstatus=1 %(cond)s)) - where - name="%(detail_id)s" - """ % args) - - # get unique transactions to update - for name in set([d.fields.get(args['percent_join_field']) for d in self.obj.doclist if d.doctype == args['source_dt']]): - if name: - args['name'] = name - - # update percent complete in the parent table - webnotes.conn.sql(""" - update - `tab%(target_parent_dt)s` - set - %(target_parent_field)s = - (select sum(if(%(target_ref_field)s > ifnull(%(target_field)s, 0), %(target_field)s, %(target_ref_field)s))/sum(%(target_ref_field)s)*100 from `tab%(target_dt)s` where parent="%(name)s"), - modified = now() - where - name="%(name)s" - """ % args) - - # update field - if args['status_field']: - webnotes.conn.sql(""" - update - `tab%(target_parent_dt)s` - set - %(status_field)s = if(ifnull(%(target_parent_field)s,0)<0.001, 'Not %(keyword)s', - if(%(target_parent_field)s>=99.99, 'Fully %(keyword)s', 'Partly %(keyword)s') - ) - where - name="%(name)s" - """ % args) - diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js index 4c12580a44d..27db426eb7e 100644 --- a/selling/doctype/sales_order/sales_order.js +++ b/selling/doctype/sales_order/sales_order.js @@ -69,14 +69,35 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( cur_frm.add_custom_button('Unstop', cur_frm.cscript['Unstop Sales Order']); } } - + + if (this.frm.doc.docstatus===0) { + cur_frm.add_custom_button(wn._('From Quotation'), + function() { + wn.model.map_current_doc({ + method: "selling.doctype.quotation.quotation.make_sales_order", + source_doctype: "Quotation", + get_query_filters: { + docstatus: 1, + status: ["!=", "Order Lost"], + order_type: cur_frm.doc.order_type, + customer: cur_frm.doc.customer || undefined, + company: cur_frm.doc.company + } + }) + }); + } + this.order_type(doc); }, order_type: function() { this.frm.toggle_reqd("delivery_date", this.frm.doc.order_type == "Sales"); }, - + + tc_name: function() { + this.get_terms(); + }, + reserved_warehouse: function(doc, cdt, cdn) { this.warehouse(doc, cdt, cdn); }, @@ -89,7 +110,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( }, make_delivery_note: function() { - console.log(cur_frm.doc.name); wn.model.open_mapped_doc({ method: "selling.doctype.sales_order.sales_order.make_delivery_note", source_name: cur_frm.doc.name @@ -116,16 +136,6 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend( source_name: cur_frm.doc.name }) }, - - pull_quotation_details: function() { - wn.model.map_current_doc({ - method: "selling.doctype.quotation.quotation.make_sales_order", - source_name: cur_frm.doc.quotation_no, - }); - unhide_field(['quotation_date', 'customer_address', - 'contact_person', 'territory', 'customer_group']); - } - }); // for backward compatibility: combine new and previous states @@ -152,22 +162,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) { ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond}); } - -cur_frm.fields_dict['quotation_no'].get_query = function(doc) { - var cond=''; - if(doc.order_type) cond = ' ifnull(`tabQuotation`.order_type, "") = "' - +doc.order_type+'" and'; - if(doc.customer) cond += ' ifnull(`tabQuotation`.customer, "") = "' - +doc.customer+'" and'; - - return repl('SELECT DISTINCT name, customer, transaction_date FROM `tabQuotation` \ - WHERE `tabQuotation`.company = "' - + doc.company + '" and `tabQuotation`.`docstatus` = 1 \ - and `tabQuotation`.status != "Order Lost" \ - and %(cond)s `tabQuotation`.%(key)s LIKE "%s" \ - ORDER BY `tabQuotation`.`name` DESC LIMIT 50', {cond:cond}); -} - cur_frm.cscript['Stop Sales Order'] = function() { var doc = cur_frm.doc; diff --git a/selling/doctype/sales_order/sales_order.txt b/selling/doctype/sales_order/sales_order.txt index c0b812c9e4b..572164a3c9a 100644 --- a/selling/doctype/sales_order/sales_order.txt +++ b/selling/doctype/sales_order/sales_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-18 12:39:59", "docstatus": 0, - "modified": "2013-07-06 18:38:37", + "modified": "2013-07-08 15:54:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -33,8 +33,8 @@ "parent": "Sales Order", "parentfield": "permissions", "parenttype": "DocType", - "read": 1, - "report": 1 + "permlevel": 0, + "read": 1 }, { "doctype": "DocType", @@ -364,55 +364,6 @@ "print_hide": 1, "read_only": 1 }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break" - }, - { - "description": "Quotation no against which this Sales Order is made ", - "doctype": "DocField", - "fieldname": "quotation_no", - "fieldtype": "Link", - "in_filter": 1, - "label": "Quotation No", - "no_copy": 0, - "oldfieldname": "quotation_no", - "oldfieldtype": "Link", - "options": "Quotation", - "print_hide": 1, - "search_index": 1, - "width": "150px" - }, - { - "depends_on": "eval:doc.quotation_no", - "doctype": "DocField", - "fieldname": "quotation_date", - "fieldtype": "Date", - "hidden": 1, - "label": "Quotation Date", - "no_copy": 0, - "oldfieldname": "quotation_date", - "oldfieldtype": "Date", - "print_hide": 1, - "read_only": 1, - "reqd": 0, - "width": "100px" - }, - { - "doctype": "DocField", - "fieldname": "pull_quotation_details", - "fieldtype": "Button", - "label": "Pull Quotation Items", - "oldfieldtype": "Button", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "col_break20", - "fieldtype": "Column Break", - "width": "50%" - }, { "doctype": "DocField", "fieldname": "net_total_export", @@ -647,24 +598,6 @@ "print_hide": 1, "search_index": 0 }, - { - "doctype": "DocField", - "fieldname": "column_break_58", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "print_hide": 1 - }, - { - "doctype": "DocField", - "fieldname": "section_break_60", - "fieldtype": "Section Break" - }, { "doctype": "DocField", "fieldname": "terms", @@ -974,23 +907,13 @@ "options": "Sales Team", "print_hide": 1 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Sales Manager", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "role": "Sales Manager", + "report": 1, + "role": "Sales User", "submit": 1, "write": 1 }, @@ -999,63 +922,18 @@ "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, - "role": "Sales User", + "report": 1, + "role": "Maintenance User", "submit": 1, "write": 1 }, { - "amend": 0, - "cancel": 0, - "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "role": "Sales User", - "submit": 0, - "write": 0 + "role": "Accounts User" }, { "doctype": "DocPerm", - "match": "customer_name", - "permlevel": 0, + "match": "customer", "role": "Customer" - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "role": "Maintenance Manager", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Maintenance Manager", - "submit": 0 - }, - { - "amend": 1, - "cancel": 1, - "create": 1, - "doctype": "DocPerm", - "permlevel": 0, - "role": "Maintenance User", - "submit": 1, - "write": 1 - }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Maintenance User", - "submit": 0 } ] \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index be0d9dd4341..de2ccf4cc09 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -161,8 +161,8 @@ wn.module_page["Selling"] = [ route: "query-report/Customer Addresses And Contacts" }, { - "label":wn._("Sales Orders Pending to be Delivered"), - route: "query-report/Sales Orders Pending To Be Delivered" + "label":wn._("Ordered Items To Be Delivered"), + route: "query-report/Ordered Items To Be Delivered", }, { "label":wn._("Sales Person-wise Transaction Summary"), diff --git a/selling/report/sales_orders_pending_to_be_delivered/__init__.py b/selling/report/sales_orders_pending_to_be_delivered/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt b/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt deleted file mode 100644 index c145f4ea393..00000000000 --- a/selling/report/sales_orders_pending_to_be_delivered/sales_orders_pending_to_be_delivered.txt +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "creation": "2013-02-21 14:26:46", - "docstatus": 0, - "modified": "2013-02-22 15:53:24", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Report", - "is_standard": "Yes", - "name": "__common__", - "query": "select \n `tabSales Order`.`name` as \"S.O. No.:Link/Sales Order:120\",\n `tabSales Order`.`transaction_date` as \"S.O. Date:Date\",\n `tabSales Order`.`delivery_date` as \"Expected Delivery Date:Date\",\n `tabSales Order`.`customer` as \"Customer:Link/Customer:120\",\n `tabSales Order Item`.item_code as \"Item Code:Link/Item:120\",\n `tabSales Order Item`.description as \"Description\",\n `tabSales Order Item`.qty as \"Qty:Float\",\n `tabSales Order Item`.delivered_qty as \"Delivered Qty:Float\",\n `tabSales Order`.`po_no` as \"P.O. No.\"\nfrom\n `tabSales Order`, `tabSales Order Item`\nwhere\n `tabSales Order Item`.`parent` = `tabSales Order`.`name`\n and `tabSales Order`.docstatus = 1\n and `tabSales Order`.status != \"Stopped\"\n and ifnull(`tabSales Order Item`.delivered_qty,0) < ifnull(`tabSales Order Item`.qty,0)\norder by `tabSales Order`.transaction_date asc", - "ref_doctype": "Sales Order", - "report_name": "Sales Orders Pending To Be Delivered", - "report_type": "Query Report" - }, - { - "doctype": "Report", - "name": "Sales Orders Pending To Be Delivered" - } -] \ No newline at end of file diff --git a/selling/utils.py b/selling/utils.py index bd04db570e2..5f2cfbd307c 100644 --- a/selling/utils.py +++ b/selling/utils.py @@ -113,8 +113,10 @@ def _get_basic_details(args, item_bean): "description": item.description_html or item.description, "reserved_warehouse": item.default_warehouse or args.warehouse or args.reserved_warehouse, "warehouse": item.default_warehouse or args.warehouse, - "income_account": item.default_income_account or args.income_account, - "expense_account": item.purchase_account or args.expense_account, + "income_account": item.default_income_account or args.income_account \ + or webnotes.conn.get_value("Company", args.company, "default_income_account"), + "expense_account": item.purchase_account or args.expense_account \ + or webnotes.conn.get_value("Company", args.company, "default_expense_account"), "cost_center": item.default_sales_cost_center or args.cost_center, "qty": 1.0, "adj_rate": 0.0, diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index 446d602082f..0bcd8c5cc50 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -191,6 +191,8 @@ class DocType: def set_default_accounts(self): accounts = { + "default_income_account": "Sales", + "default_expense_account": "Cost of Goods Sold", "receivables_group": "Accounts Receivable", "payables_group": "Accounts Payable", "stock_received_but_not_billed": "Stock Received But Not Billed", diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt index c4def9a7883..e3afda13f34 100644 --- a/setup/doctype/company/company.txt +++ b/setup/doctype/company/company.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-10 08:35:39", "docstatus": 0, - "modified": "2013-07-05 14:32:14", + "modified": "2013-07-08 17:34:21", "modified_by": "Administrator", "owner": "Administrator" }, @@ -89,15 +89,6 @@ "oldfieldtype": "Section Break", "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "default_currency", - "fieldtype": "Link", - "label": "Default Currency", - "options": "Currency", - "read_only": 0, - "reqd": 1 - }, { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", @@ -142,6 +133,28 @@ "options": "Account", "read_only": 0 }, + { + "doctype": "DocField", + "fieldname": "default_expense_account", + "fieldtype": "Link", + "label": "Default Expense Account", + "options": "Account" + }, + { + "doctype": "DocField", + "fieldname": "default_income_account", + "fieldtype": "Link", + "label": "Default Income Account", + "options": "Account" + }, + { + "doctype": "DocField", + "fieldname": "column_break0", + "fieldtype": "Column Break", + "oldfieldtype": "Column Break", + "read_only": 0, + "width": "50%" + }, { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", @@ -153,11 +166,12 @@ }, { "doctype": "DocField", - "fieldname": "column_break0", - "fieldtype": "Column Break", - "oldfieldtype": "Column Break", + "fieldname": "default_currency", + "fieldtype": "Link", + "label": "Default Currency", + "options": "Currency", "read_only": 0, - "width": "50%" + "reqd": 1 }, { "depends_on": "eval:!doc.__islocal", diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index 8756e83c35b..117e77eacb2 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -46,15 +46,27 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( var aii_enabled = cint(sys_defaults.auto_inventory_accounting) cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("expense_account", aii_enabled); cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp("cost_center", aii_enabled); + + 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_delivery_note", + source_doctype: "Sales Order", + get_query_filters: { + docstatus: 1, + status: ["!=", "Stopped"], + per_delivered: ["<", 99.99], + project_name: cur_frm.doc.project_name || undefined, + customer: cur_frm.doc.customer || undefined, + company: cur_frm.doc.company + } + }) + }); + } + }, - get_items: function() { - wn.model.map_current_doc({ - method: "selling.doctype.sales_order.sales_order.make_delivery_note", - source_name: cur_frm.doc.sales_order_no, - }) - }, - make_sales_invoice: function() { wn.model.open_mapped_doc({ method: "stock.doctype.delivery_note.delivery_note.make_sales_invoice", @@ -67,7 +79,11 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( method: "stock.doctype.delivery_note.delivery_note.make_installation_note", source_name: cur_frm.doc.name }); - } + }, + + tc_name: function() { + this.get_terms(); + }, }); @@ -96,22 +112,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, cdt, cdn) { ORDER BY `tabProject`.name ASC LIMIT 50', {cond:cond}); } - -// *************** Customized link query for SALES ORDER based on customer and currency***************************** -cur_frm.fields_dict['sales_order_no'].get_query = function(doc) { - doc = locals[this.doctype][this.docname]; - var cond = ''; - - if(doc.customer) { - cond = '`tabSales Order`.customer = "'+doc.customer+'" and'; - } - - if(doc.project_name){ - cond += '`tabSales Order`.project_name ="'+doc.project_name+'"'; - } - return repl('SELECT DISTINCT `tabSales Order`.`name` FROM `tabSales Order` WHERE `tabSales Order`.company = "%(company)s" and `tabSales Order`.`docstatus` = 1 and `tabSales Order`.`status` != "Stopped" and ifnull(`tabSales Order`.per_delivered,0) < 99.99 and %(cond)s `tabSales Order`.%(key)s LIKE "%s" ORDER BY `tabSales Order`.`name` DESC LIMIT 50', {company:doc.company,cond:cond}) -} - cur_frm.cscript.serial_no = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; if (d.serial_no) { diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index aa3a4d167a9..a7dbd00c35f 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -369,7 +369,7 @@ class DocType(SellingController): @webnotes.whitelist() def make_sales_invoice(source_name, target_doclist=None): def update_item(obj, target, source_parent): - target.export_amount = flt(obj.amount) - flt(obj.billed_amt) + target.export_amount = flt(obj.amount) target.amount = target.export_amount / flt(source_parent.conversion_rate) target.qty = obj.basic_rate and target.amount / flt(obj.basic_rate) or obj.qty @@ -393,8 +393,7 @@ def make_sales_invoice(source_name, target_doclist=None): "prevdoc_docname": "sales_order", "serial_no": "serial_no" }, - "postprocess": update_item, - "condition": lambda doc: doc.amount==0 or doc.billed_amt < doc.export_amount + "postprocess": update_item }, "Sales Taxes and Charges": { "doctype": "Sales Taxes and Charges", diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index 3b032aeba7a..a93573ab163 100644 --- a/stock/doctype/delivery_note/delivery_note.txt +++ b/stock/doctype/delivery_note/delivery_note.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:09", "docstatus": 0, - "modified": "2013-07-06 19:04:46", + "modified": "2013-07-08 17:46:45", "modified_by": "Administrator", "owner": "Administrator" }, @@ -34,6 +34,7 @@ "parent": "Delivery Note", "parentfield": "permissions", "parenttype": "DocType", + "permlevel": 0, "read": 1, "report": 1 }, @@ -373,42 +374,6 @@ "print_hide": 1, "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "section_break0", - "fieldtype": "Section Break", - "read_only": 0 - }, - { - "description": "You can make a delivery note from multiple sales orders. Select sales orders one by one and click on the button below.", - "doctype": "DocField", - "fieldname": "sales_order_no", - "fieldtype": "Link", - "in_list_view": 1, - "label": "Sales Order No", - "no_copy": 0, - "oldfieldname": "sales_order_no", - "oldfieldtype": "Link", - "options": "Sales Order", - "print_hide": 0, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "get_items", - "fieldtype": "Button", - "hidden": 0, - "label": "Get Items", - "oldfieldtype": "Button", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "col_break24", - "fieldtype": "Column Break", - "read_only": 0 - }, { "doctype": "DocField", "fieldname": "net_total_export", @@ -664,25 +629,6 @@ "print_hide": 1, "read_only": 0 }, - { - "doctype": "DocField", - "fieldname": "column_break_59", - "fieldtype": "Column Break" - }, - { - "doctype": "DocField", - "fieldname": "get_terms", - "fieldtype": "Button", - "label": "Get Terms and Conditions", - "oldfieldtype": "Button", - "print_hide": 1, - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "section_break_61", - "fieldtype": "Section Break" - }, { "doctype": "DocField", "fieldname": "terms", @@ -953,33 +899,6 @@ "search_index": 1, "width": "150px" }, - { - "depends_on": "eval:!doc.__islocal", - "description": "% of materials billed against this Delivery Note", - "doctype": "DocField", - "fieldname": "per_billed", - "fieldtype": "Percent", - "in_filter": 1, - "in_list_view": 1, - "label": "% Amount Billed", - "no_copy": 1, - "oldfieldname": "per_billed", - "oldfieldtype": "Currency", - "print_hide": 1, - "read_only": 1, - "search_index": 1 - }, - { - "doctype": "DocField", - "fieldname": "billing_status", - "fieldtype": "Select", - "hidden": 1, - "label": "Billing Status", - "no_copy": 1, - "options": "\nNot Billed\nPartly Billed\nFully Billed", - "print_hide": 1, - "read_only": 0 - }, { "depends_on": "eval:!doc.__islocal", "description": "% of materials delivered against this Delivery Note", @@ -1125,83 +1044,39 @@ "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, "role": "Material User", "submit": 1, "write": 1 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Material User", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, "role": "Material Manager", "submit": 1, "write": 1 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Material Manager", - "submit": 0, - "write": 0 - }, { "amend": 1, "cancel": 1, "create": 1, "doctype": "DocPerm", - "permlevel": 0, "role": "Sales User", "submit": 1, "write": 1 }, { - "amend": 0, "cancel": 0, "create": 0, "doctype": "DocPerm", - "permlevel": 1, - "role": "Sales User", - "submit": 0, - "write": 0 - }, - { - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 0, "role": "Accounts User", "submit": 0, "write": 0 }, - { - "amend": 0, - "cancel": 0, - "create": 0, - "doctype": "DocPerm", - "permlevel": 1, - "role": "Accounts User", - "submit": 0 - }, { "doctype": "DocPerm", "match": "customer_name", - "permlevel": 0, "role": "Customer" } ] \ No newline at end of file diff --git a/stock/doctype/delivery_note_item/delivery_note_item.txt b/stock/doctype/delivery_note_item/delivery_note_item.txt index a8eda202a05..69b5bc4d49d 100644 --- a/stock/doctype/delivery_note_item/delivery_note_item.txt +++ b/stock/doctype/delivery_note_item/delivery_note_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-22 13:15:44", "docstatus": 0, - "modified": "2013-05-22 12:15:32", + "modified": "2013-07-08 17:46:21", "modified_by": "Administrator", "owner": "Administrator" }, @@ -308,18 +308,6 @@ "read_only": 1, "width": "150px" }, - { - "doctype": "DocField", - "fieldname": "billed_amt", - "fieldtype": "Currency", - "label": "Billed Amt", - "no_copy": 1, - "options": "currency", - "print_hide": 1, - "print_width": "100px", - "read_only": 1, - "width": "100px" - }, { "doctype": "DocField", "fieldname": "installed_qty", diff --git a/stock/doctype/material_request/material_request.js b/stock/doctype/material_request/material_request.js index d33ca80f76d..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,7 +87,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten calculate_taxes_and_totals: function() { return; }, - + 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.py b/stock/doctype/material_request/material_request.py index d423b3c8ffe..861162acd4c 100644 --- a/stock/doctype/material_request/material_request.py +++ b/stock/doctype/material_request/material_request.py @@ -21,15 +21,6 @@ class DocType(BuyingController): def get_bin_details(self, arg = ''): return get_obj(dt='Purchase Common').get_bin_details(arg) - # Pull Sales Order Items - # ------------------------- - def pull_so_details(self): - self.check_if_already_pulled() - if self.doc.sales_order_no: - get_obj('DocType Mapper', 'Sales Order-Material Request', with_children=1).dt_map('Sales Order', 'Material Request', self.doc.sales_order_no, self.doc, self.doclist, "[['Sales Order', 'Material Request'],['Sales Order Item', 'Material Request Item']]") - else: - msgprint("Please select Sales Order whose details need to pull") - def check_if_already_pulled(self): pass#if self.[d.sales_order_no for d in getlist(self.doclist, 'indent_details')] @@ -303,10 +294,10 @@ def make_supplier_quotation(source_name, target_doclist=None): def make_stock_entry(source_name, target_doclist=None): from webnotes.model.mapper import get_mapped_doclist - def set_purpose(source, target, source_parent): + def set_purpose(source, target): target[0].purpose = "Material Transfer" - def update_item(source, target): + def update_item(source, target, source_parent): target.conversion_factor = 1 target.qty = flt(source.qty) - flt(source.ordered_qty) diff --git a/stock/doctype/material_request/material_request.txt b/stock/doctype/material_request/material_request.txt index ad9450386d1..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-05 14:46:13", + "modified": "2013-07-08 15:40:01", "modified_by": "Administrator", "owner": "Administrator" }, @@ -98,45 +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", - "options": "pull_so_details" - }, { "default": "Give additional details about the indent.", "doctype": "DocField", @@ -309,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/material_request/test_material_request.py b/stock/doctype/material_request/test_material_request.py index daf31ad969c..0efc3b00251 100644 --- a/stock/doctype/material_request/test_material_request.py +++ b/stock/doctype/material_request/test_material_request.py @@ -6,6 +6,9 @@ import webnotes, unittest from webnotes.utils import flt class TestMaterialRequest(unittest.TestCase): + def setUp(self): + webnotes.defaults.set_global_default("auto_inventory_accounting", 0) + def test_make_purchase_order(self): from stock.doctype.material_request.material_request import make_purchase_order @@ -116,17 +119,9 @@ class TestMaterialRequest(unittest.TestCase): self._test_requested_qty(54.0, 3.0) # map a purchase order - po_doclist = webnotes.map_doclist([["Material Request", "Purchase Order"], - ["Material Request Item", "Purchase Order Item"]], mr.doc.name) - po_doclist[0].fields.update({ - "supplier": "_Test Supplier", - "supplier_name": "_Test Supplier", - "transaction_date": mr.doc.transaction_date, - "fiscal_year": "_Test Fiscal Year 2013", - "currency": "INR", - "conversion_rate": 1.0, - "grand_total_import": 0.0 - }) + from stock.doctype.material_request.material_request import make_purchase_order + po_doclist = make_purchase_order(mr.doc.name) + po_doclist[0].supplier = "_Test Supplier" po_doclist[1].qty = 27.0 po_doclist[2].qty = 1.5 @@ -167,22 +162,23 @@ class TestMaterialRequest(unittest.TestCase): self._test_expected(mr.doclist, [{"per_ordered": None}, {"ordered_qty": None}, {"ordered_qty": None}]) self._test_requested_qty(54.0, 3.0) - + + from stock.doctype.material_request.material_request import make_stock_entry + # map a stock entry - se_doclist = webnotes.map_doclist([["Material Request", "Stock Entry"], - ["Material Request Item", "Stock Entry Detail"]], mr.doc.name) - se_doclist[0].fields.update({ + se_doclist = make_stock_entry(mr.doc.name) + se_doclist[0].update({ "posting_date": "2013-03-01", "posting_time": "01:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].fields.update({ + se_doclist[1].update({ "qty": 27.0, "transfer_qty": 27.0, "s_warehouse": "_Test Warehouse 1", "incoming_rate": 1.0 }) - se_doclist[2].fields.update({ + se_doclist[2].update({ "qty": 1.5, "transfer_qty": 1.5, "s_warehouse": "_Test Warehouse 1", @@ -231,20 +227,21 @@ class TestMaterialRequest(unittest.TestCase): self._test_requested_qty(54.0, 3.0) # map a stock entry - se_doclist = webnotes.map_doclist([["Material Request", "Stock Entry"], - ["Material Request Item", "Stock Entry Detail"]], mr.doc.name) - se_doclist[0].fields.update({ + from stock.doctype.material_request.material_request import make_stock_entry + + se_doclist = make_stock_entry(mr.doc.name) + se_doclist[0].update({ "posting_date": "2013-03-01", "posting_time": "00:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].fields.update({ + se_doclist[1].update({ "qty": 60.0, "transfer_qty": 60.0, "s_warehouse": "_Test Warehouse 1", "incoming_rate": 1.0 }) - se_doclist[2].fields.update({ + se_doclist[2].update({ "qty": 3.0, "transfer_qty": 3.0, "s_warehouse": "_Test Warehouse 1", @@ -285,21 +282,22 @@ class TestMaterialRequest(unittest.TestCase): mr.submit() # map a stock entry - se_doclist = webnotes.map_doclist([["Material Request", "Stock Entry"], - ["Material Request Item", "Stock Entry Detail"]], mr.doc.name) - se_doclist[0].fields.update({ + from stock.doctype.material_request.material_request import make_stock_entry + + se_doclist = make_stock_entry(mr.doc.name) + se_doclist[0].update({ "posting_date": "2013-03-01", "posting_time": "00:00", "fiscal_year": "_Test Fiscal Year 2013", }) - se_doclist[1].fields.update({ + se_doclist[1].update({ "qty": 60.0, "transfer_qty": 60.0, "s_warehouse": "_Test Warehouse", "t_warehouse": "_Test Warehouse 1", "incoming_rate": 1.0 }) - se_doclist[2].fields.update({ + se_doclist[2].update({ "qty": 3.0, "transfer_qty": 3.0, "s_warehouse": "_Test Warehouse 1", diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index b5e52027d08..852a9c60796 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -35,6 +35,22 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']); } + cur_frm.add_custom_button(wn._('From Purchase Order'), + function() { + wn.model.map_current_doc({ + method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt", + source_doctype: "Purchase Order", + get_query_filters: { + supplier: cur_frm.doc.supplier || undefined, + docstatus: 1, + status: ["!=", "Stopped"], + per_received: ["<", 99.99], + company: cur_frm.doc.company + } + }) + }); + + if(wn.boot.control_panel.country == 'India') { unhide_field(['challan_no', 'challan_date']); } @@ -85,14 +101,11 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend source_name: cur_frm.doc.name }) }, - - pull_purchase_order_details: function() { - wn.model.map_current_doc({ - method: "buying.doctype.purchase_order.purchase_order.make_purchase_receipt", - source_name: cur_frm.doc.purchase_order_no, - }) - } - + + tc_name: function() { + this.get_terms(); + }, + }); // for backward compatibility: combine new and previous states @@ -146,57 +159,10 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) return 'SELECT `tabPrint Heading`.name FROM `tabPrint Heading` WHERE `tabPrint Heading`.docstatus !=2 AND `tabPrint Heading`.name LIKE "%s" ORDER BY `tabPrint Heading`.name ASC LIMIT 50'; } -cur_frm.fields_dict['purchase_order_no'].get_query = function(doc) { - if (doc.supplier) - return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`supplier` = "' +doc.supplier + '" and`tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.`currency` = ifnull("' +doc.currency+ '","") and `tabPurchase Order`.company = "'+ doc.company +'" and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50'; - else - return 'SELECT DISTINCT `tabPurchase Order`.`name` FROM `tabPurchase Order` WHERE `tabPurchase Order`.`docstatus` = 1 and `tabPurchase Order`.`company` = "'+ doc.company +'" and `tabPurchase Order`.`status` != "Stopped" and ifnull(`tabPurchase Order`.`per_received`, 0) < 99.99 and `tabPurchase Order`.%(key)s LIKE "%s" ORDER BY `tabPurchase Order`.`name` DESC LIMIT 50'; -} - cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query = function(doc) { return 'SELECT `tabQuality Inspection`.name FROM `tabQuality Inspection` WHERE `tabQuality Inspection`.docstatus = 1 AND `tabQuality Inspection`.%(key)s LIKE "%s"'; } -cur_frm.pformat.purchase_order_no = function(doc, cdt, cdn){ - //function to make row of table - - var make_row = function(title,val1, val2, bold){ - var bstart = ''; var bend = ''; - - return '
| ';
-
- // main table
- out +=' |