From 2ba61236c1caae841faa477b71431cec485c4d1e Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 27 Sep 2013 21:08:37 +0530 Subject: [PATCH 01/24] [price list] make new grid --- setup/doctype/price_list/price_list.js | 301 +++++++++++++++++++++++++ 1 file changed, 301 insertions(+) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index f3adc72757..6dfbd0f1ee 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -5,4 +5,305 @@ $.extend(cur_frm.cscript, { onload: function() { erpnext.add_for_territory(); }, +}); + +cur_frm.cscript.refresh = function(doc, cdt, cdn) { + cur_frm.cscript.show_item_prices(); +} + +cur_frm.cscript.show_item_prices = function() { + var counter = 0; + var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); + + new wn.ui.form.TableGrid({ + parent: cur_frm.fields_dict.item_prices.wrapper, + frm: cur_frm, + table_field: wn.model.get("DocField", {parent:"Price List", fieldname:"item_prices"})[0] + }); +} + +wn.ui.form.TableGrid = Class.extend({ + init: function(opts) { + $.extend(this, opts); + this.fields = wn.model.get("DocField", {parent: this.table_field.options}); + this.make_table(); + }, + make_table: function() { + var me = this; + // Creating table & assigning attributes + var grid_table = document.createElement("table"); + $(grid_table).attr("class", "table table-hover table-bordered grid"); + + // Appending header & rows to table + + $(this.make_table_headers()).appendTo(grid_table); + $(this.make_table_rows()).appendTo(grid_table); + + // Creating button to add new row + var btn_div = document.createElement("div"); + var new_row_btn = document.createElement("button"); + $new_row_btn = $(new_row_btn); + $new_row_btn.attr({ + "class": "btn btn-success table-new-row", + "title": "Add new row" + }); + var btn_icon = document.createElement("i"); + $(btn_icon).attr("class", "icon-plus"); + $(btn_icon).appendTo(new_row_btn); + $new_row_btn.append(" Add new row"); + $new_row_btn.appendTo(btn_div); + + // Appending table & button to parent + var $grid_table = $(grid_table).appendTo($(this.parent)); + var $btn_div = $(btn_div).appendTo($(this.parent)); + + $btn_div.on("click", ".table-new-row", function() { + me.make_dialog(); + return false; + }); + + $grid_table.on("click", ".table-row", function() { + me.make_dialog(this); + return false; + }); + }, + make_table_headers: function() { + var me = this; + var header = document.createElement("thead"); + + // Creating header row + var row = document.createElement("tr"); + $(row).attr({ + "class": "active", + "style": "height:50px" + }); + $(row).appendTo(header); + + // Creating head first cell + var th = document.createElement("th"); + $(th).attr({ + "width": "8%", + "style": "vertical-align:middle", + "class": "text-center" + }); + $(th).html("#"); + $(th).appendTo(row); + + // Make other headers with label as heading + $.each(this.fields, function(i, obj) { + if (obj.in_list_view===1) + var th = document.createElement("th"); + $(th).attr("style", "vertical-align:middle"); + $(th).html(obj.label); + $(th).appendTo(row); + }); + + return header; + }, + make_table_rows: function() { + var me = this; + + // Creating table body + var table_body = document.createElement("tbody"); + $(table_body).attr("style", "cursor:pointer"); + + $.each(wn.model.get_children(this.table_field.options, this.frm.doc.name, + this.table_field.fieldname, this.frm.doctype), function(index, d) { + + // Creating table row + var tr = document.createElement("tr"); + $(tr).attr({ + "class": "table-row", + "data-idx": d.idx + }); + + // Creating table data & appending to row + var td = document.createElement("td"); + $(td).attr("class", "text-center"); + $(td).html(d.idx); + $(td).appendTo(tr); + + $.each(me.fields, function(i, obj) { + if (obj.in_list_view===1) { + var td = document.createElement("td"); + $(td).attr({ + "data-fieldtype": obj.fieldtype, + "data-fieldname": obj.fieldname, + "data-fieldvalue": d[obj.fieldname], + "data-doc_name": d["name"] + }); + $(td).html(d[obj.fieldname]); + + // if field is currency then add style & change text + if (obj.fieldtype=="Currency") { + $(td).attr("style", "text-align:right"); + $(td).html(format_currency(d[obj.fieldname], me.frm.doc.currency)); + } + + // Append td to row + $(td).appendTo(tr); + } + }); + + // Append row to table body + $(tr).appendTo(table_body); + }); + + return table_body; + }, + make_dialog: function(row) { + var me = this; + + this.dialog = new wn.ui.Dialog({ + title: this.table_field.options, + fields: this.fields + }); + + this.dialog.set_values(this.make_dialog_values(row)); + + $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons()); + this.dialog.show(); + + this.dialog.$wrapper.find('button.update').on('click', function() { + me.update_row(row); + }); + + this.dialog.$wrapper.find('button.delete').on('click', function() { + me.delete_row(row); + }); + return row; + }, + // make_dialog_fields: function() { + // var me = this; + // var fields = []; + + // $.each(this.fields, function(i, obj) { + // var dialog_field = { + // fieldtype: obj.fieldtype, + // fieldname: obj.fieldname, + // label: obj.label + // } + + // // check if fields has options + // if (obj.options) { + // var options = {options: obj.options} + // $.extend(dialog_field, options); + // } + + // // check if field is mandatory + // if (obj.reqd == 1) { + // var reqd = {reqd: obj.reqd} + // $.extend(dialog_field, reqd); + // } + + // fields.push(obj); + // }); + + // return fields; + // }, + make_dialog_values: function(row) { + var me = this; + var dialog_values = {}; + + $.each(this.fields, function(i, item) { + dialog_values[item.fieldname] = $(row).find('td[data-fieldname="'+ item.fieldname +'"]').data('fieldvalue'); + }); + + return dialog_values; + }, + make_dialog_buttons: function() { + var me = this; + var buttons = ''; + + // if user can delete then only add the delete button in dialog + if (wn.model.can_delete(me.frm.doc.doctype)) + buttons += ' '; + + return buttons; + }, + update_row: function(row) { + var me = this; + + if (!row) { + me.add_new_row(); + } + else { + $.each(me.fields, function(i, item) { + var $td = $(row).find('td[data-fieldname="'+ item.fieldname +'"]'); + var val = me.dialog.get_values()[item.fieldname]; + + wn.model.set_value(me.table_field.options, $td.attr('data-doc_name'), + item.fieldname, me.dialog.get_values()[item.fieldname]); + $td.attr('data-fieldvalue', val); + + // If field type is currency the update with format currency + if ($td.attr('data-fieldtype') == "Currency") + $td.html(format_currency(val, me.frm.doc.currency)); + else + $td.html(val); + }); + } + + this.dialog.hide(); + }, + delete_row: function(row) { + var me = this; + var doc_name = $(row).find('td:last').attr('data-doc_name'); + wn.model.clear_doc(me.table_field.options, doc_name); + $(row).remove(); + + // Re-assign idx + $.each($(this.parent).find(".grid tbody tr"), function(idx, data) { + $(data).attr("data-idx", idx + 1); + var $td = $(data).find('td:first'); + $td.html(idx + 1); + }); + this.dialog.hide(); + }, + add_new_row: function() { + var me = this; + var row = $(this.parent).find(".grid tbody tr"); + + // Creating new row + var new_row = document.createElement("tr"); + $(new_row).attr({ + "class": "table-row", + "data-idx": row.length + 1 + }); + + // Creating first table data + var td = document.createElement("td"); + $(td).attr("class", "text-center"); + $(td).html(row.length + 1); + $(td).appendTo(new_row); + + var child = wn.model.add_child(this.frm.doc, this.table_field.options, + this.table_field.fieldname); + + $.each(this.fields, function(i, obj) { + if (obj.in_list_view===1) { + child[obj.fieldname] = me.dialog.get_values()[obj.fieldname]; + + var td = document.createElement("td"); + $(td).attr({ + "data-fieldtype": obj.fieldtype, + "data-fieldname": obj.fieldname, + "data-fieldvalue": child[obj.fieldname], + "data-doc_name": child["name"] + }); + $(td).html(child[obj.fieldname]); + + // if field is currency then add style & change text + if (obj.fieldtype=="Currency") { + $(td).attr("style", "text-align:right"); + $(td).html(format_currency(child[obj.fieldname], me.frm.doc.currency)); + } + + // Append td to row + $(td).appendTo(new_row); + } + }); + + $(new_row).appendTo($(this.parent).find(".grid tbody")); + } }); \ No newline at end of file From d086d724b638a80e501abf4746ce3ebcab4c0e81 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 11:37:44 +0530 Subject: [PATCH 02/24] [price_list] new grid finished with fixes --- setup/doctype/price_list/price_list.js | 37 +++++--------------------- 1 file changed, 7 insertions(+), 30 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 6dfbd0f1ee..0057773d57 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -12,8 +12,12 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { } cur_frm.cscript.show_item_prices = function() { - var counter = 0; var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); + var show = item_price && item_price.length; + + cur_frm.toggle_display("item_prices", show); + $(cur_frm.fields_dict.item_prices.wrapper).empty(); + if (!show) return; new wn.ui.form.TableGrid({ parent: cur_frm.fields_dict.item_prices.wrapper, @@ -159,7 +163,8 @@ wn.ui.form.TableGrid = Class.extend({ fields: this.fields }); - this.dialog.set_values(this.make_dialog_values(row)); + if (row) + this.dialog.set_values(this.make_dialog_values(row)); $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons()); this.dialog.show(); @@ -173,34 +178,6 @@ wn.ui.form.TableGrid = Class.extend({ }); return row; }, - // make_dialog_fields: function() { - // var me = this; - // var fields = []; - - // $.each(this.fields, function(i, obj) { - // var dialog_field = { - // fieldtype: obj.fieldtype, - // fieldname: obj.fieldname, - // label: obj.label - // } - - // // check if fields has options - // if (obj.options) { - // var options = {options: obj.options} - // $.extend(dialog_field, options); - // } - - // // check if field is mandatory - // if (obj.reqd == 1) { - // var reqd = {reqd: obj.reqd} - // $.extend(dialog_field, reqd); - // } - - // fields.push(obj); - // }); - - // return fields; - // }, make_dialog_values: function(row) { var me = this; var dialog_values = {}; From 7d36fc821bba65928c8a9537720fb119e6bb4122 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 12:44:00 +0530 Subject: [PATCH 03/24] [fix] [minor] new grid fix to hide other grid --- setup/doctype/price_list/price_list.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 0057773d57..a190710d4e 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -13,11 +13,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.show_item_prices = function() { var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); - var show = item_price && item_price.length; - - cur_frm.toggle_display("item_prices", show); + + cur_frm.toggle_display("item_prices", true); $(cur_frm.fields_dict.item_prices.wrapper).empty(); - if (!show) return; new wn.ui.form.TableGrid({ parent: cur_frm.fields_dict.item_prices.wrapper, From 9cb2cdbce6635d034eb09e05d8c09d2fcb7a88e4 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 15:43:00 +0530 Subject: [PATCH 04/24] [price_list] [minor] fix of new grid --- setup/doctype/price_list/price_list.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index a190710d4e..cbca413f0c 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -181,7 +181,7 @@ wn.ui.form.TableGrid = Class.extend({ var dialog_values = {}; $.each(this.fields, function(i, item) { - dialog_values[item.fieldname] = $(row).find('td[data-fieldname="'+ item.fieldname +'"]').data('fieldvalue'); + dialog_values[item.fieldname] = $(row).find('td[data-fieldname="'+ item.fieldname +'"]').attr('data-fieldvalue'); }); return dialog_values; @@ -206,9 +206,9 @@ wn.ui.form.TableGrid = Class.extend({ $.each(me.fields, function(i, item) { var $td = $(row).find('td[data-fieldname="'+ item.fieldname +'"]'); var val = me.dialog.get_values()[item.fieldname]; - + wn.model.set_value(me.table_field.options, $td.attr('data-doc_name'), - item.fieldname, me.dialog.get_values()[item.fieldname]); + item.fieldname, val); $td.attr('data-fieldvalue', val); // If field type is currency the update with format currency @@ -279,6 +279,10 @@ wn.ui.form.TableGrid = Class.extend({ } }); + // refresh field to push to grid rows + refresh_field(this.table_field.fieldname); + + // append row to tbody of grid $(new_row).appendTo($(this.parent).find(".grid tbody")); } }); \ No newline at end of file From eb8753e8b6419d6d50765d42975d3fcf800db078 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 15:56:36 +0530 Subject: [PATCH 05/24] [fix] [minor] new grid to hide delete button on new row & added description --- setup/doctype/price_list/price_list.js | 6 +++--- setup/doctype/price_list/price_list.txt | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index cbca413f0c..397e9826ad 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -164,7 +164,7 @@ wn.ui.form.TableGrid = Class.extend({ if (row) this.dialog.set_values(this.make_dialog_values(row)); - $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons()); + $a(this.dialog.body, 'div', '', '', this.make_dialog_buttons(row)); this.dialog.show(); this.dialog.$wrapper.find('button.update').on('click', function() { @@ -186,12 +186,12 @@ wn.ui.form.TableGrid = Class.extend({ return dialog_values; }, - make_dialog_buttons: function() { + make_dialog_buttons: function(row) { var me = this; var buttons = ''; // if user can delete then only add the delete button in dialog - if (wn.model.can_delete(me.frm.doc.doctype)) + if (wn.model.can_delete(me.frm.doc.doctype) && row) buttons += ' '; return buttons; diff --git a/setup/doctype/price_list/price_list.txt b/setup/doctype/price_list/price_list.txt index 46905a6591..343331dd0c 100644 --- a/setup/doctype/price_list/price_list.txt +++ b/setup/doctype/price_list/price_list.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-25 11:35:09", "docstatus": 0, - "modified": "2013-09-06 15:03:38", + "modified": "2013-09-30 15:50:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -85,6 +85,7 @@ "reqd": 1 }, { + "description": "To change row values, click on the respective row", "doctype": "DocField", "fieldname": "item_prices_section", "fieldtype": "Section Break", From 300ae0cdf4444129f789a4b45cb4037e890951d5 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Sep 2013 17:57:22 +0530 Subject: [PATCH 06/24] [fix] [minor] dont call is_pos trigger in onload of pos invoice --- accounts/doctype/sales_invoice/sales_invoice.js | 6 ++++-- accounts/doctype/sales_invoice/sales_invoice.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 6639e65e6c..4f8dda8fbe 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -29,8 +29,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte // toggle to pos view if is_pos is 1 in user_defaults if ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) && cint(wn.defaults.get_user_defaults("fs_pos_view"))===1) { - this.frm.set_value("is_pos", 1); - this.is_pos(); + if(this.frm.doc.__islocal) { + this.frm.set_value("is_pos", 1); + this.is_pos(); + } cur_frm.cscript.toggle_pos(true); } diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 12deed73a8..2eb9ae84cb 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -195,7 +195,7 @@ class DocType(SellingController): pos = get_pos_settings(self.doc.company) if pos: - if not for_validate: + if not for_validate and not self.doc.customer: self.doc.customer = pos.customer self.set_customer_defaults() From cadc6e1b2be2563bd3afed150bd76d8313f7cb54 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 30 Sep 2013 17:57:37 +0530 Subject: [PATCH 07/24] [fix] [minor] dont call is_pos trigger in onload of pos invoice --- setup/doctype/price_list/price_list.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index a190710d4e..cbca413f0c 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -181,7 +181,7 @@ wn.ui.form.TableGrid = Class.extend({ var dialog_values = {}; $.each(this.fields, function(i, item) { - dialog_values[item.fieldname] = $(row).find('td[data-fieldname="'+ item.fieldname +'"]').data('fieldvalue'); + dialog_values[item.fieldname] = $(row).find('td[data-fieldname="'+ item.fieldname +'"]').attr('data-fieldvalue'); }); return dialog_values; @@ -206,9 +206,9 @@ wn.ui.form.TableGrid = Class.extend({ $.each(me.fields, function(i, item) { var $td = $(row).find('td[data-fieldname="'+ item.fieldname +'"]'); var val = me.dialog.get_values()[item.fieldname]; - + wn.model.set_value(me.table_field.options, $td.attr('data-doc_name'), - item.fieldname, me.dialog.get_values()[item.fieldname]); + item.fieldname, val); $td.attr('data-fieldvalue', val); // If field type is currency the update with format currency @@ -279,6 +279,10 @@ wn.ui.form.TableGrid = Class.extend({ } }); + // refresh field to push to grid rows + refresh_field(this.table_field.fieldname); + + // append row to tbody of grid $(new_row).appendTo($(this.parent).find(".grid tbody")); } }); \ No newline at end of file From 4233ae2258a1f60edb9e5cc331fc79312e2c08c8 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 18:18:19 +0530 Subject: [PATCH 08/24] [pos] pos related fixes --- accounts/doctype/sales_invoice/pos.js | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index e19652d25f..0dba40fabc 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -214,7 +214,7 @@ erpnext.POS = Class.extend({ // if form is local then allow this function if (me.frm.doc.docstatus===0) { - $("div.pos-item").on("click", function() { + $(me.wrapper).find("div.pos-item").on("click", function() { if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && me.frm.doc.quotation_to == "Customer") || me.frm.doctype != "Quotation")) { @@ -313,7 +313,7 @@ erpnext.POS = Class.extend({ // taxes var taxes = wn.model.get_children(this.sales_or_purchase + " Taxes and Charges", this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype); - $(".tax-table") + $(this.wrapper).find(".tax-table") .toggle((taxes && taxes.length) ? true : false) .find("tbody").empty(); @@ -345,18 +345,18 @@ erpnext.POS = Class.extend({ // if form is local then only run all these functions if (this.frm.doc.docstatus===0) { - $("input.qty").on("focus", function() { + $(this.wrapper).find("input.qty").on("focus", function() { $(this).select(); }); // append quantity to the respective item after change from input box - $("input.qty").on("change", function() { + $(this.wrapper).find("input.qty").on("change", function() { var item_code = $(this).closest("tr")[0].id; me.update_qty(item_code, $(this).val(), true); }); // on td click toggle the highlighting of row - me.wrapper.find("#cart tbody tr td").on("click", function() { + $(this.wrapper).find("#cart tbody tr td").on("click", function() { var row = $(this).closest("tr"); if (row.attr("data-selected") == "false") { row.attr("class", "warning"); @@ -376,16 +376,22 @@ erpnext.POS = Class.extend({ // if form is submitted & cancelled then disable all input box & buttons if (this.frm.doc.docstatus>=1) { - me.wrapper.find('input, button').each(function () { + $(this.wrapper).find('input, button').each(function () { $(this).prop('disabled', true); }); - $(".delete-items").hide(); - $(".make-payment").hide(); + $(this.wrapper).find(".delete-items").hide(); + $(this.wrapper).find(".make-payment").hide(); + } + else { + $(this.wrapper).find('input, button').each(function () { + $(this).prop('disabled', false); + }); + $(this.wrapper).find(".make-payment").show(); } // Show Make Payment button only in Sales Invoice if (this.frm.doctype != "Sales Invoice") - $(".make-payment").hide(); + $(this.wrapper).find(".make-payment").hide(); // If quotation to is not Customer then remove party if (this.frm.doctype == "Quotation") { @@ -395,7 +401,7 @@ erpnext.POS = Class.extend({ } }, refresh_delete_btn: function() { - $(".delete-items").toggle($(".item-cart .warning").length ? true : false); + $(this.wrapper).find(".delete-items").toggle($(".item-cart .warning").length ? true : false); }, add_item_thru_barcode: function() { var me = this; @@ -417,9 +423,9 @@ erpnext.POS = Class.extend({ remove_selected_item: function() { var me = this; var selected_items = []; - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = $(this.wrapper).find("#cart tbody tr").length; for(var x=0; x<=no_of_items - 1; x++) { - var row = me.wrapper.find("#cart tbody tr:eq(" + x + ")"); + var row = $(this.wrapper).find("#cart tbody tr:eq(" + x + ")"); if(row.attr("data-selected") == "true") { selected_items.push(row.attr("id")); } @@ -442,7 +448,7 @@ erpnext.POS = Class.extend({ }, make_payment: function() { var me = this; - var no_of_items = me.wrapper.find("#cart tbody tr").length; + var no_of_items = $(this.wrapper).find("#cart tbody tr").length; var mode_of_payment = []; if (no_of_items == 0) From 67a9ea68008c6a73e89bdd18fd75d8b135714299 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 30 Sep 2013 19:05:36 +0530 Subject: [PATCH 09/24] [price_list] [minor] move header of new grid to right if currency --- setup/doctype/price_list/price_list.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 397e9826ad..2c24d7ec89 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -93,11 +93,16 @@ wn.ui.form.TableGrid = Class.extend({ // Make other headers with label as heading $.each(this.fields, function(i, obj) { - if (obj.in_list_view===1) - var th = document.createElement("th"); + var th = document.createElement("th"); + + // If currency then move header to right + if (obj.fieldtype == "Currency") + $(th).attr("style", "vertical-align:middle; text-align:right;"); + else $(th).attr("style", "vertical-align:middle"); - $(th).html(obj.label); - $(th).appendTo(row); + + $(th).html(obj.label); + $(th).appendTo(row); }); return header; From d780baeacc92c4c8c83fde464de75982a503f2cd Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Oct 2013 11:22:51 +0530 Subject: [PATCH 10/24] [fix] [minor] fixes in old patch --- patches/august_2013/p02_rename_price_list.py | 1 + 1 file changed, 1 insertion(+) diff --git a/patches/august_2013/p02_rename_price_list.py b/patches/august_2013/p02_rename_price_list.py index 41efb27306..0a1929925b 100644 --- a/patches/august_2013/p02_rename_price_list.py +++ b/patches/august_2013/p02_rename_price_list.py @@ -6,6 +6,7 @@ import webnotes def execute(): webnotes.reload_doc("selling", "doctype", "shopping_cart_price_list") + webnotes.reload_doc("setup", "doctype", "item_price") for t in [ ("Supplier Quotation", "price_list_name", "buying_price_list"), From 49e71400acfadfe0b14ec0ada1e4541ffddf88b0 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Oct 2013 15:20:06 +0530 Subject: [PATCH 11/24] [patch] [minor] fix wrong customers in pos --- patches/patch_list.py | 1 + .../september_2013/p05_fix_customer_in_pos.py | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 patches/september_2013/p05_fix_customer_in_pos.py diff --git a/patches/patch_list.py b/patches/patch_list.py index 7041ba8858..6d1a084f68 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -218,4 +218,5 @@ patch_list = [ "execute:webnotes.bean('Style Settings').save() #2013-09-19", "execute:webnotes.conn.set_value('Accounts Settings', None, 'frozen_accounts_modifier', 'Accounts Manager') # 2013-09-24", "patches.september_2013.p04_unsubmit_serial_nos", + "patches.september_2013.p05_fix_customer_in_pos", ] \ No newline at end of file diff --git a/patches/september_2013/p05_fix_customer_in_pos.py b/patches/september_2013/p05_fix_customer_in_pos.py new file mode 100644 index 0000000000..60210dab24 --- /dev/null +++ b/patches/september_2013/p05_fix_customer_in_pos.py @@ -0,0 +1,22 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +def execute(): + si_list = webnotes.conn.sql("""select name, debit_to from `tabSales Invoice` + where ifnull(is_pos, 1)=1 and docstatus=1 and modified > '2013-09-03'""", as_dict=1) + + for si in si_list: + if not webnotes.conn.get_value("GL Entry", {"voucher_type": "Sales Invoice", + "voucher_no": si.name, "account": si.debit_to}): + debit_to = webnotes.conn.sql("""select account from `tabGL Entry` gle + where voucher_type='Sales Invoice' and voucher_no=%s + and (select master_type from tabAccount where name=gle.account)='Customer' + """, si.name) + if debit_to: + si_bean = webnotes.bean("Sales Invoice", si.name) + si_bean.doc.debit_to = debit_to[0][0] + si_bean.doc.customer = None + si_bean.run_method("set_customer_defaults") + si_bean.update_after_submit() \ No newline at end of file From b6177cbb5b38c88624eefb09f921e69d30157d41 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 1 Oct 2013 17:11:39 +0530 Subject: [PATCH 12/24] [minor] change filename to unicode after os.walk and os.listdir --- setup/doctype/backup_manager/backup_dropbox.py | 1 + setup/doctype/backup_manager/backup_googledrive.py | 1 + setup/doctype/company/charts/import_from_openerp.py | 2 ++ 3 files changed, 4 insertions(+) diff --git a/setup/doctype/backup_manager/backup_dropbox.py b/setup/doctype/backup_manager/backup_dropbox.py index 8d16353952..b4a8f66d4c 100644 --- a/setup/doctype/backup_manager/backup_dropbox.py +++ b/setup/doctype/backup_manager/backup_dropbox.py @@ -96,6 +96,7 @@ def backup_to_dropbox(): error_log = [] path = os.path.join(get_base_path(), "public", "files") for filename in os.listdir(path): + filename = cstr(filename) if filename in ignore_list: continue diff --git a/setup/doctype/backup_manager/backup_googledrive.py b/setup/doctype/backup_manager/backup_googledrive.py index 5d7b6ad0fa..440d907f2e 100644 --- a/setup/doctype/backup_manager/backup_googledrive.py +++ b/setup/doctype/backup_manager/backup_googledrive.py @@ -85,6 +85,7 @@ def backup_to_gdrive(): webnotes.conn.close() path = os.path.join(get_base_path(), "public", "files") for filename in os.listdir(path): + filename = cstr(filename) found = False filepath = os.path.join(path, filename) ext = filename.split('.')[-1] diff --git a/setup/doctype/company/charts/import_from_openerp.py b/setup/doctype/company/charts/import_from_openerp.py index 894c2d739d..ef800086c9 100644 --- a/setup/doctype/company/charts/import_from_openerp.py +++ b/setup/doctype/company/charts/import_from_openerp.py @@ -9,6 +9,7 @@ from __future__ import unicode_literals import os, json from xml.etree import ElementTree as ET from webnotes.utils.datautils import read_csv_content +from webnotes.utils import cstr path = "/Users/rmehta/Downloads/openerp/openerp/addons" chart_roots = [] @@ -108,6 +109,7 @@ def find_charts(): basename = os.path.basename(basepath) if basename.startswith("l10n"): for fname in files: + fname = cstr(fname) filepath = os.path.join(basepath, fname) if fname.endswith(".xml"): tree = ET.parse(filepath) From cf3011839f6ab28f9f1d75759bdd3c9fa30b8914 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Oct 2013 18:14:16 +0530 Subject: [PATCH 13/24] [fix] [minor] bind onclick function based on docstatus in pos --- accounts/doctype/sales_invoice/pos.js | 12 ++++++------ accounts/doctype/sales_invoice/sales_invoice.js | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 0dba40fabc..c68b9915c8 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -213,8 +213,8 @@ erpnext.POS = Class.extend({ }); // if form is local then allow this function - if (me.frm.doc.docstatus===0) { - $(me.wrapper).find("div.pos-item").on("click", function() { + $(me.wrapper).find("div.pos-item").on("click", function() { + if(me.frm.doc.docstatus==0) { if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && me.frm.doc.quotation_to == "Customer") || me.frm.doctype != "Quotation")) { @@ -223,8 +223,8 @@ erpnext.POS = Class.extend({ } else me.add_to_cart($(this).attr("data-item_code")); - }); - } + } + }); } }); }, @@ -371,7 +371,7 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); - this.frm.pos.barcode.$input.focus(); + this.barcode.$input.focus(); } // if form is submitted & cancelled then disable all input box & buttons @@ -476,7 +476,7 @@ erpnext.POS = Class.extend({ "total_amount": $(".grand-total").text() }); dialog.show(); - me.frm.pos.barcode.$input.focus(); + me.barcode.$input.focus(); dialog.get_input("total_amount").prop("disabled", true); diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 4f8dda8fbe..5220c0fa20 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -29,11 +29,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte // toggle to pos view if is_pos is 1 in user_defaults if ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) && cint(wn.defaults.get_user_defaults("fs_pos_view"))===1) { - if(this.frm.doc.__islocal) { + if(this.frm.doc.__islocal && !this.frm.doc.amended_from) { this.frm.set_value("is_pos", 1); - this.is_pos(); + this.is_pos(function() {cur_frm.cscript.toggle_pos(true);}); } - cur_frm.cscript.toggle_pos(true); } // if document is POS then change default print format to "POS Invoice" @@ -128,7 +127,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.get_terms(); }, - is_pos: function() { + is_pos: function(callback_fn) { cur_frm.cscript.hide_fields(this.frm.doc); if(cint(this.frm.doc.is_pos)) { if(!this.frm.doc.company) { @@ -142,6 +141,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte callback: function(r) { if(!r.exc) { me.frm.script_manager.trigger("update_stock"); + if(callback_fn) callback_fn() } } }); From 2ebbe95e0464e0a273bdcd057ed3f69bc144ad8a Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 12:44:59 +0530 Subject: [PATCH 14/24] [minor] [fix] item prices html table --- setup/doctype/price_list/price_list.js | 248 ++++++++++-------------- setup/doctype/price_list/price_list.txt | 8 +- 2 files changed, 112 insertions(+), 144 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 2c24d7ec89..1dd9ec53de 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -14,46 +14,42 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.show_item_prices = function() { var item_price = wn.model.get("Item Price", {parent: cur_frm.doc.name}); - cur_frm.toggle_display("item_prices", true); - $(cur_frm.fields_dict.item_prices.wrapper).empty(); + $(cur_frm.fields_dict.item_prices_html.wrapper).empty(); new wn.ui.form.TableGrid({ - parent: cur_frm.fields_dict.item_prices.wrapper, + parent: cur_frm.fields_dict.item_prices_html.wrapper, frm: cur_frm, - table_field: wn.model.get("DocField", {parent:"Price List", fieldname:"item_prices"})[0] + table_field: wn.meta.get_docfield("Price List", "item_prices", cur_frm.doc.name) }); } wn.ui.form.TableGrid = Class.extend({ init: function(opts) { $.extend(this, opts); - this.fields = wn.model.get("DocField", {parent: this.table_field.options}); + this.fields = wn.meta.get_docfields("Item Price", cur_frm.doc.name); this.make_table(); }, make_table: function() { var me = this; // Creating table & assigning attributes var grid_table = document.createElement("table"); - $(grid_table).attr("class", "table table-hover table-bordered grid"); + grid_table.className = "table table-hover table-bordered grid"; // Appending header & rows to table - - $(this.make_table_headers()).appendTo(grid_table); - $(this.make_table_rows()).appendTo(grid_table); + grid_table.appendChild(this.make_table_headers()); + grid_table.appendChild(this.make_table_rows()); // Creating button to add new row var btn_div = document.createElement("div"); var new_row_btn = document.createElement("button"); - $new_row_btn = $(new_row_btn); - $new_row_btn.attr({ - "class": "btn btn-success table-new-row", - "title": "Add new row" - }); + new_row_btn.className = "btn btn-success table-new-row"; + new_row_btn.title = "Add new row"; + var btn_icon = document.createElement("i"); - $(btn_icon).attr("class", "icon-plus"); - $(btn_icon).appendTo(new_row_btn); - $new_row_btn.append(" Add new row"); - $new_row_btn.appendTo(btn_div); + btn_icon.className = "icon-plus"; + new_row_btn.appendChild(btn_icon); + new_row_btn.innerHTML += " Add new row"; + btn_div.appendChild(new_row_btn); // Appending table & button to parent var $grid_table = $(grid_table).appendTo($(this.parent)); @@ -75,35 +71,33 @@ wn.ui.form.TableGrid = Class.extend({ // Creating header row var row = document.createElement("tr"); - $(row).attr({ - "class": "active", - "style": "height:50px" - }); - $(row).appendTo(header); - + row.className = "active"; + // row.style = "height:50px"; + + // Creating head first cell var th = document.createElement("th"); - $(th).attr({ - "width": "8%", - "style": "vertical-align:middle", - "class": "text-center" - }); - $(th).html("#"); - $(th).appendTo(row); + th.width = "8%"; + th.className = "text-center"; + th.innerHTML = "#"; + row.appendChild(th); // Make other headers with label as heading - $.each(this.fields, function(i, obj) { - var th = document.createElement("th"); + for(var i=0, l=this.fields.length; i Date: Wed, 2 Oct 2013 15:16:22 +0530 Subject: [PATCH 15/24] [minor] [fix] item price grid --- setup/doctype/price_list/price_list.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index 1dd9ec53de..e1cb52130d 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -33,7 +33,7 @@ wn.ui.form.TableGrid = Class.extend({ var me = this; // Creating table & assigning attributes var grid_table = document.createElement("table"); - grid_table.className = "table table-hover table-bordered grid"; + grid_table.className = "table table-hover table-bordered table-grid"; // Appending header & rows to table grid_table.appendChild(this.make_table_headers()); @@ -72,8 +72,6 @@ wn.ui.form.TableGrid = Class.extend({ // Creating header row var row = document.createElement("tr"); row.className = "active"; - // row.style = "height:50px"; - // Creating head first cell var th = document.createElement("th"); @@ -106,7 +104,6 @@ wn.ui.form.TableGrid = Class.extend({ // Creating table body var table_body = document.createElement("tbody"); - table_body.style = "cursor: pointer"; var item_prices = wn.model.get_children(this.table_field.options, this.frm.doc.name, this.table_field.fieldname, this.frm.doctype); @@ -210,8 +207,7 @@ wn.ui.form.TableGrid = Class.extend({ $(row).remove(); // Re-assign idx - $.each($(this.parent).find(".grid tbody tr"), function(idx, data) { - $(data).attr("data-idx", idx + 1); + $.each($(this.parent).find("tbody tr"), function(idx, data) { var $td = $(data).find('td:first'); $td.html(idx + 1); }); @@ -221,7 +217,6 @@ wn.ui.form.TableGrid = Class.extend({ add_new_row: function(d) { var tr = document.createElement("tr"); tr.className = "table-row"; - tr.setAttribute("data-idx", d.idx); tr.setAttribute("data-docname", d.name); // Creating table data & appending to row From c49986f092ab145205adc47e3aeae6dd0da550e8 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 2 Oct 2013 16:14:30 +0530 Subject: [PATCH 16/24] [minor] [fix] price list table --- setup/doctype/price_list/price_list.css | 7 +++++++ setup/doctype/price_list/price_list.js | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 setup/doctype/price_list/price_list.css diff --git a/setup/doctype/price_list/price_list.css b/setup/doctype/price_list/price_list.css new file mode 100644 index 0000000000..61b069442f --- /dev/null +++ b/setup/doctype/price_list/price_list.css @@ -0,0 +1,7 @@ +.table-grid tbody tr { + cursor: pointer; +} + +.table-grid thead tr { + height: 50px; +} \ No newline at end of file diff --git a/setup/doctype/price_list/price_list.js b/setup/doctype/price_list/price_list.js index e1cb52130d..67090bcbc1 100644 --- a/setup/doctype/price_list/price_list.js +++ b/setup/doctype/price_list/price_list.js @@ -188,6 +188,13 @@ wn.ui.form.TableGrid = Class.extend({ if(!docname && row) docname = $(row).attr("data-docname"); $.each(me.fields, function(i, df) { var val = me.dialog.get_values()[df.fieldname]; + + if(["Currency", "Float"].indexOf(df.fieldtype)!==-1) { + val = flt(val); + } else if(["Int", "Check"].indexOf(df.fieldtype)!==-1) { + val = cint(val); + } + wn.model.set_value(me.table_field.options, docname, df.fieldname, val); From a1d1c980bc041485f843f8899ab1504e4a315098 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 2 Oct 2013 16:29:45 +0530 Subject: [PATCH 17/24] [minor] fixes in stock balance report, bin uom and sle is_cancelled --- patches/october_2013/__init__.py | 0 patches/october_2013/fix_is_cancelled_in_sle.py | 13 +++++++++++++ patches/patch_list.py | 1 + public/js/stock_grid_report.js | 6 ++++-- stock/doctype/bin/bin.py | 2 +- .../stock_reconciliation/stock_reconciliation.py | 1 + stock/page/stock_balance/stock_balance.js | 7 ++++--- 7 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 patches/october_2013/__init__.py create mode 100644 patches/october_2013/fix_is_cancelled_in_sle.py diff --git a/patches/october_2013/__init__.py b/patches/october_2013/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/october_2013/fix_is_cancelled_in_sle.py b/patches/october_2013/fix_is_cancelled_in_sle.py new file mode 100644 index 0000000000..050c1e68cd --- /dev/null +++ b/patches/october_2013/fix_is_cancelled_in_sle.py @@ -0,0 +1,13 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.conn.sql("""update `tabStock Ledger Entry` set is_cancelled = 'No' + where ifnull(is_cancelled, '') = ''""") + + webnotes.conn.sql("""update tabBin b set b.stock_uom = + (select i.stock_uom from tabItem i where i.name = b.item_code) + where b.created_on>='2013-09-01'""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 6d1a084f68..f228acf97e 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -219,4 +219,5 @@ patch_list = [ "execute:webnotes.conn.set_value('Accounts Settings', None, 'frozen_accounts_modifier', 'Accounts Manager') # 2013-09-24", "patches.september_2013.p04_unsubmit_serial_nos", "patches.september_2013.p05_fix_customer_in_pos", + "patches.october_2013.fix_is_cancelled_in_sle", ] \ No newline at end of file diff --git a/public/js/stock_grid_report.js b/public/js/stock_grid_report.js index 8b79b5e1ee..46370d27f6 100644 --- a/public/js/stock_grid_report.js +++ b/public/js/stock_grid_report.js @@ -29,6 +29,8 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({ if(add_qty) wh.fifo_stack.push([add_qty, sl.incoming_rate, sl.posting_date]); + + if(sl.serial_no) value_diff = this.get_serialized_value_diff(sl); } else { // outgoing if(sl.serial_no) { @@ -98,7 +100,7 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({ $.each(sl.serial_no.trim().split("\n"), function(i, sr) { if(sr) { - value_diff += flt(me.serialized_buying_rates[sr.trim()]); + value_diff += flt(me.serialized_buying_rates[sr.trim().toLowerCase()]); } }); @@ -112,7 +114,7 @@ erpnext.StockGridReport = wn.views.TreeGridReport.extend({ if(sle.qty > 0 && sle.serial_no) { $.each(sle.serial_no.trim().split("\n"), function(i, sr) { if(sr && sle.incoming_rate !== undefined) { - serialized_buying_rates[sr.trim()] = flt(sle.incoming_rate); + serialized_buying_rates[sr.trim().toLowerCase()] = flt(sle.incoming_rate); } }); } diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index 788642fe4f..c419cad43b 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -16,7 +16,7 @@ class DocType: self.doclist = doclist def validate(self): - if not self.doc.stock_uom: + if self.doc.fields.get("__islocal") or not self.doc.stock_uom: self.doc.stock_uom = webnotes.conn.get_value('Item', self.doc.item_code, 'stock_uom') self.validate_mandatory() diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index 465edc490a..9feb57e716 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -246,6 +246,7 @@ class DocType(StockController): "stock_uom": webnotes.conn.get_value("Item", row.item_code, "stock_uom"), "voucher_detail_no": row.voucher_detail_no, "fiscal_year": self.doc.fiscal_year, + "is_cancelled": "No" }) args.update(opts) self.make_sl_entries([args]) diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js index 1bc5d1c6bc..b45a610be8 100644 --- a/stock/page/stock_balance/stock_balance.js +++ b/stock/page/stock_balance/stock_balance.js @@ -126,10 +126,11 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ } else { item.inflow_value += value_diff; } - } - item.closing_qty += qty_diff; - item.closing_value += value_diff; + item.closing_qty += qty_diff; + item.closing_value += value_diff; + } + } else { break; } From efa94ce1bf092b7b4150aed1ca2ce1611fb7f203 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 2 Oct 2013 16:40:14 +0530 Subject: [PATCH 18/24] [fix] [minor] fixe in patch --- patches/october_2013/fix_is_cancelled_in_sle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/patches/october_2013/fix_is_cancelled_in_sle.py b/patches/october_2013/fix_is_cancelled_in_sle.py index 050c1e68cd..cb51b5d7ca 100644 --- a/patches/october_2013/fix_is_cancelled_in_sle.py +++ b/patches/october_2013/fix_is_cancelled_in_sle.py @@ -10,4 +10,4 @@ def execute(): webnotes.conn.sql("""update tabBin b set b.stock_uom = (select i.stock_uom from tabItem i where i.name = b.item_code) - where b.created_on>='2013-09-01'""") \ No newline at end of file + where b.creation>='2013-09-01'""") \ No newline at end of file From d1809e30e9e81fa468792b1407e7b3f0082048db Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 3 Oct 2013 18:58:11 +0530 Subject: [PATCH 19/24] [minor] [fix] due date in sales invoice --- accounts/doctype/sales_invoice/sales_invoice.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index 00c6c2cc5c..516d1925a8 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-09-19 11:42:13", + "modified": "2013-10-03 18:54:31", "modified_by": "Administrator", "owner": "Administrator" }, @@ -180,7 +180,6 @@ "search_index": 1 }, { - "default": "Today", "description": "Enter the date by which payments from customer is expected against this invoice.", "doctype": "DocField", "fieldname": "due_date", From b4212a5672d7f9651f568b19aa7cae679639ae97 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 4 Oct 2013 12:54:16 +0530 Subject: [PATCH 20/24] [patch] [minor] perpetua inventory utility patch --- ...petual_inventory_stock_transfer_utility.py | 71 +++++++++++++++++++ .../set_stock_value_diff_in_sle.py | 10 +++ 2 files changed, 81 insertions(+) create mode 100644 patches/october_2013/perpetual_inventory_stock_transfer_utility.py create mode 100644 patches/october_2013/set_stock_value_diff_in_sle.py diff --git a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py new file mode 100644 index 0000000000..f59ebdb55b --- /dev/null +++ b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py @@ -0,0 +1,71 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import nowdate, nowtime +from accounts.utils import get_fiscal_year + +def execute(): + item_map = {} + for item in webnotes.conn.sql("""select * from tabItem""", as_dict=1): + item_map.setdefault(item.name, item) + + warehouse_map = get_warehosue_map() + # naming_series = + for company in webnotes.conn.sql("select name from tabCompany"): + stock_entry = [{ + "doctype": "Stock Entry", + "naming_series": naming_series, + "posting_date": nowdate(), + "posting_time": nowtime(), + "purpose": "Material Transfer", + "company": company[0], + "remarks": "Material Transfer to activate perpetual inventory", + "fiscal_year": get_fiscal_year(nowdate()) + }] + expense_account = "Cost of Goods Sold - NISL" + cost_center = "Default CC Ledger - NISL" + + for bin in webnotes.conn.sql("select * from tabBin where company=%s", company[0] as_dict=1): + new_warehouse = warehouse_map[bin.warehouse].get("fixed_asset_warehouse") \ + if cstr(item_map[bin.item_code]) == "Yes" else wh.get("current_asset_warehouse") + + item_details = item_map[bin.item_code] + stock_entry.append({ + "doctype": "Stock Entry Detail", + "parentfield": "mtn_details", + "s_warehouse": bin.warehouse, + "t_warehouse": new_warehouse, + "item_code": bin.item_code, + "description": item_details.description, + "qty": bin.actual_qty, + "transfer_qty": bin.actual_qty, + "uom": item_details.stock_uom, + "stock_uom": item_details.stock_uom, + "conversion_factor": 1, + "expense_account": expense_account, + "cost_center": cost_center + }) + + webnotes.bean(stock_entry).insert() + +def get_warehosue_map(): + return { + "MAHAPE": { + "current_asset_warehouse": "Mahape-New - NISL", + "fixed_asset_warehouse": "" + }, + "DROP SHIPMENT": { + "current_asset_warehouse": "Drop Shipment-New - NISL", + "fixed_asset_warehouse": "" + }, + "TRANSIT": { + "current_asset_warehouse": "Transit-New - NISL", + "fixed_asset_warehouse": "" + }, + "ASSET-MAHAPE": { + "current_asset_warehouse": "", + "fixed_asset_warehouse": "Assets-New - NISL" + } + } \ No newline at end of file diff --git a/patches/october_2013/set_stock_value_diff_in_sle.py b/patches/october_2013/set_stock_value_diff_in_sle.py new file mode 100644 index 0000000000..25f95e0e6d --- /dev/null +++ b/patches/october_2013/set_stock_value_diff_in_sle.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import cint + +def execute(): + from patches.september_2012 import repost_stock + repost_stock.execute() \ No newline at end of file From b646b3b3e661c55308aa43bd082fa3eebb6be8e2 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 4 Oct 2013 14:30:33 +0530 Subject: [PATCH 21/24] [patch] [minor] perpetual inventory stock transfer utility --- ...petual_inventory_stock_transfer_utility.py | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py index f59ebdb55b..2b39be69a5 100644 --- a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py +++ b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import nowdate, nowtime +from webnotes.utils import nowdate, nowtime, cstr from accounts.utils import get_fiscal_year def execute(): @@ -12,7 +12,8 @@ def execute(): item_map.setdefault(item.name, item) warehouse_map = get_warehosue_map() - # naming_series = + naming_series = "STE/13/" + for company in webnotes.conn.sql("select name from tabCompany"): stock_entry = [{ "doctype": "Stock Entry", @@ -22,16 +23,28 @@ def execute(): "purpose": "Material Transfer", "company": company[0], "remarks": "Material Transfer to activate perpetual inventory", - "fiscal_year": get_fiscal_year(nowdate()) + "fiscal_year": get_fiscal_year(nowdate())[0] }] expense_account = "Cost of Goods Sold - NISL" cost_center = "Default CC Ledger - NISL" - for bin in webnotes.conn.sql("select * from tabBin where company=%s", company[0] as_dict=1): - new_warehouse = warehouse_map[bin.warehouse].get("fixed_asset_warehouse") \ - if cstr(item_map[bin.item_code]) == "Yes" else wh.get("current_asset_warehouse") - + for bin in webnotes.conn.sql("""select * from tabBin bin where ifnull(item_code, '')!='' + and ifnull(warehouse, '')!='' and ifnull(actual_qty, 0) != 0 + and (select company from tabWarehouse where name=bin.warehouse)=%s""", + company[0], as_dict=1): item_details = item_map[bin.item_code] + new_warehouse = warehouse_map[bin.warehouse].get("fixed_asset_warehouse") \ + if cstr(item_details.is_asset_item) == "Yes" \ + else warehouse_map[bin.warehouse].get("current_asset_warehouse") + + if item_details.has_serial_no == "Yes": + serial_no = "\n".join([d[0] for d in webnotes.conn.sql("""select name + from `tabSerial No` where item_code = %s and warehouse = %s""", + (bin.item_code, bin.warehouse))]) + print serial_no + else: + serial_no = None + stock_entry.append({ "doctype": "Stock Entry Detail", "parentfield": "mtn_details", @@ -45,9 +58,10 @@ def execute(): "stock_uom": item_details.stock_uom, "conversion_factor": 1, "expense_account": expense_account, - "cost_center": cost_center + "cost_center": cost_center, + "serial_no": serial_no }) - + webnotes.bean(stock_entry).insert() def get_warehosue_map(): @@ -64,7 +78,7 @@ def get_warehosue_map(): "current_asset_warehouse": "Transit-New - NISL", "fixed_asset_warehouse": "" }, - "ASSET-MAHAPE": { + "ASSET - MAHAPE": { "current_asset_warehouse": "", "fixed_asset_warehouse": "Assets-New - NISL" } From 27c9ecc5384394d4ca6080ebf51ea2784078aae9 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 4 Oct 2013 14:41:41 +0530 Subject: [PATCH 22/24] [patch] [minor] perpetual inventory stock transfer utility --- .../october_2013/perpetual_inventory_stock_transfer_utility.py | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py index 2b39be69a5..c02656285f 100644 --- a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py +++ b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py @@ -41,7 +41,6 @@ def execute(): serial_no = "\n".join([d[0] for d in webnotes.conn.sql("""select name from `tabSerial No` where item_code = %s and warehouse = %s""", (bin.item_code, bin.warehouse))]) - print serial_no else: serial_no = None From 5f8477d4ef7af34d2a6bf54afeb13251ed92dc54 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 4 Oct 2013 15:29:36 +0530 Subject: [PATCH 23/24] [patch] [minor] perpetual inventory stock transfer utility --- .../perpetual_inventory_stock_transfer_utility.py | 4 ++-- stock/doctype/stock_entry/stock_entry.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py index c02656285f..8cee29a824 100644 --- a/patches/october_2013/perpetual_inventory_stock_transfer_utility.py +++ b/patches/october_2013/perpetual_inventory_stock_transfer_utility.py @@ -39,8 +39,8 @@ def execute(): if item_details.has_serial_no == "Yes": serial_no = "\n".join([d[0] for d in webnotes.conn.sql("""select name - from `tabSerial No` where item_code = %s and warehouse = %s""", - (bin.item_code, bin.warehouse))]) + from `tabSerial No` where item_code = %s and warehouse = %s + and status='Available'""", (bin.item_code, bin.warehouse))]) else: serial_no = None diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index a54f9bf05b..8c4b97e091 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -42,7 +42,7 @@ class DocType(StockController): self.validate_warehouse(pro_obj) self.validate_production_order(pro_obj) self.get_stock_and_rate() - self.validate_incoming_rate() + # self.validate_incoming_rate() self.validate_bom() self.validate_finished_goods() self.validate_return_reference_doc() From ac90ecf946773bc5fab70a04cd7ed9812e3d1b76 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 4 Oct 2013 15:36:29 +0530 Subject: [PATCH 24/24] [patch] [minor] perpetual inventory stock transfer utility --- stock/doctype/stock_entry/stock_entry.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index 8c4b97e091..a54f9bf05b 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -42,7 +42,7 @@ class DocType(StockController): self.validate_warehouse(pro_obj) self.validate_production_order(pro_obj) self.get_stock_and_rate() - # self.validate_incoming_rate() + self.validate_incoming_rate() self.validate_bom() self.validate_finished_goods() self.validate_return_reference_doc()