From 7eb90d3d5c870563a9fa652d72c02d3a92e00117 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 2 Dec 2013 20:12:18 +0530 Subject: [PATCH 01/80] Stock Ageing report migated to Script report --- stock/report/stock_ageing/__init__.py | 0 stock/report/stock_ageing/stock_ageing.js | 40 +++++++++ stock/report/stock_ageing/stock_ageing.py | 99 ++++++++++++++++++++++ stock/report/stock_ageing/stock_ageing.txt | 21 +++++ 4 files changed, 160 insertions(+) create mode 100644 stock/report/stock_ageing/__init__.py create mode 100644 stock/report/stock_ageing/stock_ageing.js create mode 100644 stock/report/stock_ageing/stock_ageing.py create mode 100644 stock/report/stock_ageing/stock_ageing.txt diff --git a/stock/report/stock_ageing/__init__.py b/stock/report/stock_ageing/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/report/stock_ageing/stock_ageing.js b/stock/report/stock_ageing/stock_ageing.js new file mode 100644 index 0000000000..f9e84b8a65 --- /dev/null +++ b/stock/report/stock_ageing/stock_ageing.js @@ -0,0 +1,40 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +wn.query_reports["Stock Ageing"] = { + "filters": [ + { + "fieldname":"company", + "label": wn._("Company"), + "fieldtype": "Link", + "options": "Company", + "default": wn.defaults.get_user_default("company"), + "reqd": 1 + }, + { + "fieldname":"to_date", + "label": wn._("To Date"), + "fieldtype": "Date", + "default": wn.datetime.get_today(), + "reqd": 1 + }, + { + "fieldname":"warehouse", + "label": wn._("Warehouse"), + "fieldtype": "Link", + "options": "Warehouse" + }, + { + "fieldname":"item_code", + "label": wn._("Item"), + "fieldtype": "Link", + "options": "Item" + }, + { + "fieldname":"brand", + "label": wn._("Brand"), + "fieldtype": "Link", + "options": "Brand" + } + ] +} \ No newline at end of file diff --git a/stock/report/stock_ageing/stock_ageing.py b/stock/report/stock_ageing/stock_ageing.py new file mode 100644 index 0000000000..f688ed96ef --- /dev/null +++ b/stock/report/stock_ageing/stock_ageing.py @@ -0,0 +1,99 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import date_diff +from webnotes import _ + +def execute(filters=None): + + columns = get_columns() + item_details = get_fifo_queue(filters) + to_date = filters["to_date"] + data = [] + for item, item_dict in item_details.items(): + fifo_queue = item_dict["fifo_queue"] + details = item_dict["details"] + if not fifo_queue: continue + + average_age = get_average_age(fifo_queue, to_date) + earliest_age = date_diff(to_date, fifo_queue[0][1]) + latest_age = date_diff(to_date, fifo_queue[-1][1]) + + data.append([item, details.item_name, details.description, details.brand, + average_age, earliest_age, latest_age, details.stock_uom]) + + return columns, data + +def get_average_age(fifo_queue, to_date): + batch_age = age_qty = total_qty = 0.0 + for batch in fifo_queue: + batch_age = date_diff(to_date, batch[1]) + age_qty += batch_age * batch[0] + total_qty += batch[0] + + return (age_qty / total_qty) if total_qty else 0.0 + +def get_columns(): + return ["Item Code:Link/Item:100", "Item Name::100", "Description::200", + "Brand:Link/Brand:100", "Average Age:Float:100", "Earliest:Int:80", + "Latest:Int:80", "UOM:Link/UOM:100"] + +def get_fifo_queue(filters): + item_details = {} + for d in get_stock_ledger_entries(filters): + item_details.setdefault(d.name, {"details": d, "fifo_queue": []}) + fifo_queue = item_details[d.name]["fifo_queue"] + if d.actual_qty > 0: + fifo_queue.append([d.actual_qty, d.posting_date]) + else: + qty_to_pop = abs(d.actual_qty) + while qty_to_pop: + batch = fifo_queue[0] if fifo_queue else [0, None] + if 0 < batch[0] <= qty_to_pop: + # if batch qty > 0 + # not enough or exactly same qty in current batch, clear batch + qty_to_pop -= batch[0] + fifo_queue.pop(0) + else: + # all from current batch + batch[0] -= qty_to_pop + qty_to_pop = 0 + + return item_details + +def get_stock_ledger_entries(filters): + if not filters.get("company"): + webnotes.throw(_("Company is mandatory")) + if not filters.get("to_date"): + webnotes.throw(_("To Date is mandatory")) + + return webnotes.conn.sql("""select + item.name, item.item_name, brand, description, item.stock_uom, actual_qty, posting_date + from `tabStock Ledger Entry` sle, + (select name, item_name, description, stock_uom, brand + from `tabItem` {item_conditions}) item + where item_code = item.name and + company = %(company)s and + posting_date <= %(to_date)s + {sle_conditions} + order by posting_date, posting_time, sle.name"""\ + .format(item_conditions=get_item_conditions(filters), + sle_conditions=get_sle_conditions(filters)), filters, as_dict=True) + +def get_item_conditions(filters): + conditions = [] + if filters.get("item_code"): + conditions.append("item_code=%(item_code)s") + if filters.get("brand"): + conditions.append("brand=%(brand)s") + + return "where {}".format(" and ".join(conditions)) if conditions else "" + +def get_sle_conditions(filters): + conditions = [] + if filters.get("warehouse"): + conditions.append("warehouse=%(warehouse)s") + + return "and {}".format(" and ".join(conditions)) if conditions else "" \ No newline at end of file diff --git a/stock/report/stock_ageing/stock_ageing.txt b/stock/report/stock_ageing/stock_ageing.txt new file mode 100644 index 0000000000..b88ebce5ed --- /dev/null +++ b/stock/report/stock_ageing/stock_ageing.txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-12-02 17:09:31", + "docstatus": 0, + "modified": "2013-12-02 17:09:31", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Item", + "report_name": "Stock Ageing", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Stock Ageing" + } +] \ No newline at end of file From 47e40242bdf9f2937855f9faff3e9625c7e50c1e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 2 Dec 2013 23:13:36 +0530 Subject: [PATCH 02/80] [minor] removed old stock ageing grid report --- stock/page/stock_ageing/README.md | 1 - stock/page/stock_ageing/__init__.py | 1 - stock/page/stock_ageing/stock_ageing.js | 183 ----------------- stock/page/stock_ageing/stock_ageing.txt | 37 ---- stock/page/stock_home/stock_home.js | 5 +- stock/page/stock_ledger/README.md | 1 - stock/page/stock_ledger/__init__.py | 1 - stock/page/stock_ledger/stock_ledger.js | 247 ----------------------- stock/page/stock_ledger/stock_ledger.txt | 41 ---- 9 files changed, 3 insertions(+), 514 deletions(-) delete mode 100644 stock/page/stock_ageing/README.md delete mode 100644 stock/page/stock_ageing/__init__.py delete mode 100644 stock/page/stock_ageing/stock_ageing.js delete mode 100644 stock/page/stock_ageing/stock_ageing.txt delete mode 100644 stock/page/stock_ledger/README.md delete mode 100644 stock/page/stock_ledger/__init__.py delete mode 100644 stock/page/stock_ledger/stock_ledger.js delete mode 100644 stock/page/stock_ledger/stock_ledger.txt diff --git a/stock/page/stock_ageing/README.md b/stock/page/stock_ageing/README.md deleted file mode 100644 index e8597b2194..0000000000 --- a/stock/page/stock_ageing/README.md +++ /dev/null @@ -1 +0,0 @@ -Average "age" of an Item in a particular Warehouse based on First-in-first-out (FIFO). \ No newline at end of file diff --git a/stock/page/stock_ageing/__init__.py b/stock/page/stock_ageing/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ageing/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js deleted file mode 100644 index 6c626e22ed..0000000000 --- a/stock/page/stock_ageing/stock_ageing.js +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - - -wn.pages['stock-ageing'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ageing'), - single_column: true - }); - - new erpnext.StockAgeing(wrapper); - - - wrapper.appframe.add_module_icon("Stock") - -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockAgeing = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ageing"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand", "Serial No"], - }) - }, - setup_columns: function() { - this.columns = [ - {id: "name", name: wn._("Item"), field: "name", width: 300, - link_formatter: { - open_btn: true, - doctype: '"Item"' - }}, - {id: "item_name", name: wn._("Item Name"), field: "item_name", - width: 100, formatter: this.text_formatter}, - {id: "description", name: wn._("Description"), field: "description", - width: 200, formatter: this.text_formatter}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "average_age", name: wn._("Average Age"), field: "average_age", - formatter: this.currency_formatter}, - {id: "earliest", name: wn._("Earliest"), field: "earliest", - formatter: this.currency_formatter}, - {id: "latest", name: wn._("Latest"), field: "latest", - formatter: this.currency_formatter}, - {id: "stock_uom", name: "UOM", field: "stock_uom", width: 100}, - ]; - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse..."}, - {fieldtype:"Select", label: wn._("Brand"), link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Select", label: wn._("Plot By"), - options: ["Average Age", "Earliest", "Latest"]}, - {fieldtype:"Date", label: wn._("To Date")}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - setup_filters: function() { - var me = this; - this._super(); - this.trigger_refresh_on_change(["warehouse", "plot_by", "brand"]); - this.show_zero_check(); - }, - init_filter_values: function() { - this._super(); - this.filter_inputs.to_date.val(dateutil.obj_to_user(new Date())); - }, - prepare_data: function() { - var me = this; - - if(!this.data) { - me._data = wn.report_dump.data["Item"]; - me.item_by_name = me.make_name_map(me._data); - } - - this.data = [].concat(this._data); - - this.serialized_buying_rates = this.get_serialized_buying_rates(); - - $.each(this.data, function(i, d) { - me.reset_item_values(d); - }); - - this.prepare_balances(); - - // filter out brand - this.data = $.map(this.data, function(d) { - return me.apply_filter(d, "brand") ? d : null; - }); - - // filter out rows with zero values - this.data = $.map(this.data, function(d) { - return me.apply_zero_filter(null, d, null, me) ? d : null; - }); - }, - prepare_balances: function() { - var me = this; - var to_date = dateutil.str_to_obj(this.to_date); - var data = wn.report_dump.data["Stock Ledger Entry"]; - - this.item_warehouse = {}; - - for(var i=0, j=data.length; i to_date) - break; - } - } - - $.each(me.data, function(i, item) { - var full_fifo_stack = []; - if(me.is_default("warehouse")) { - $.each(me.item_warehouse[item.name] || {}, function(i, wh) { - full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || []) - }); - } else { - full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name).fifo_stack || []; - } - - var age_qty = total_qty = 0.0; - var min_age = max_age = null; - - $.each(full_fifo_stack, function(i, batch) { - var batch_age = dateutil.get_diff(me.to_date, batch[2]); - age_qty += batch_age * batch[0]; - total_qty += batch[0]; - max_age = Math.max(max_age, batch_age); - if(min_age===null) min_age=batch_age; - else min_age = Math.min(min_age, batch_age); - }); - - item.average_age = total_qty.toFixed(2)==0.0 ? 0 - : (age_qty / total_qty).toFixed(2); - item.earliest = max_age || 0.0; - item.latest = min_age || 0.0; - }); - - this.data = this.data.sort(function(a, b) { - var sort_by = me.plot_by.replace(" ", "_").toLowerCase(); - return b[sort_by] - a[sort_by]; - }); - }, - get_plot_data: function() { - var data = []; - var me = this; - - data.push({ - label: me.plot_by, - data: $.map(me.data, function(item, idx) { - return [[idx+1, item[me.plot_by.replace(" ", "_").toLowerCase() ]]] - }), - bars: {show: true}, - }); - - return data.length ? data : false; - }, - get_plot_options: function() { - var me = this; - return { - grid: { hoverable: true, clickable: true }, - xaxis: { - ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }), - max: 15 - }, - series: { downsample: { threshold: 1000 } } - } - } -}); \ No newline at end of file diff --git a/stock/page/stock_ageing/stock_ageing.txt b/stock/page/stock_ageing/stock_ageing.txt deleted file mode 100644 index cd1cfbd1c9..0000000000 --- a/stock/page/stock_ageing/stock_ageing.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ageing", - "standard": "Yes", - "title": "Stock Ageing" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ageing", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ageing" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index 4be5a46601..ec432425b5 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -150,8 +150,9 @@ wn.module_page["Stock"] = [ "label": wn._("Stock Level") }, { - "page":"stock-ageing", - "label": wn._("Stock Ageing") + "label":wn._("Stock Ageing"), + doctype: "Item", + route: "query-report/Stock Ageing" }, ] }, diff --git a/stock/page/stock_ledger/README.md b/stock/page/stock_ledger/README.md deleted file mode 100644 index 774498b77e..0000000000 --- a/stock/page/stock_ledger/README.md +++ /dev/null @@ -1 +0,0 @@ -Stock movement report based on Stock Ledger Entry. \ No newline at end of file diff --git a/stock/page/stock_ledger/__init__.py b/stock/page/stock_ledger/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ledger/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js deleted file mode 100644 index 08a455e1d3..0000000000 --- a/stock/page/stock_ledger/stock_ledger.js +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -wn.pages['stock-ledger'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ledger'), - single_column: true - }); - - new erpnext.StockLedger(wrapper); - wrapper.appframe.add_module_icon("Stock") -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockLedger = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ledger"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"], - }) - }, - - setup_columns: function() { - this.hide_balance = (this.is_default("item_code") || this.voucher_no) ? true : false; - this.columns = [ - {id: "posting_datetime", name: wn._("Posting Date"), field: "posting_datetime", width: 120, - formatter: this.date_formatter}, - {id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160, - link_formatter: { - filter_input: "item_code", - open_btn: true, - doctype: '"Item"', - }}, - {id: "description", name: wn._("Description"), field: "description", width: 200, - formatter: this.text_formatter}, - {id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100, - link_formatter: {filter_input: "warehouse"}}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "stock_uom", name: wn._("UOM"), field: "stock_uom", width: 100}, - {id: "qty", name: wn._("Qty"), field: "qty", width: 100, - formatter: this.currency_formatter}, - {id: "balance", name: wn._("Balance Qty"), field: "balance", width: 100, - formatter: this.currency_formatter, - hidden: this.hide_balance}, - {id: "balance_value", name: wn._("Balance Value"), field: "balance_value", width: 100, - formatter: this.currency_formatter, hidden: this.hide_balance}, - {id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120}, - {id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160, - link_formatter: { - filter_input: "voucher_no", - open_btn: true, - doctype: "dataContext.voucher_type" - }}, - ]; - - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse...", filter: function(val, item, opts) { - return item.warehouse == val || val == opts.default_value; - }}, - {fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...", - filter: function(val, item, opts) { - return item.item_code == val || !val; - }}, - {fieldtype:"Select", label: "Brand", link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val || item._show; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Data", label: wn._("Voucher No"), - filter: function(val, item, opts) { - if(!val) return true; - return (item.voucher_no && item.voucher_no.indexOf(val)!=-1); - }}, - {fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Label", label: wn._("To")}, - {fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - - setup_filters: function() { - var me = this; - this._super(); - - this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); }); - this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); }); - - this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]); - }, - - toggle_enable_brand: function() { - if(!this.filter_inputs.item_code.val()) { - this.filter_inputs.brand.prop("disabled", false); - } else { - this.filter_inputs.brand - .val(this.filter_inputs.brand.get(0).opts.default_value) - .prop("disabled", true); - } - }, - - init_filter_values: function() { - this._super(); - this.filter_inputs.warehouse.get(0).selectedIndex = 0; - }, - prepare_data: function() { - var me = this; - if(!this.item_by_name) - this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]); - var data = wn.report_dump.data["Stock Ledger Entry"]; - var out = []; - - var opening = { - item_code: "On " + dateutil.str_to_user(this.from_date), qty: 0.0, balance: 0.0, - id:"_opening", _show: true, _style: "font-weight: bold", balance_value: 0.0 - } - var total_in = { - item_code: "Total In", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_in", _show: true, _style: "font-weight: bold" - } - var total_out = { - item_code: "Total Out", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_out", _show: true, _style: "font-weight: bold" - } - - // clear balance - $.each(wn.report_dump.data["Item"], function(i, item) { - item.balance = item.balance_value = 0.0; - }); - - // initialize warehouse-item map - this.item_warehouse = {}; - this.serialized_buying_rates = this.get_serialized_buying_rates(); - var from_datetime = dateutil.str_to_obj(me.from_date + " 00:00:00"); - var to_datetime = dateutil.str_to_obj(me.to_date + " 23:59:59"); - - // - for(var i=0, j=data.length; i 0) { - total_in.qty += sl.qty; - total_in.balance_value += value_diff; - } else { - total_out.qty += (-1 * sl.qty); - total_out.balance_value += value_diff; - } - } - } - - if(!before_end) break; - - // apply filters - if(me.apply_filters(sl)) { - out.push(sl); - } - - // update balance - if((!me.is_default("warehouse") ? me.apply_filter(sl, "warehouse") : true)) { - sl.balance = me.item_by_name[sl.item_code].balance + sl.qty; - me.item_by_name[sl.item_code].balance = sl.balance; - - sl.balance_value = me.item_by_name[sl.item_code].balance_value + value_diff; - me.item_by_name[sl.item_code].balance_value = sl.balance_value; - } - } - - if(me.item_code && !me.voucher_no) { - var closing = { - item_code: "On " + dateutil.str_to_user(this.to_date), - balance: (out.length ? out[out.length-1].balance : 0), qty: 0, - balance_value: (out.length ? out[out.length-1].balance_value : 0), - id:"_closing", _show: true, _style: "font-weight: bold" - }; - total_out.balance_value = -total_out.balance_value; - var out = [opening].concat(out).concat([total_in, total_out, closing]); - } - - this.data = out; - }, - get_plot_data: function() { - var data = []; - var me = this; - if(me.hide_balance) return false; - data.push({ - label: me.item_code, - data: [[dateutil.str_to_obj(me.from_date).getTime(), me.data[0].balance]] - .concat($.map(me.data, function(col, idx) { - if (col.posting_datetime) { - return [[dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance - col.qty], - [dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance]] - } - return null; - })).concat([ - // closing - [dateutil.str_to_obj(me.to_date).getTime(), me.data[me.data.length - 1].balance] - ]), - points: {show: true}, - lines: {show: true, fill: true}, - }); - return data; - }, - get_plot_options: function() { - return { - grid: { hoverable: true, clickable: true }, - xaxis: { mode: "time", - min: dateutil.str_to_obj(this.from_date).getTime(), - max: dateutil.str_to_obj(this.to_date).getTime(), - }, - series: { downsample: { threshold: 1000 } } - } - }, - get_tooltip_text: function(label, x, y) { - var d = new Date(x); - var date = dateutil.obj_to_user(d) + " " + d.getHours() + ":" + d.getMinutes(); - var value = format_number(y); - return value.bold() + " on " + date; - } -}); \ No newline at end of file diff --git a/stock/page/stock_ledger/stock_ledger.txt b/stock/page/stock_ledger/stock_ledger.txt deleted file mode 100644 index 9c2a4b75e5..0000000000 --- a/stock/page/stock_ledger/stock_ledger.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ledger", - "standard": "Yes", - "title": "Stock Ledger" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ledger", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ledger" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Material User" - } -] \ No newline at end of file From bc6df5c71b861c6f83d5381e0642c25e6f31fe99 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 16:42:23 +0530 Subject: [PATCH 03/80] [patch] [minor] deleted old stock ledger and stock ageing page --- patches/patch_list.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patches/patch_list.py b/patches/patch_list.py index 437f3227a7..1a9e75f39b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,4 +256,6 @@ patch_list = [ "patches.1311.p06_fix_report_columns", "execute:webnotes.delete_doc('DocType', 'Documentation Tool')", "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", + "execute:webnotes.delete_doc('Page', 'stock-ledger') #2013-12-04", + "execute:webnotes.delete_doc('Page', 'stock-ageing') #2013-12-04", ] \ No newline at end of file From 9b0a6d426c646af1bdc27ecf938b9d6d647e827f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 17:18:05 +0530 Subject: [PATCH 04/80] [patch] [minor] deleted old stock ledger and stock ageing page --- patches/1312/__init__.py | 0 patches/1312/p01_delete_old_stock_reports.py | 11 + patches/patch_list.py | 3 +- stock/page/stock_ageing/README.md | 1 - stock/page/stock_ageing/__init__.py | 1 - stock/page/stock_ageing/stock_ageing.js | 183 -------------- stock/page/stock_ageing/stock_ageing.txt | 37 --- stock/page/stock_ledger/README.md | 1 - stock/page/stock_ledger/__init__.py | 1 - stock/page/stock_ledger/stock_ledger.js | 247 ------------------- stock/page/stock_ledger/stock_ledger.txt | 41 --- 11 files changed, 12 insertions(+), 514 deletions(-) create mode 100644 patches/1312/__init__.py create mode 100644 patches/1312/p01_delete_old_stock_reports.py delete mode 100644 stock/page/stock_ageing/README.md delete mode 100644 stock/page/stock_ageing/__init__.py delete mode 100644 stock/page/stock_ageing/stock_ageing.js delete mode 100644 stock/page/stock_ageing/stock_ageing.txt delete mode 100644 stock/page/stock_ledger/README.md delete mode 100644 stock/page/stock_ledger/__init__.py delete mode 100644 stock/page/stock_ledger/stock_ledger.js delete mode 100644 stock/page/stock_ledger/stock_ledger.txt diff --git a/patches/1312/__init__.py b/patches/1312/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/1312/p01_delete_old_stock_reports.py b/patches/1312/p01_delete_old_stock_reports.py new file mode 100644 index 0000000000..ffa783fc1e --- /dev/null +++ b/patches/1312/p01_delete_old_stock_reports.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +def execute(): + import webnotes, os + + webnotes.delete_doc('Page', 'stock-ledger') + webnotes.delete_doc('Page', 'stock-ageing') + + os.system("rm -rf app/stock/page/stock_ledger") + os.system("rm -rf app/stock/page/stock_ageing") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 1a9e75f39b..0ebe5e2540 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -256,6 +256,5 @@ patch_list = [ "patches.1311.p06_fix_report_columns", "execute:webnotes.delete_doc('DocType', 'Documentation Tool')", "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", - "execute:webnotes.delete_doc('Page', 'stock-ledger') #2013-12-04", - "execute:webnotes.delete_doc('Page', 'stock-ageing') #2013-12-04", + "patches.1312.p01_delete_old_stock_reports", ] \ No newline at end of file diff --git a/stock/page/stock_ageing/README.md b/stock/page/stock_ageing/README.md deleted file mode 100644 index e8597b2194..0000000000 --- a/stock/page/stock_ageing/README.md +++ /dev/null @@ -1 +0,0 @@ -Average "age" of an Item in a particular Warehouse based on First-in-first-out (FIFO). \ No newline at end of file diff --git a/stock/page/stock_ageing/__init__.py b/stock/page/stock_ageing/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ageing/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ageing/stock_ageing.js b/stock/page/stock_ageing/stock_ageing.js deleted file mode 100644 index 6c626e22ed..0000000000 --- a/stock/page/stock_ageing/stock_ageing.js +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - - -wn.pages['stock-ageing'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ageing'), - single_column: true - }); - - new erpnext.StockAgeing(wrapper); - - - wrapper.appframe.add_module_icon("Stock") - -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockAgeing = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ageing"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Item Group", "Brand", "Serial No"], - }) - }, - setup_columns: function() { - this.columns = [ - {id: "name", name: wn._("Item"), field: "name", width: 300, - link_formatter: { - open_btn: true, - doctype: '"Item"' - }}, - {id: "item_name", name: wn._("Item Name"), field: "item_name", - width: 100, formatter: this.text_formatter}, - {id: "description", name: wn._("Description"), field: "description", - width: 200, formatter: this.text_formatter}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "average_age", name: wn._("Average Age"), field: "average_age", - formatter: this.currency_formatter}, - {id: "earliest", name: wn._("Earliest"), field: "earliest", - formatter: this.currency_formatter}, - {id: "latest", name: wn._("Latest"), field: "latest", - formatter: this.currency_formatter}, - {id: "stock_uom", name: "UOM", field: "stock_uom", width: 100}, - ]; - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse..."}, - {fieldtype:"Select", label: wn._("Brand"), link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Select", label: wn._("Plot By"), - options: ["Average Age", "Earliest", "Latest"]}, - {fieldtype:"Date", label: wn._("To Date")}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - setup_filters: function() { - var me = this; - this._super(); - this.trigger_refresh_on_change(["warehouse", "plot_by", "brand"]); - this.show_zero_check(); - }, - init_filter_values: function() { - this._super(); - this.filter_inputs.to_date.val(dateutil.obj_to_user(new Date())); - }, - prepare_data: function() { - var me = this; - - if(!this.data) { - me._data = wn.report_dump.data["Item"]; - me.item_by_name = me.make_name_map(me._data); - } - - this.data = [].concat(this._data); - - this.serialized_buying_rates = this.get_serialized_buying_rates(); - - $.each(this.data, function(i, d) { - me.reset_item_values(d); - }); - - this.prepare_balances(); - - // filter out brand - this.data = $.map(this.data, function(d) { - return me.apply_filter(d, "brand") ? d : null; - }); - - // filter out rows with zero values - this.data = $.map(this.data, function(d) { - return me.apply_zero_filter(null, d, null, me) ? d : null; - }); - }, - prepare_balances: function() { - var me = this; - var to_date = dateutil.str_to_obj(this.to_date); - var data = wn.report_dump.data["Stock Ledger Entry"]; - - this.item_warehouse = {}; - - for(var i=0, j=data.length; i to_date) - break; - } - } - - $.each(me.data, function(i, item) { - var full_fifo_stack = []; - if(me.is_default("warehouse")) { - $.each(me.item_warehouse[item.name] || {}, function(i, wh) { - full_fifo_stack = full_fifo_stack.concat(wh.fifo_stack || []) - }); - } else { - full_fifo_stack = me.get_item_warehouse(me.warehouse, item.name).fifo_stack || []; - } - - var age_qty = total_qty = 0.0; - var min_age = max_age = null; - - $.each(full_fifo_stack, function(i, batch) { - var batch_age = dateutil.get_diff(me.to_date, batch[2]); - age_qty += batch_age * batch[0]; - total_qty += batch[0]; - max_age = Math.max(max_age, batch_age); - if(min_age===null) min_age=batch_age; - else min_age = Math.min(min_age, batch_age); - }); - - item.average_age = total_qty.toFixed(2)==0.0 ? 0 - : (age_qty / total_qty).toFixed(2); - item.earliest = max_age || 0.0; - item.latest = min_age || 0.0; - }); - - this.data = this.data.sort(function(a, b) { - var sort_by = me.plot_by.replace(" ", "_").toLowerCase(); - return b[sort_by] - a[sort_by]; - }); - }, - get_plot_data: function() { - var data = []; - var me = this; - - data.push({ - label: me.plot_by, - data: $.map(me.data, function(item, idx) { - return [[idx+1, item[me.plot_by.replace(" ", "_").toLowerCase() ]]] - }), - bars: {show: true}, - }); - - return data.length ? data : false; - }, - get_plot_options: function() { - var me = this; - return { - grid: { hoverable: true, clickable: true }, - xaxis: { - ticks: $.map(me.data, function(item, idx) { return [[idx+1, item.name]] }), - max: 15 - }, - series: { downsample: { threshold: 1000 } } - } - } -}); \ No newline at end of file diff --git a/stock/page/stock_ageing/stock_ageing.txt b/stock/page/stock_ageing/stock_ageing.txt deleted file mode 100644 index cd1cfbd1c9..0000000000 --- a/stock/page/stock_ageing/stock_ageing.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:08", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ageing", - "standard": "Yes", - "title": "Stock Ageing" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ageing", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ageing" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - } -] \ No newline at end of file diff --git a/stock/page/stock_ledger/README.md b/stock/page/stock_ledger/README.md deleted file mode 100644 index 774498b77e..0000000000 --- a/stock/page/stock_ledger/README.md +++ /dev/null @@ -1 +0,0 @@ -Stock movement report based on Stock Ledger Entry. \ No newline at end of file diff --git a/stock/page/stock_ledger/__init__.py b/stock/page/stock_ledger/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/stock/page/stock_ledger/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/stock/page/stock_ledger/stock_ledger.js b/stock/page/stock_ledger/stock_ledger.js deleted file mode 100644 index 08a455e1d3..0000000000 --- a/stock/page/stock_ledger/stock_ledger.js +++ /dev/null @@ -1,247 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -wn.pages['stock-ledger'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Ledger'), - single_column: true - }); - - new erpnext.StockLedger(wrapper); - wrapper.appframe.add_module_icon("Stock") -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockLedger = erpnext.StockGridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("Stock Ledger"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", "Serial No"], - }) - }, - - setup_columns: function() { - this.hide_balance = (this.is_default("item_code") || this.voucher_no) ? true : false; - this.columns = [ - {id: "posting_datetime", name: wn._("Posting Date"), field: "posting_datetime", width: 120, - formatter: this.date_formatter}, - {id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160, - link_formatter: { - filter_input: "item_code", - open_btn: true, - doctype: '"Item"', - }}, - {id: "description", name: wn._("Description"), field: "description", width: 200, - formatter: this.text_formatter}, - {id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100, - link_formatter: {filter_input: "warehouse"}}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100}, - {id: "stock_uom", name: wn._("UOM"), field: "stock_uom", width: 100}, - {id: "qty", name: wn._("Qty"), field: "qty", width: 100, - formatter: this.currency_formatter}, - {id: "balance", name: wn._("Balance Qty"), field: "balance", width: 100, - formatter: this.currency_formatter, - hidden: this.hide_balance}, - {id: "balance_value", name: wn._("Balance Value"), field: "balance_value", width: 100, - formatter: this.currency_formatter, hidden: this.hide_balance}, - {id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120}, - {id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160, - link_formatter: { - filter_input: "voucher_no", - open_btn: true, - doctype: "dataContext.voucher_type" - }}, - ]; - - }, - filters: [ - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse...", filter: function(val, item, opts) { - return item.warehouse == val || val == opts.default_value; - }}, - {fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...", - filter: function(val, item, opts) { - return item.item_code == val || !val; - }}, - {fieldtype:"Select", label: "Brand", link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val || item._show; - }, link_formatter: {filter_input: "brand"}}, - {fieldtype:"Data", label: wn._("Voucher No"), - filter: function(val, item, opts) { - if(!val) return true; - return (item.voucher_no && item.voucher_no.indexOf(val)!=-1); - }}, - {fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Label", label: wn._("To")}, - {fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - - setup_filters: function() { - var me = this; - this._super(); - - this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); }); - this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); }); - - this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]); - }, - - toggle_enable_brand: function() { - if(!this.filter_inputs.item_code.val()) { - this.filter_inputs.brand.prop("disabled", false); - } else { - this.filter_inputs.brand - .val(this.filter_inputs.brand.get(0).opts.default_value) - .prop("disabled", true); - } - }, - - init_filter_values: function() { - this._super(); - this.filter_inputs.warehouse.get(0).selectedIndex = 0; - }, - prepare_data: function() { - var me = this; - if(!this.item_by_name) - this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]); - var data = wn.report_dump.data["Stock Ledger Entry"]; - var out = []; - - var opening = { - item_code: "On " + dateutil.str_to_user(this.from_date), qty: 0.0, balance: 0.0, - id:"_opening", _show: true, _style: "font-weight: bold", balance_value: 0.0 - } - var total_in = { - item_code: "Total In", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_in", _show: true, _style: "font-weight: bold" - } - var total_out = { - item_code: "Total Out", qty: 0.0, balance: 0.0, balance_value: 0.0, - id:"_total_out", _show: true, _style: "font-weight: bold" - } - - // clear balance - $.each(wn.report_dump.data["Item"], function(i, item) { - item.balance = item.balance_value = 0.0; - }); - - // initialize warehouse-item map - this.item_warehouse = {}; - this.serialized_buying_rates = this.get_serialized_buying_rates(); - var from_datetime = dateutil.str_to_obj(me.from_date + " 00:00:00"); - var to_datetime = dateutil.str_to_obj(me.to_date + " 23:59:59"); - - // - for(var i=0, j=data.length; i 0) { - total_in.qty += sl.qty; - total_in.balance_value += value_diff; - } else { - total_out.qty += (-1 * sl.qty); - total_out.balance_value += value_diff; - } - } - } - - if(!before_end) break; - - // apply filters - if(me.apply_filters(sl)) { - out.push(sl); - } - - // update balance - if((!me.is_default("warehouse") ? me.apply_filter(sl, "warehouse") : true)) { - sl.balance = me.item_by_name[sl.item_code].balance + sl.qty; - me.item_by_name[sl.item_code].balance = sl.balance; - - sl.balance_value = me.item_by_name[sl.item_code].balance_value + value_diff; - me.item_by_name[sl.item_code].balance_value = sl.balance_value; - } - } - - if(me.item_code && !me.voucher_no) { - var closing = { - item_code: "On " + dateutil.str_to_user(this.to_date), - balance: (out.length ? out[out.length-1].balance : 0), qty: 0, - balance_value: (out.length ? out[out.length-1].balance_value : 0), - id:"_closing", _show: true, _style: "font-weight: bold" - }; - total_out.balance_value = -total_out.balance_value; - var out = [opening].concat(out).concat([total_in, total_out, closing]); - } - - this.data = out; - }, - get_plot_data: function() { - var data = []; - var me = this; - if(me.hide_balance) return false; - data.push({ - label: me.item_code, - data: [[dateutil.str_to_obj(me.from_date).getTime(), me.data[0].balance]] - .concat($.map(me.data, function(col, idx) { - if (col.posting_datetime) { - return [[dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance - col.qty], - [dateutil.str_to_obj(col.posting_datetime).getTime(), col.balance]] - } - return null; - })).concat([ - // closing - [dateutil.str_to_obj(me.to_date).getTime(), me.data[me.data.length - 1].balance] - ]), - points: {show: true}, - lines: {show: true, fill: true}, - }); - return data; - }, - get_plot_options: function() { - return { - grid: { hoverable: true, clickable: true }, - xaxis: { mode: "time", - min: dateutil.str_to_obj(this.from_date).getTime(), - max: dateutil.str_to_obj(this.to_date).getTime(), - }, - series: { downsample: { threshold: 1000 } } - } - }, - get_tooltip_text: function(label, x, y) { - var d = new Date(x); - var date = dateutil.obj_to_user(d) + " " + d.getHours() + ":" + d.getMinutes(); - var value = format_number(y); - return value.bold() + " on " + date; - } -}); \ No newline at end of file diff --git a/stock/page/stock_ledger/stock_ledger.txt b/stock/page/stock_ledger/stock_ledger.txt deleted file mode 100644 index 9c2a4b75e5..0000000000 --- a/stock/page/stock_ledger/stock_ledger.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-21 20:15:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:19", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-ledger", - "standard": "Yes", - "title": "Stock Ledger" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-ledger", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-ledger" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Material User" - } -] \ No newline at end of file From 690c75fa0daf3b839f519b063499fe2ca3ce239f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 19:16:32 +0530 Subject: [PATCH 05/80] [report] migrated stock level report to script report and renamed to Stock Projected Qty --- patches/1312/p01_delete_old_stock_reports.py | 4 +- stock/page/stock_home/stock_home.js | 7 +-- stock/report/stock_projected_qty/__init__.py | 0 .../stock_projected_qty.js | 33 ++++++++++++ .../stock_projected_qty.py | 54 +++++++++++++++++++ .../stock_projected_qty.txt | 22 ++++++++ 6 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 stock/report/stock_projected_qty/__init__.py create mode 100644 stock/report/stock_projected_qty/stock_projected_qty.js create mode 100644 stock/report/stock_projected_qty/stock_projected_qty.py create mode 100644 stock/report/stock_projected_qty/stock_projected_qty.txt diff --git a/patches/1312/p01_delete_old_stock_reports.py b/patches/1312/p01_delete_old_stock_reports.py index ffa783fc1e..17c8947478 100644 --- a/patches/1312/p01_delete_old_stock_reports.py +++ b/patches/1312/p01_delete_old_stock_reports.py @@ -6,6 +6,8 @@ def execute(): webnotes.delete_doc('Page', 'stock-ledger') webnotes.delete_doc('Page', 'stock-ageing') + webnotes.delete_doc('Page', 'stock-level') os.system("rm -rf app/stock/page/stock_ledger") - os.system("rm -rf app/stock/page/stock_ageing") \ No newline at end of file + os.system("rm -rf app/stock/page/stock_ageing") + os.system("rm -rf app/stock/page/stock_level") \ No newline at end of file diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index ec432425b5..3b6fd4cf40 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -138,7 +138,7 @@ wn.module_page["Stock"] = [ items: [ { "label":wn._("Stock Ledger"), - doctype: "Delivery Note", + doctype: "Item", route: "query-report/Stock Ledger" }, { @@ -146,8 +146,9 @@ wn.module_page["Stock"] = [ page: "stock-balance" }, { - "page":"stock-level", - "label": wn._("Stock Level") + "label":wn._("Stock Projected Qty"), + doctype: "Item", + route: "query-report/Stock Projected Qty" }, { "label":wn._("Stock Ageing"), diff --git a/stock/report/stock_projected_qty/__init__.py b/stock/report/stock_projected_qty/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/report/stock_projected_qty/stock_projected_qty.js b/stock/report/stock_projected_qty/stock_projected_qty.js new file mode 100644 index 0000000000..a0ad755ed0 --- /dev/null +++ b/stock/report/stock_projected_qty/stock_projected_qty.js @@ -0,0 +1,33 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +wn.query_reports["Stock Projected Qty"] = { + "filters": [ + { + "fieldname":"company", + "label": wn._("Company"), + "fieldtype": "Link", + "options": "Company", + "default": wn.defaults.get_user_default("company"), + "reqd": 1 + }, + { + "fieldname":"warehouse", + "label": wn._("Warehouse"), + "fieldtype": "Link", + "options": "Warehouse" + }, + { + "fieldname":"item_code", + "label": wn._("Item"), + "fieldtype": "Link", + "options": "Item" + }, + { + "fieldname":"brand", + "label": wn._("Brand"), + "fieldtype": "Link", + "options": "Brand" + } + ] +} \ No newline at end of file diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py new file mode 100644 index 0000000000..126cc2c34e --- /dev/null +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -0,0 +1,54 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes import _ + +def execute(filters=None): + columns = get_columns() + if not filters.get("company"): + webnotes.throw(_("Company is mandatory")) + + data = webnotes.conn.sql("""select + item.name, item.item_name, description, brand, warehouse, item.stock_uom, + actual_qty, planned_qty, indented_qty, ordered_qty, reserved_qty, + projected_qty, item.re_order_level, item.re_order_qty + from `tabBin` bin, + (select name, company from tabWarehouse {warehouse_conditions}) wh, + (select name, item_name, description, stock_uom, brand, re_order_level, re_order_qty + from `tabItem` {item_conditions}) item + where item_code = item.name and warehouse = wh.name + order by item.name, wh.name"""\ + .format(item_conditions=get_item_conditions(filters), + warehouse_conditions=get_warehouse_conditions(filters)), filters, debug=1) + + return columns, data + +def get_columns(): + return ["Item Code:Link/Item:140", "Item Name::100", "Description::200", + "Brand:Link/Brand:100", "Warehouse:Link/Warehouse:120", "UOM:Link/UOM:100", + "Actual Qty:Float:100", "Planned Qty:Float:100", "Requested Qty:Float:110", + "Ordered Qty:Float:100", "Reserved Qty:Float:100", "Projected Qty:Float:100", + "Reorder Level:Float:100", "Reorder Qty:Float:100"] + +def get_item_conditions(filters): + conditions = [] + if filters.get("item_code"): + conditions.append("name=%(item_code)s") + if filters.get("brand"): + conditions.append("brand=%(brand)s") + + return "where {}".format(" and ".join(conditions)) if conditions else "" + +def get_warehouse_conditions(filters): + conditions = [] + if not filters.get("company"): + webnotes.throw(_("Company is mandatory")) + else: + conditions.append("company=%(company)s") + + if filters.get("warehouse"): + conditions.append("name=%(warehouse)s") + + return "where {}".format(" and ".join(conditions)) if conditions else "" \ No newline at end of file diff --git a/stock/report/stock_projected_qty/stock_projected_qty.txt b/stock/report/stock_projected_qty/stock_projected_qty.txt new file mode 100644 index 0000000000..1998f7ae74 --- /dev/null +++ b/stock/report/stock_projected_qty/stock_projected_qty.txt @@ -0,0 +1,22 @@ +[ + { + "creation": "2013-12-04 18:21:56", + "docstatus": 0, + "modified": "2013-12-04 18:21:56", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "add_total_row": 1, + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "Item", + "report_name": "Stock Projected Qty", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "Stock Projected Qty" + } +] \ No newline at end of file From 01d2811ccd5b5815179ec757ef1aaf446b8d0084 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 4 Dec 2013 19:16:50 +0530 Subject: [PATCH 06/80] [report] migrated stock level report to script report and renamed to Stock Projected Qty --- stock/page/stock_level/README.md | 1 - stock/page/stock_level/__init__.py | 0 stock/page/stock_level/stock_level.js | 228 ------------------------- stock/page/stock_level/stock_level.txt | 37 ---- 4 files changed, 266 deletions(-) delete mode 100644 stock/page/stock_level/README.md delete mode 100644 stock/page/stock_level/__init__.py delete mode 100644 stock/page/stock_level/stock_level.js delete mode 100644 stock/page/stock_level/stock_level.txt diff --git a/stock/page/stock_level/README.md b/stock/page/stock_level/README.md deleted file mode 100644 index 43b2b0fbde..0000000000 --- a/stock/page/stock_level/README.md +++ /dev/null @@ -1 +0,0 @@ -Stock levels (actual, planned, reserved, ordered) for Items on a particular date. \ No newline at end of file diff --git a/stock/page/stock_level/__init__.py b/stock/page/stock_level/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/stock/page/stock_level/stock_level.js b/stock/page/stock_level/stock_level.js deleted file mode 100644 index c50879160e..0000000000 --- a/stock/page/stock_level/stock_level.js +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -wn.pages['stock-level'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('Stock Level'), - single_column: true - }); - - new erpnext.StockLevel(wrapper); - - - wrapper.appframe.add_module_icon("Stock") - ; -} - -wn.require("app/js/stock_grid_report.js"); - -erpnext.StockLevel = erpnext.StockGridReport.extend({ - init: function(wrapper) { - var me = this; - - this._super({ - title: wn._("Stock Level"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Item", "Warehouse", "Stock Ledger Entry", "Production Order", - "Material Request Item", "Purchase Order Item", "Sales Order Item", "Brand", "Serial No"], - }); - - this.wrapper.bind("make", function() { - wn.utils.set_footnote(me, me.wrapper.get(0), - "
    \ -
  • \ - Projected Qty = Actual Qty + Planned Qty + Requested Qty \ - + Ordered Qty - Reserved Qty
  • \ -
      \ -
    • "+wn._("Actual Qty: Quantity available in the warehouse.") +"
    • "+ - "
    • "+wn._("Planned Qty: Quantity, for which, Production Order has been raised,")+ - wn._("but is pending to be manufactured.")+ "
    • " + - "
    • "+wn._("Requested Qty: Quantity requested for purchase, but not ordered.") + "
    • " + - "
    • " + wn._("Ordered Qty: Quantity ordered for purchase, but not received.")+ "
    • " + - "
    • " + wn._("Reserved Qty: Quantity ordered for sale, but not delivered.") + "
    • " + - "
    \ -
"); - }); - }, - - setup_columns: function() { - this.columns = [ - {id: "item_code", name: wn._("Item Code"), field: "item_code", width: 160, - link_formatter: { - filter_input: "item_code", - open_btn: true, - doctype: '"Item"', - }}, - {id: "item_name", name: wn._("Item Name"), field: "item_name", width: 100, - formatter: this.text_formatter}, - {id: "description", name: wn._("Description"), field: "description", width: 200, - formatter: this.text_formatter}, - {id: "brand", name: wn._("Brand"), field: "brand", width: 100, - link_formatter: {filter_input: "brand"}}, - {id: "warehouse", name: wn._("Warehouse"), field: "warehouse", width: 100, - link_formatter: {filter_input: "warehouse"}}, - {id: "uom", name: wn._("UOM"), field: "uom", width: 60}, - {id: "actual_qty", name: wn._("Actual Qty"), - field: "actual_qty", width: 80, formatter: this.currency_formatter}, - {id: "planned_qty", name: wn._("Planned Qty"), - field: "planned_qty", width: 80, formatter: this.currency_formatter}, - {id: "requested_qty", name: wn._("Requested Qty"), - field: "requested_qty", width: 80, formatter: this.currency_formatter}, - {id: "ordered_qty", name: wn._("Ordered Qty"), - field: "ordered_qty", width: 80, formatter: this.currency_formatter}, - {id: "reserved_qty", name: wn._("Reserved Qty"), - field: "reserved_qty", width: 80, formatter: this.currency_formatter}, - {id: "projected_qty", name: wn._("Projected Qty"), - field: "projected_qty", width: 80, formatter: this.currency_formatter}, - {id: "re_order_level", name: wn._("Re-Order Level"), - field: "re_order_level", width: 80, formatter: this.currency_formatter}, - {id: "re_order_qty", name: wn._("Re-Order Qty"), - field: "re_order_qty", width: 80, formatter: this.currency_formatter}, - ]; - }, - - filters: [ - {fieldtype:"Link", label: wn._("Item Code"), link:"Item", default_value: "Select Item...", - filter: function(val, item, opts) { - return item.item_code == val || !val; - }}, - - {fieldtype:"Select", label: wn._("Warehouse"), link:"Warehouse", - default_value: "Select Warehouse...", filter: function(val, item, opts) { - return item.warehouse == val || val == opts.default_value; - }}, - - {fieldtype:"Select", label: wn._("Brand"), link:"Brand", - default_value: "Select Brand...", filter: function(val, item, opts) { - return val == opts.default_value || item.brand == val; - }}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - - setup_filters: function() { - var me = this; - this._super(); - - this.wrapper.bind("apply_filters_from_route", function() { me.toggle_enable_brand(); }); - this.filter_inputs.item_code.change(function() { me.toggle_enable_brand(); }); - - this.trigger_refresh_on_change(["item_code", "warehouse", "brand"]); - }, - - toggle_enable_brand: function() { - if(!this.filter_inputs.item_code.val()) { - this.filter_inputs.brand.prop("disabled", false); - } else { - this.filter_inputs.brand - .val(this.filter_inputs.brand.get(0).opts.default_value) - .prop("disabled", true); - } - }, - - init_filter_values: function() { - this._super(); - this.filter_inputs.warehouse.get(0).selectedIndex = 0; - }, - - prepare_data: function() { - var me = this; - - if(!this._data) { - this._data = []; - this.item_warehouse_map = {}; - this.item_by_name = this.make_name_map(wn.report_dump.data["Item"]); - this.calculate_quantities(); - } - - this.data = [].concat(this._data); - this.data = $.map(this.data, function(d) { - return me.apply_filters(d) ? d : null; - }); - - this.calculate_total(); - }, - - calculate_quantities: function() { - var me = this; - $.each([ - ["Stock Ledger Entry", "actual_qty"], - ["Production Order", "planned_qty"], - ["Material Request Item", "requested_qty"], - ["Purchase Order Item", "ordered_qty"], - ["Sales Order Item", "reserved_qty"]], - function(i, v) { - $.each(wn.report_dump.data[v[0]], function(i, item) { - var row = me.get_row(item.item_code, item.warehouse); - row[v[1]] += flt(item.qty); - }); - } - ); - - // sort by item, warehouse - this._data = $.map(Object.keys(this.item_warehouse_map).sort(), function(key) { - return me.item_warehouse_map[key]; - }); - - // calculate projected qty - $.each(this._data, function(i, row) { - row.projected_qty = row.actual_qty + row.planned_qty + row.requested_qty - + row.ordered_qty - row.reserved_qty; - }); - - // filter out rows with zero values - this._data = $.map(this._data, function(d) { - return me.apply_zero_filter(null, d, null, me) ? d : null; - }); - }, - - get_row: function(item_code, warehouse) { - var key = item_code + ":" + warehouse; - if(!this.item_warehouse_map[key]) { - var item = this.item_by_name[item_code]; - var row = { - item_code: item_code, - warehouse: warehouse, - description: item.description, - brand: item.brand, - item_name: item.item_name || item.name, - uom: item.stock_uom, - id: key, - } - this.reset_item_values(row); - - row["re_order_level"] = item.re_order_level - row["re_order_qty"] = item.re_order_qty - - this.item_warehouse_map[key] = row; - } - return this.item_warehouse_map[key]; - }, - - calculate_total: function() { - var me = this; - // show total if a specific item is selected and warehouse is not filtered - if(this.is_default("warehouse") && !this.is_default("item_code")) { - var total = { - id: "_total", - item_code: "Total", - _style: "font-weight: bold", - _show: true - }; - this.reset_item_values(total); - - $.each(this.data, function(i, row) { - $.each(me.columns, function(i, col) { - if (col.formatter==me.currency_formatter) { - total[col.id] += row[col.id]; - } - }); - }); - - this.data = this.data.concat([total]); - } - } -}) diff --git a/stock/page/stock_level/stock_level.txt b/stock/page/stock_level/stock_level.txt deleted file mode 100644 index bae3d9c9b2..0000000000 --- a/stock/page/stock_level/stock_level.txt +++ /dev/null @@ -1,37 +0,0 @@ -[ - { - "creation": "2012-12-31 10:52:14", - "docstatus": 0, - "modified": "2013-07-11 14:44:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Stock", - "name": "__common__", - "page_name": "stock-level", - "standard": "Yes", - "title": "Stock Level" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "stock-level", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "stock-level" - }, - { - "doctype": "Page Role", - "role": "Material Manager" - }, - { - "doctype": "Page Role", - "role": "Analytics" - } -] \ No newline at end of file From afc44cf54ed48518575bc948b4c89ae33cf396ee Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 5 Dec 2013 17:42:53 +0530 Subject: [PATCH 07/80] [fix] [minor] email settings - set send print in body and attachment --- patches/december_2013/__init__.py | 0 ...l_settings_set_send_print_in_body_and_attachment.py | 10 ++++++++++ patches/patch_list.py | 1 + 3 files changed, 11 insertions(+) create mode 100644 patches/december_2013/__init__.py create mode 100644 patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py diff --git a/patches/december_2013/__init__.py b/patches/december_2013/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py b/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py new file mode 100644 index 0000000000..7b7e7fb4f1 --- /dev/null +++ b/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.conn.sql("""update `tabSingles` set value = 1 + where doctype = 'Email Settings' and field = 'send_print_in_body_and_attachment' and + ifnull(value,'')=''""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 9400e08872..8a7d10e450 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -258,4 +258,5 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", "execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')", "execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')", + "patches.december_2013.p01_email_settings_set_send_print_in_body_and_attachment", ] \ No newline at end of file From 86da17d5d9ae71272116c67876ce831d6b46f159 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Dec 2013 13:23:31 +0530 Subject: [PATCH 08/80] [minor] removed mandatory validation in server side --- stock/report/stock_ageing/stock_ageing.py | 6 ------ .../stock_projected_qty/stock_projected_qty.py | 17 +++-------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/stock/report/stock_ageing/stock_ageing.py b/stock/report/stock_ageing/stock_ageing.py index f688ed96ef..fa052050ca 100644 --- a/stock/report/stock_ageing/stock_ageing.py +++ b/stock/report/stock_ageing/stock_ageing.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import date_diff -from webnotes import _ def execute(filters=None): @@ -64,11 +63,6 @@ def get_fifo_queue(filters): return item_details def get_stock_ledger_entries(filters): - if not filters.get("company"): - webnotes.throw(_("Company is mandatory")) - if not filters.get("to_date"): - webnotes.throw(_("To Date is mandatory")) - return webnotes.conn.sql("""select item.name, item.item_name, brand, description, item.stock_uom, actual_qty, posting_date from `tabStock Ledger Entry` sle, diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py index 126cc2c34e..232c744c87 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.py +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -3,19 +3,17 @@ from __future__ import unicode_literals import webnotes -from webnotes import _ def execute(filters=None): columns = get_columns() - if not filters.get("company"): - webnotes.throw(_("Company is mandatory")) data = webnotes.conn.sql("""select item.name, item.item_name, description, brand, warehouse, item.stock_uom, actual_qty, planned_qty, indented_qty, ordered_qty, reserved_qty, projected_qty, item.re_order_level, item.re_order_qty from `tabBin` bin, - (select name, company from tabWarehouse {warehouse_conditions}) wh, + (select name, company from tabWarehouse + where company=%(company)s {warehouse_conditions}) wh, (select name, item_name, description, stock_uom, brand, re_order_level, re_order_qty from `tabItem` {item_conditions}) item where item_code = item.name and warehouse = wh.name @@ -42,13 +40,4 @@ def get_item_conditions(filters): return "where {}".format(" and ".join(conditions)) if conditions else "" def get_warehouse_conditions(filters): - conditions = [] - if not filters.get("company"): - webnotes.throw(_("Company is mandatory")) - else: - conditions.append("company=%(company)s") - - if filters.get("warehouse"): - conditions.append("name=%(warehouse)s") - - return "where {}".format(" and ".join(conditions)) if conditions else "" \ No newline at end of file + return " and name=%(warehouse)s" if filters.get("warehouse") else "" \ No newline at end of file From c313ca99ffc6b3a9342e09f432b536c8e39730c3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Dec 2013 16:36:23 +0530 Subject: [PATCH 09/80] [report]general ledger report migrated to script report --- accounts/report/general_ledger/__init__.py | 0 .../report/general_ledger/general_ledger.js | 51 +++++++++++++++++++ .../report/general_ledger/general_ledger.py | 49 ++++++++++++++++++ .../report/general_ledger/general_ledger.txt | 21 ++++++++ 4 files changed, 121 insertions(+) create mode 100644 accounts/report/general_ledger/__init__.py create mode 100644 accounts/report/general_ledger/general_ledger.js create mode 100644 accounts/report/general_ledger/general_ledger.py create mode 100644 accounts/report/general_ledger/general_ledger.txt diff --git a/accounts/report/general_ledger/__init__.py b/accounts/report/general_ledger/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/report/general_ledger/general_ledger.js b/accounts/report/general_ledger/general_ledger.js new file mode 100644 index 0000000000..b0cd485527 --- /dev/null +++ b/accounts/report/general_ledger/general_ledger.js @@ -0,0 +1,51 @@ +// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +// License: GNU General Public License v3. See license.txt + +wn.query_reports["General Ledger"] = { + "filters": [ + { + "fieldname":"company", + "label": wn._("Company"), + "fieldtype": "Link", + "options": "Company", + "default": wn.defaults.get_user_default("company"), + "reqd": 1 + }, + { + "fieldname":"account", + "label": wn._("Account"), + "fieldtype": "Link", + "options": "Account" + }, + { + "fieldname":"voucher_no", + "label": wn._("Voucher No"), + "fieldtype": "Data", + }, + { + "fieldtype": "Break", + }, + { + "fieldname":"from_date", + "label": wn._("From Date"), + "fieldtype": "Date", + "default": wn.datetime.add_months(wn.datetime.get_today(), -1), + "reqd": 1, + "width": "60px" + }, + { + "fieldname":"to_date", + "label": wn._("To Date"), + "fieldtype": "Date", + "default": wn.datetime.get_today(), + "reqd": 1, + "width": "60px" + }, + { + "fieldname":"group_by", + "label": wn._("Group by"), + "fieldtype": "Select", + "options": "\nAccount\nVoucher" + } + ] +} \ No newline at end of file diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py new file mode 100644 index 0000000000..e99ea2016b --- /dev/null +++ b/accounts/report/general_ledger/general_ledger.py @@ -0,0 +1,49 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes +from webnotes.utils import flt + +def execute(filters=None): + columns = get_columns() + if filters.get("group_by"): + data = get_grouped_gle(filters) + else: + data = get_gl_entries(filters) + + return columns, data + +def get_columns(): + return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Currency:100", + "Credit:Currency:100", "Voucher Type::120", "Voucher No::160", "Remarks::200"] + +def get_gl_entries(filters): + return webnotes.conn.sql("""select + posting_date, account, debit, credit, voucher_type, voucher_no, cost_center, remarks + from `tabGL Entry` + where company=%(company)s + and posting_date between %(from_date)s and %(to_date)s + {conditions} + order by posting_date, account"""\ + .format(conditions=get_conditions(filters)), filters) + +def get_conditions(filters): + return " and account=%(account)s" if filters.get("account") else "" + +def get_grouped_gle(filters): + gle_map = {} + gle = get_gl_entries(filters) + for d in gle: + gle_map.setdefault(d[1 if filters["group_by"]=="Account" else 5], []).append(d) + + data = [] + for entries in gle_map.values(): + total_debit = total_credit = 0.0 + for entry in entries: + data.append(entry) + total_debit += flt(entry[2]) + total_credit += flt(entry[3]) + + data.append(["", "Total", total_debit, total_credit, "", "", ""]) + return data \ No newline at end of file diff --git a/accounts/report/general_ledger/general_ledger.txt b/accounts/report/general_ledger/general_ledger.txt new file mode 100644 index 0000000000..ef169dbe88 --- /dev/null +++ b/accounts/report/general_ledger/general_ledger.txt @@ -0,0 +1,21 @@ +[ + { + "creation": "2013-12-06 13:22:23", + "docstatus": 0, + "modified": "2013-12-06 13:22:23", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "doctype": "Report", + "is_standard": "Yes", + "name": "__common__", + "ref_doctype": "GL Entry", + "report_name": "General Ledger", + "report_type": "Script Report" + }, + { + "doctype": "Report", + "name": "General Ledger" + } +] \ No newline at end of file From 4a8930fc67efcaa13853b9e4d81afa9b72bb3918 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 6 Dec 2013 18:07:23 +0530 Subject: [PATCH 10/80] [report]general ledger report migrated to script report --- accounts/report/general_ledger/general_ledger.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index e99ea2016b..23c79d8996 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -16,7 +16,8 @@ def execute(filters=None): def get_columns(): return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Currency:100", - "Credit:Currency:100", "Voucher Type::120", "Voucher No::160", "Remarks::200"] + "Credit:Currency:100", "Voucher Type::120", "Voucher No::160", + "Cost Center:Link/Cost Center:100", "Remarks::200"] def get_gl_entries(filters): return webnotes.conn.sql("""select From d9255abd46f167e6fe34b105ee3a5d786def0265 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Fri, 6 Dec 2013 18:49:48 +0530 Subject: [PATCH 11/80] [fix] [minor] set send_print_in_body_and_attachment in email settings --- hr/doctype/earning_type/earning_type.txt | 4 ++-- manufacturing/doctype/bom/bom.txt | 10 ++++++---- ...l_settings_set_send_print_in_body_and_attachment.py | 7 +++++++ setup/doctype/email_settings/email_settings.txt | 3 ++- stock/doctype/delivery_note/delivery_note.txt | 4 ++-- stock/doctype/stock_entry/stock_entry.js | 4 ++-- stock/doctype/stock_entry/stock_entry.txt | 10 +++++----- 7 files changed, 26 insertions(+), 16 deletions(-) diff --git a/hr/doctype/earning_type/earning_type.txt b/hr/doctype/earning_type/earning_type.txt index 0c84cf1d4e..905bbd89b9 100644 --- a/hr/doctype/earning_type/earning_type.txt +++ b/hr/doctype/earning_type/earning_type.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-24 11:03:32", "docstatus": 0, - "modified": "2013-07-22 15:25:26", + "modified": "2013-12-06 15:16:11", "modified_by": "Administrator", "owner": "Administrator" }, @@ -85,7 +85,7 @@ "doctype": "DocField", "fieldname": "exemption_limit", "fieldtype": "Float", - "hidden": 1, + "hidden": 0, "label": "Exemption Limit", "oldfieldname": "exemption_limit", "oldfieldtype": "Currency" diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt index 68553fb9e3..1878f25e1f 100644 --- a/manufacturing/doctype/bom/bom.txt +++ b/manufacturing/doctype/bom/bom.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-22 15:11:38", "docstatus": 0, - "modified": "2013-12-04 11:51:36", + "modified": "2013-12-06 18:48:23", "modified_by": "Administrator", "owner": "Administrator" }, @@ -120,18 +120,20 @@ "options": "Price List" }, { - "depends_on": "with_operations", + "description": "Specify the operations, operating cost and give a unique Operation no to your operations.", "doctype": "DocField", "fieldname": "operations", "fieldtype": "Section Break", + "hidden": 0, "label": "Operations", - "oldfieldtype": "Section Break", - "options": "Specify the operations, operating cost and give a unique Operation no to your operations." + "oldfieldtype": "Section Break" }, { + "depends_on": "with_operations", "doctype": "DocField", "fieldname": "bom_operations", "fieldtype": "Table", + "hidden": 0, "label": "BOM Operations", "oldfieldname": "bom_operations", "oldfieldtype": "Table", diff --git a/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py b/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py index 7b7e7fb4f1..1a11f57871 100644 --- a/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py +++ b/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py @@ -5,6 +5,13 @@ from __future__ import unicode_literals import webnotes def execute(): + doctype = webnotes.conn.sql("""select doctype from `tabSingles` + where doctype = 'Email Settings'""") + if not doctype: + email_settings = webnotes.bean("Email Settings", "Email Settings") + email_settings.doc.send_print_in_body_and_attachment = 1 + email_settings.save() + webnotes.conn.sql("""update `tabSingles` set value = 1 where doctype = 'Email Settings' and field = 'send_print_in_body_and_attachment' and ifnull(value,'')=''""") \ No newline at end of file diff --git a/setup/doctype/email_settings/email_settings.txt b/setup/doctype/email_settings/email_settings.txt index 3689718ff5..6b28f10f35 100644 --- a/setup/doctype/email_settings/email_settings.txt +++ b/setup/doctype/email_settings/email_settings.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-25 17:53:21", "docstatus": 0, - "modified": "2013-11-28 11:54:42", + "modified": "2013-12-06 13:12:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -103,6 +103,7 @@ "label": "Auto Email Id" }, { + "default": "1", "description": "If checked, an email with an attached HTML format will be added to part of the EMail body as well as attachment. To only send as attachment, uncheck this.", "doctype": "DocField", "fieldname": "send_print_in_body_and_attachment", diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index 7fb166e686..b94310e8ac 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-11-03 14:20:19", + "modified": "2013-12-06 15:15:49", "modified_by": "Administrator", "owner": "Administrator" }, @@ -229,7 +229,7 @@ "doctype": "DocField", "fieldname": "po_date", "fieldtype": "Date", - "hidden": 1, + "hidden": 0, "label": "Customer's Purchase Order Date", "no_copy": 0, "oldfieldname": "po_date", diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index ed41d7d879..440a9a3a1e 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -244,7 +244,7 @@ cur_frm.script_manager.make(erpnext.stock.StockEntry); cur_frm.cscript.toggle_related_fields = function(doc) { disable_from_warehouse = inList(["Material Receipt", "Sales Return"], doc.purpose); - disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose) + disable_to_warehouse = inList(["Material Issue", "Purchase Return"], doc.purpose); cur_frm.toggle_enable("from_warehouse", !disable_from_warehouse); cur_frm.toggle_enable("to_warehouse", !disable_to_warehouse); @@ -302,7 +302,7 @@ cur_frm.fields_dict['production_order'].get_query = function(doc) { } cur_frm.cscript.purpose = function(doc, cdt, cdn) { - cur_frm.cscript.toggle_related_fields(doc, cdt, cdn); + cur_frm.cscript.toggle_related_fields(doc); } // Overloaded query for link batch_no diff --git a/stock/doctype/stock_entry/stock_entry.txt b/stock/doctype/stock_entry/stock_entry.txt index ca9b5f29a2..a63f8a4492 100644 --- a/stock/doctype/stock_entry/stock_entry.txt +++ b/stock/doctype/stock_entry/stock_entry.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-09 11:43:55", "docstatus": 0, - "modified": "2013-11-03 14:11:42", + "modified": "2013-12-06 15:15:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -108,7 +108,7 @@ "doctype": "DocField", "fieldname": "delivery_note_no", "fieldtype": "Link", - "hidden": 1, + "hidden": 0, "in_filter": 0, "label": "Delivery Note No", "no_copy": 1, @@ -126,7 +126,7 @@ "doctype": "DocField", "fieldname": "sales_invoice_no", "fieldtype": "Link", - "hidden": 1, + "hidden": 0, "label": "Sales Invoice No", "no_copy": 1, "options": "Sales Invoice", @@ -139,7 +139,7 @@ "doctype": "DocField", "fieldname": "purchase_receipt_no", "fieldtype": "Link", - "hidden": 1, + "hidden": 0, "in_filter": 0, "label": "Purchase Receipt No", "no_copy": 1, @@ -299,7 +299,7 @@ "doctype": "DocField", "fieldname": "production_order", "fieldtype": "Link", - "hidden": 1, + "hidden": 0, "in_filter": 1, "label": "Production Order", "no_copy": 0, From a652347bd12923839cba570ab27ee2a035801920 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 9 Dec 2013 15:52:47 +0530 Subject: [PATCH 12/80] [fix] [minor] customer_name not visible in sales invoice --- accounts/doctype/sales_invoice/sales_invoice.txt | 2 +- selling/sales_common.js | 2 +- stock/doctype/stock_entry/stock_entry.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index 99bfe5cdf0..ece17a4ef7 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-11-18 15:16:50", + "modified": "2013-12-09 14:05:34", "modified_by": "Administrator", "owner": "Administrator" }, diff --git a/selling/sales_common.js b/selling/sales_common.js index ee55dfab7a..d6c8fdd0e4 100644 --- a/selling/sales_common.js +++ b/selling/sales_common.js @@ -95,7 +95,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ refresh: function() { this._super(); this.frm.toggle_display("customer_name", - (this.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); + (this.frm.doc.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); if(this.frm.fields_dict.packing_details) { var packing_list_exists = this.frm.get_doclist({parentfield: "packing_details"}).length; this.frm.toggle_display("packing_list", packing_list_exists ? true : false); diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 440a9a3a1e..73fd441f76 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -106,7 +106,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ }, callback: function(r) { if (!r.exc) { - for(d in getchildren('Stock Entry Detail',doc.name,'mtn_details')) { + for(d in getchildren('Stock Entry Detail', me.frm.doc.name, 'mtn_details')) { if(!d.expense_account) d.expense_account = r.message; } } From 7b1d9409f16312566ef1089aa4af54aba29a4e01 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 9 Dec 2013 15:57:26 +0530 Subject: [PATCH 13/80] [fix] [minor] remove email patch --- patches/december_2013/__init__.py | 0 ...ngs_set_send_print_in_body_and_attachment.py | 17 ----------------- patches/patch_list.py | 1 - 3 files changed, 18 deletions(-) delete mode 100644 patches/december_2013/__init__.py delete mode 100644 patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py diff --git a/patches/december_2013/__init__.py b/patches/december_2013/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py b/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py deleted file mode 100644 index 1a11f57871..0000000000 --- a/patches/december_2013/p01_email_settings_set_send_print_in_body_and_attachment.py +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -# License: GNU General Public License v3. See license.txt - -from __future__ import unicode_literals -import webnotes - -def execute(): - doctype = webnotes.conn.sql("""select doctype from `tabSingles` - where doctype = 'Email Settings'""") - if not doctype: - email_settings = webnotes.bean("Email Settings", "Email Settings") - email_settings.doc.send_print_in_body_and_attachment = 1 - email_settings.save() - - webnotes.conn.sql("""update `tabSingles` set value = 1 - where doctype = 'Email Settings' and field = 'send_print_in_body_and_attachment' and - ifnull(value,'')=''""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 8a7d10e450..9400e08872 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -258,5 +258,4 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", "execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')", "execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')", - "patches.december_2013.p01_email_settings_set_send_print_in_body_and_attachment", ] \ No newline at end of file From 5d3da6c095daf4094fe92eddcc450f10f3a8a0d0 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 10 Dec 2013 11:18:08 +0530 Subject: [PATCH 14/80] [fix] [minor] rename fix for customer and supplier --- buying/doctype/supplier/supplier.py | 10 ++++++++++ manufacturing/doctype/bom/bom.txt | 4 +++- selling/doctype/customer/customer.py | 12 +++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index b2873c5661..48bb9c276c 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -151,6 +151,16 @@ class DocType(TransactionBase): def before_rename(self, olddn, newdn, merge=False): from accounts.utils import rename_account_for rename_account_for("Supplier", olddn, newdn, merge) + self.rename_address(olddn, newdn) + self.rename_contact(olddn, newdn) + + def rename_address(self, olddn, newdn): + webnotes.conn.sql("""update `tabAddress` set supplier_name=%s, + address_title=%s where supplier=%s""", (newdn, newdn, olddn)) + + def rename_contact(self,olddn, newdn): + webnotes.conn.sql("""update `tabContact` set supplier_name=%s + where supplier=%s""", (newdn, olddn)) def after_rename(self, olddn, newdn, merge=False): if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt index a5ff125293..023473a620 100644 --- a/manufacturing/doctype/bom/bom.txt +++ b/manufacturing/doctype/bom/bom.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-22 15:11:38", "docstatus": 0, - "modified": "2013-12-09 16:25:50", + "modified": "2013-12-09 16:56:41", "modified_by": "Administrator", "owner": "Administrator" }, @@ -102,6 +102,7 @@ "doctype": "DocField", "fieldname": "with_operations", "fieldtype": "Check", + "hidden": 0, "label": "With Operations" }, { @@ -125,6 +126,7 @@ "doctype": "DocField", "fieldname": "operations", "fieldtype": "Section Break", + "hidden": 0, "label": "Operations", "oldfieldtype": "Section Break" }, diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index d00926f43c..356628a6b9 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -146,7 +146,17 @@ class DocType(TransactionBase): def before_rename(self, olddn, newdn, merge=False): from accounts.utils import rename_account_for rename_account_for("Customer", olddn, newdn, merge) - + self.rename_address(olddn, newdn) + self.rename_contact(olddn, newdn) + + def rename_address(self, olddn, newdn): + webnotes.conn.sql("""update `tabAddress` set customer_name=%s, + address_title=%s where customer=%s""", (newdn, newdn, olddn)) + + def rename_contact(self,olddn, newdn): + webnotes.conn.sql("""update `tabContact` set customer_name=%s + where customer=%s""", (newdn, olddn)) + def after_rename(self, olddn, newdn, merge=False): if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': webnotes.conn.set(self.doc, "customer_name", newdn) From abefa3fd40440a92a65ca4cf0cc99f0dc5792849 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 10 Dec 2013 14:22:52 +0530 Subject: [PATCH 15/80] [fix] [minor] supplier & customer rename fix --- buying/doctype/supplier/supplier.py | 30 ++++++++++++++++++---------- selling/doctype/customer/customer.py | 30 ++++++++++++++++++---------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 48bb9c276c..503ec8a1dd 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -27,6 +27,14 @@ class DocType(TransactionBase): else: self.doc.name = make_autoname(self.doc.naming_series + '.#####') + def update_address(self): + webnotes.conn.sql("""update `tabAddress` set supplier_name=%s + where supplier=%s""", (self.doc.supplier_name, self.doc.name)) + + def update_contact(self): + webnotes.conn.sql("""update `tabContact` set supplier_name=%s + where supplier=%s""", (self.doc.supplier_name, self.doc.name)) + def update_credit_days_limit(self): webnotes.conn.sql("""update tabAccount set credit_days = %s where name = %s""", (cint(self.doc.credit_days), self.doc.name + " - " + self.get_company_abbr())) @@ -35,6 +43,9 @@ class DocType(TransactionBase): if not self.doc.naming_series: self.doc.naming_series = '' + self.update_address() + self.update_contact() + # create account head self.create_account_head() @@ -151,20 +162,19 @@ class DocType(TransactionBase): def before_rename(self, olddn, newdn, merge=False): from accounts.utils import rename_account_for rename_account_for("Supplier", olddn, newdn, merge) - self.rename_address(olddn, newdn) - self.rename_contact(olddn, newdn) - def rename_address(self, olddn, newdn): - webnotes.conn.sql("""update `tabAddress` set supplier_name=%s, - address_title=%s where supplier=%s""", (newdn, newdn, olddn)) - - def rename_contact(self,olddn, newdn): - webnotes.conn.sql("""update `tabContact` set supplier_name=%s - where supplier=%s""", (newdn, olddn)) - def after_rename(self, olddn, newdn, merge=False): + condition = value = '' if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': webnotes.conn.set(self.doc, "supplier_name", newdn) + self.update_contact() + condition = ", supplier_name=%s" + value = newdn + self.update_supplier_address(newdn, condition, value) + + def update_supplier_address(self, newdn, condition, value): + webnotes.conn.sql("""update `tabAddress` set address_title=%s %s + where supplier=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) @webnotes.whitelist() def get_dashboard_info(supplier): diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 356628a6b9..71116b33b1 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -47,6 +47,14 @@ class DocType(TransactionBase): if self.doc.lead_name: webnotes.conn.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) + def update_address(self): + webnotes.conn.sql("""update `tabAddress` set customer_name=%s where customer=%s""", + (self.doc.customer_name, self.doc.name)) + + def update_contact(self): + webnotes.conn.sql("""update `tabContact` set customer_name=%s where customer=%s""", + (self.doc.customer_name, self.doc.name)) + def create_account_head(self): if self.doc.company : abbr = self.get_company_abbr() @@ -99,6 +107,9 @@ class DocType(TransactionBase): self.validate_name_with_customer_group() self.update_lead_status() + self.update_address() + self.update_contact() + # create account head self.create_account_head() # update credit days and limit in account @@ -146,20 +157,19 @@ class DocType(TransactionBase): def before_rename(self, olddn, newdn, merge=False): from accounts.utils import rename_account_for rename_account_for("Customer", olddn, newdn, merge) - self.rename_address(olddn, newdn) - self.rename_contact(olddn, newdn) - - def rename_address(self, olddn, newdn): - webnotes.conn.sql("""update `tabAddress` set customer_name=%s, - address_title=%s where customer=%s""", (newdn, newdn, olddn)) - - def rename_contact(self,olddn, newdn): - webnotes.conn.sql("""update `tabContact` set customer_name=%s - where customer=%s""", (newdn, olddn)) def after_rename(self, olddn, newdn, merge=False): + condition = value = '' if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': webnotes.conn.set(self.doc, "customer_name", newdn) + self.update_contact() + condition = ", customer_name=%s" + value = newdn + self.update_customer_address(newdn, condition, value) + + def update_customer_address(self, newdn, condition, value): + webnotes.conn.sql("""update `tabAddress` set address_title=%s %s + where customer=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) @webnotes.whitelist() def get_dashboard_info(customer): From 4e677a3f5235c96e86c5fe5acd8d2f59dff895dc Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 10 Dec 2013 15:23:07 +0530 Subject: [PATCH 16/80] [fix] [minor] stashed bom.txt --- manufacturing/doctype/bom/bom.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt index 023473a620..a5ff125293 100644 --- a/manufacturing/doctype/bom/bom.txt +++ b/manufacturing/doctype/bom/bom.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-22 15:11:38", "docstatus": 0, - "modified": "2013-12-09 16:56:41", + "modified": "2013-12-09 16:25:50", "modified_by": "Administrator", "owner": "Administrator" }, @@ -102,7 +102,6 @@ "doctype": "DocField", "fieldname": "with_operations", "fieldtype": "Check", - "hidden": 0, "label": "With Operations" }, { @@ -126,7 +125,6 @@ "doctype": "DocField", "fieldname": "operations", "fieldtype": "Section Break", - "hidden": 0, "label": "Operations", "oldfieldtype": "Section Break" }, From f0dad52aaa51f495812ed341881da905fdad0df9 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 10 Dec 2013 18:11:31 +0530 Subject: [PATCH 17/80] [fix] [minor] merge conflict fix --- manufacturing/doctype/bom/bom.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/manufacturing/doctype/bom/bom.txt b/manufacturing/doctype/bom/bom.txt index 57076654df..a5ff125293 100644 --- a/manufacturing/doctype/bom/bom.txt +++ b/manufacturing/doctype/bom/bom.txt @@ -120,24 +120,18 @@ "options": "Price List" }, { -<<<<<<< HEAD -======= "depends_on": "with_operations", ->>>>>>> 4e677a3f5235c96e86c5fe5acd8d2f59dff895dc "description": "Specify the operations, operating cost and give a unique Operation no to your operations.", "doctype": "DocField", "fieldname": "operations", "fieldtype": "Section Break", - "hidden": 0, "label": "Operations", "oldfieldtype": "Section Break" }, { - "depends_on": "with_operations", "doctype": "DocField", "fieldname": "bom_operations", "fieldtype": "Table", - "hidden": 0, "label": "BOM Operations", "oldfieldname": "bom_operations", "oldfieldtype": "Table", From 42a8fc2ee31229e6b77e04dda3ae8806e669c2fe Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 11 Dec 2013 11:15:03 +0530 Subject: [PATCH 18/80] [fix] [minor] stashed sales_invoice.txt --- accounts/doctype/sales_invoice/sales_invoice.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.txt b/accounts/doctype/sales_invoice/sales_invoice.txt index ece17a4ef7..99bfe5cdf0 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-12-09 14:05:34", + "modified": "2013-11-18 15:16:50", "modified_by": "Administrator", "owner": "Administrator" }, From 229b246d6df2ab743dd8dcb5975740cf2d2b6ad2 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 11 Dec 2013 18:49:11 +0530 Subject: [PATCH 19/80] [fix] [minor] production planning tool clear sales order table --- .../accounts_receivable.py | 2 +- .../production_planning_tool.py | 22 ++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/accounts/report/accounts_receivable/accounts_receivable.py b/accounts/report/accounts_receivable/accounts_receivable.py index ad0d92523b..945bae434a 100644 --- a/accounts/report/accounts_receivable/accounts_receivable.py +++ b/accounts/report/accounts_receivable/accounts_receivable.py @@ -85,7 +85,7 @@ class AccountsReceivableReport(object): def get_account_map(self): if not hasattr(self, "account_map"): self.account_map = dict(((r.name, r) for r in webnotes.conn.sql("""select - account.name, customer.customer_name, customer.territory + account.name, customer.name as customer_name, customer.territory from `tabAccount` account, `tabCustomer` customer where account.master_type="Customer" and customer.name=account.master_name""", as_dict=True))) diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py index f3626a3da3..ce93d80c6b 100644 --- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -72,9 +72,9 @@ class DocType: and (exists (select name from `tabItem` item where item.name=so_item.item_code and (ifnull(item.is_pro_applicable, 'No') = 'Yes' or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s) - or exists (select name from `tabPacked Item` dnpi - where dnpi.parent = so.name and dnpi.parent_item = so_item.item_code - and exists (select name from `tabItem` item where item.name=dnpi.item_code + or exists (select name from `tabPacked Item` pi + where pi.parent = so.name and pi.parent_item = so_item.item_code + and exists (select name from `tabItem` item where item.name=pi.item_code and (ifnull(item.is_pro_applicable, 'No') = 'Yes' or ifnull(item.is_sub_contracted_item, 'No') = 'Yes') %s))) """ % ('%s', so_filter, item_filter, item_filter), self.doc.company, as_dict=1) @@ -83,6 +83,8 @@ class DocType: def add_so_in_table(self, open_so): """ Add sales orders in the table""" + self.clear_so_table() + so_list = [d.sales_order for d in getlist(self.doclist, 'pp_so_details')] for r in open_so: if cstr(r['name']) not in so_list: @@ -116,19 +118,19 @@ class DocType: or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \ (", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1) - dnpi_items = webnotes.conn.sql("""select distinct dnpi.parent, dnpi.item_code, dnpi.warehouse as reserved_warhouse, - (((so_item.qty - ifnull(so_item.delivered_qty, 0)) * dnpi.qty) / so_item.qty) + packed_items = webnotes.conn.sql("""select distinct pi.parent, pi.item_code, pi.warehouse as reserved_warhouse, + (((so_item.qty - ifnull(so_item.delivered_qty, 0)) * pi.qty) / so_item.qty) as pending_qty - from `tabSales Order Item` so_item, `tabPacked Item` dnpi - where so_item.parent = dnpi.parent and so_item.docstatus = 1 - and dnpi.parent_item = so_item.item_code + from `tabSales Order Item` so_item, `tabPacked Item` pi + where so_item.parent = pi.parent and so_item.docstatus = 1 + and pi.parent_item = so_item.item_code and so_item.parent in (%s) and ifnull(so_item.qty, 0) > ifnull(so_item.delivered_qty, 0) - and exists (select * from `tabItem` item where item.name=dnpi.item_code + and exists (select * from `tabItem` item where item.name=pi.item_code and (ifnull(item.is_pro_applicable, 'No') = 'Yes' or ifnull(item.is_sub_contracted_item, 'No') = 'Yes'))""" % \ (", ".join(["%s"] * len(so_list))), tuple(so_list), as_dict=1) - return items + dnpi_items + return items + packed_items def add_items(self, items): From 9d835a039a593ac1aa48ab8207794e188e673050 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Dec 2013 11:00:40 +0530 Subject: [PATCH 20/80] [fix] [minor] convert serial no to upper case for comparing --- stock/doctype/serial_no/serial_no.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stock/doctype/serial_no/serial_no.py b/stock/doctype/serial_no/serial_no.py index dc067ec6d1..bd2704d8ac 100644 --- a/stock/doctype/serial_no/serial_no.py +++ b/stock/doctype/serial_no/serial_no.py @@ -150,7 +150,7 @@ class DocType(StockController): where serial_no like %s and item_code=%s and ifnull(is_cancelled, 'No')='No' order by posting_date desc, posting_time desc, name desc""", ("%%%s%%" % self.doc.name, self.doc.item_code), as_dict=1): - if self.doc.name in get_serial_nos(sle.serial_no): + if self.doc.name.upper() in get_serial_nos(sle.serial_no): if sle.actual_qty > 0: sle_dict.setdefault("incoming", []).append(sle) else: @@ -268,7 +268,8 @@ def get_item_details(item_code): from tabItem where name=%s""", item_code, as_dict=True)[0] def get_serial_nos(serial_no): - return [s.strip() for s in cstr(serial_no).strip().replace(',', '\n').split('\n') if s.strip()] + return [s.strip() for s in cstr(serial_no).strip().upper().replace(',', '\n').split('\n') + if s.strip()] def make_serial_no(serial_no, sle): sr = webnotes.new_bean("Serial No") From 7d4c2d62bf11f5f740a1e1df151d6afde3e74b32 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 12 Dec 2013 12:32:43 +0530 Subject: [PATCH 21/80] [fix] [minor] allowed renaming for address and contact --- buying/doctype/supplier/supplier.py | 18 +++++++++--------- selling/doctype/customer/customer.py | 22 +++++++++++----------- utilities/doctype/address/address.txt | 3 ++- utilities/doctype/contact/contact.txt | 3 ++- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 503ec8a1dd..2435d0cc31 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -28,11 +28,11 @@ class DocType(TransactionBase): self.doc.name = make_autoname(self.doc.naming_series + '.#####') def update_address(self): - webnotes.conn.sql("""update `tabAddress` set supplier_name=%s + webnotes.conn.sql("""update `tabAddress` set supplier_name=%s, modified=NOW() where supplier=%s""", (self.doc.supplier_name, self.doc.name)) def update_contact(self): - webnotes.conn.sql("""update `tabContact` set supplier_name=%s + webnotes.conn.sql("""update `tabContact` set supplier_name=%s, modified=NOW() where supplier=%s""", (self.doc.supplier_name, self.doc.name)) def update_credit_days_limit(self): @@ -164,17 +164,17 @@ class DocType(TransactionBase): rename_account_for("Supplier", olddn, newdn, merge) def after_rename(self, olddn, newdn, merge=False): - condition = value = '' + set_field = '' if webnotes.defaults.get_global_default('supp_master_name') == 'Supplier Name': webnotes.conn.set(self.doc, "supplier_name", newdn) self.update_contact() - condition = ", supplier_name=%s" - value = newdn - self.update_supplier_address(newdn, condition, value) + set_field = ", supplier_name=%(newdn)s" + self.update_supplier_address(newdn, set_field) - def update_supplier_address(self, newdn, condition, value): - webnotes.conn.sql("""update `tabAddress` set address_title=%s %s - where supplier=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) + def update_supplier_address(self, newdn, set_field): + webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s + {set_field} where supplier=%(newdn)s"""\ + .format(set_field=set_field), ({"newdn": newdn})) @webnotes.whitelist() def get_dashboard_info(supplier): diff --git a/selling/doctype/customer/customer.py b/selling/doctype/customer/customer.py index 71116b33b1..49296b0b1c 100644 --- a/selling/doctype/customer/customer.py +++ b/selling/doctype/customer/customer.py @@ -48,12 +48,12 @@ class DocType(TransactionBase): webnotes.conn.sql("update `tabLead` set status='Converted' where name = %s", self.doc.lead_name) def update_address(self): - webnotes.conn.sql("""update `tabAddress` set customer_name=%s where customer=%s""", - (self.doc.customer_name, self.doc.name)) + webnotes.conn.sql("""update `tabAddress` set customer_name=%s, modified=NOW() + where customer=%s""", (self.doc.customer_name, self.doc.name)) def update_contact(self): - webnotes.conn.sql("""update `tabContact` set customer_name=%s where customer=%s""", - (self.doc.customer_name, self.doc.name)) + webnotes.conn.sql("""update `tabContact` set customer_name=%s, modified=NOW() + where customer=%s""", (self.doc.customer_name, self.doc.name)) def create_account_head(self): if self.doc.company : @@ -159,17 +159,17 @@ class DocType(TransactionBase): rename_account_for("Customer", olddn, newdn, merge) def after_rename(self, olddn, newdn, merge=False): - condition = value = '' + set_field = '' if webnotes.defaults.get_global_default('cust_master_name') == 'Customer Name': webnotes.conn.set(self.doc, "customer_name", newdn) self.update_contact() - condition = ", customer_name=%s" - value = newdn - self.update_customer_address(newdn, condition, value) + set_field = ", customer_name=%(newdn)s" + self.update_customer_address(newdn, set_field) - def update_customer_address(self, newdn, condition, value): - webnotes.conn.sql("""update `tabAddress` set address_title=%s %s - where customer=%s""" % ('%s', condition, '%s'), (newdn, value, newdn)) + def update_customer_address(self, newdn, set_field): + webnotes.conn.sql("""update `tabAddress` set address_title=%(newdn)s + {set_field} where customer=%(newdn)s"""\ + .format(set_field=set_field), ({"newdn": newdn})) @webnotes.whitelist() def get_dashboard_info(customer): diff --git a/utilities/doctype/address/address.txt b/utilities/doctype/address/address.txt index 09be67eb10..5b4ada995e 100644 --- a/utilities/doctype/address/address.txt +++ b/utilities/doctype/address/address.txt @@ -2,11 +2,12 @@ { "creation": "2013-01-10 16:34:32", "docstatus": 0, - "modified": "2013-07-11 17:02:12", + "modified": "2013-12-12 12:17:46", "modified_by": "Administrator", "owner": "Administrator" }, { + "allow_rename": 1, "doctype": "DocType", "document_type": "Master", "icon": "icon-map-marker", diff --git a/utilities/doctype/contact/contact.txt b/utilities/doctype/contact/contact.txt index 199aaea82e..1c8a5cf94a 100644 --- a/utilities/doctype/contact/contact.txt +++ b/utilities/doctype/contact/contact.txt @@ -2,11 +2,12 @@ { "creation": "2013-01-10 16:34:32", "docstatus": 0, - "modified": "2013-10-08 16:48:50", + "modified": "2013-12-12 12:18:19", "modified_by": "Administrator", "owner": "Administrator" }, { + "allow_rename": 1, "doctype": "DocType", "document_type": "Master", "icon": "icon-user", From 13fc64d7329a1b15236fc9383c7f31ea68e8cc31 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Dec 2013 12:50:42 +0530 Subject: [PATCH 22/80] [fix] [minor] Negative outstanding validation for JV against JV --- accounts/doctype/gl_entry/gl_entry.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py index 3a0b28c78f..d3c6317787 100644 --- a/accounts/doctype/gl_entry/gl_entry.py +++ b/accounts/doctype/gl_entry/gl_entry.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt, fmt_money, getdate -from webnotes.model.code import get_obj -from webnotes import msgprint, _ +from webnotes import _ class DocType: def __init__(self,d,dl): @@ -130,11 +129,12 @@ def update_outstanding_amt(account, against_voucher_type, against_voucher, on_ca against_voucher_amount = flt(webnotes.conn.sql(""" select sum(ifnull(debit, 0)) - sum(ifnull(credit, 0)) from `tabGL Entry` where voucher_type = 'Journal Voucher' and voucher_no = %s - and account = %s""", (against_voucher, account))[0][0]) + and account = %s and ifnull(against_voucher, '') = ''""", + (against_voucher, account))[0][0]) bal = against_voucher_amount + bal if against_voucher_amount < 0: bal = -bal - + # Validation : Outstanding can not be negative if bal < 0 and not on_cancel: webnotes.throw(_("Outstanding for Voucher ") + against_voucher + _(" will become ") + @@ -158,4 +158,4 @@ def validate_frozen_account(account, adv_adj): elif frozen_accounts_modifier not in webnotes.user.get_roles(): webnotes.throw(account + _(" is a frozen account. ") + _("To create / edit transactions against this account, you need role") + ": " + - frozen_accounts_modifier) + frozen_accounts_modifier) \ No newline at end of file From 6ad8973538788c869cf0896b1daba13463c02b3e Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 12 Dec 2013 13:39:21 +0600 Subject: [PATCH 23/80] bumped to version 3.2.0 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index bc72fa9bc9..779f0638b7 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.1.2", + "app_version": "3.2.0", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.1.1" + "requires_framework_version": "==3.2.0" } \ No newline at end of file From c3f2fb7355ec457edca6f1972063e367d66f2c6f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Dec 2013 14:55:25 +0530 Subject: [PATCH 24/80] [fix] [minor] payment to invoice patching tool --- .../payment_to_invoice_matching_tool.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py index 6a31191969..dea5fb59c9 100644 --- a/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py +++ b/accounts/doctype/payment_to_invoice_matching_tool/payment_to_invoice_matching_tool.py @@ -145,6 +145,8 @@ def gl_entry_details(doctype, txt, searchfield, start, page_len, filters): and voucher_no != gle.voucher_no) != abs(ifnull(gle.debit, 0) - ifnull(gle.credit, 0) ) + and if(gle.voucher_type='Sales Invoice', (select is_pos from `tabSales Invoice` + where name=gle.voucher_no), 0)=0 %(mcond)s ORDER BY gle.posting_date desc, gle.voucher_no desc limit %(start)s, %(page_len)s""" % { From c10c0c506671f0bf4352dacf1e8ab7354b36270f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Dec 2013 17:13:22 +0530 Subject: [PATCH 25/80] [fix] [minor] series skipping issue in salary manager --- hr/doctype/salary_manager/salary_manager.py | 1 - hr/doctype/salary_slip/salary_slip.py | 13 ++++++------- hr/doctype/salary_structure/salary_structure.py | 5 ++++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hr/doctype/salary_manager/salary_manager.py b/hr/doctype/salary_manager/salary_manager.py index 29b13aed98..37a8c5d5e9 100644 --- a/hr/doctype/salary_manager/salary_manager.py +++ b/hr/doctype/salary_manager/salary_manager.py @@ -12,7 +12,6 @@ class DocType: self.doc = doc self.doclist = doclist - def get_emp_list(self): """ Returns list of active employees based on selected criteria diff --git a/hr/doctype/salary_slip/salary_slip.py b/hr/doctype/salary_slip/salary_slip.py index f5eeea164d..94660d0fd8 100644 --- a/hr/doctype/salary_slip/salary_slip.py +++ b/hr/doctype/salary_slip/salary_slip.py @@ -29,18 +29,17 @@ class DocType(TransactionBase): if struct: self.pull_sal_struct(struct) - def check_sal_struct(self): - struct = webnotes.conn.sql("select name from `tabSalary Structure` where employee ='%s' and is_active = 'Yes' "%self.doc.employee) + struct = webnotes.conn.sql("""select name from `tabSalary Structure` + where employee=%s and is_active = 'Yes'""", self.doc.employee) if not struct: - msgprint("Please create Salary Structure for employee '%s'"%self.doc.employee) - self.doc.employee = '' + msgprint("Please create Salary Structure for employee '%s'" % self.doc.employee) + self.doc.employee = None return struct and struct[0][0] or '' - def pull_sal_struct(self, struct): - from hr.doctype.salary_structure.salary_structure import make_salary_slip - self.doclist = make_salary_slip(struct, self.doclist) + from hr.doctype.salary_structure.salary_structure import get_mapped_doclist + self.doclist = get_mapped_doclist(struct, self.doclist) def pull_emp_details(self): emp = webnotes.conn.get_value("Employee", self.doc.employee, diff --git a/hr/doctype/salary_structure/salary_structure.py b/hr/doctype/salary_structure/salary_structure.py index 2dc056dd16..a034b90284 100644 --- a/hr/doctype/salary_structure/salary_structure.py +++ b/hr/doctype/salary_structure/salary_structure.py @@ -74,6 +74,9 @@ class DocType: @webnotes.whitelist() def make_salary_slip(source_name, target_doclist=None): + return [d.fields for d in get_mapped_doclist(source_name, target_doclist)] + +def get_mapped_doclist(source_name, target_doclist=None): from webnotes.model.mapper import get_mapped_doclist def postprocess(source, target): @@ -109,4 +112,4 @@ def make_salary_slip(source_name, target_doclist=None): } }, target_doclist, postprocess) - return [d.fields for d in doclist] \ No newline at end of file + return doclist \ No newline at end of file From f6e06311becce981a1ce54f10d460a0dee053251 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Dec 2013 17:45:29 +0530 Subject: [PATCH 26/80] [cleanup] [minor] carry forwarded leaves field read only and depends on carry forward checkbox --- hr/doctype/leave_allocation/leave_allocation.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hr/doctype/leave_allocation/leave_allocation.txt b/hr/doctype/leave_allocation/leave_allocation.txt index a24823a454..38e3eb57c9 100644 --- a/hr/doctype/leave_allocation/leave_allocation.txt +++ b/hr/doctype/leave_allocation/leave_allocation.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-20 19:10:38", "docstatus": 0, - "modified": "2013-07-05 14:44:19", + "modified": "2013-12-12 17:41:52", "modified_by": "Administrator", "owner": "Administrator" }, @@ -131,10 +131,12 @@ "label": "Carry Forward" }, { + "depends_on": "carry_forward", "doctype": "DocField", "fieldname": "carry_forwarded_leaves", "fieldtype": "Float", - "label": "Carry Forwarded Leaves" + "label": "Carry Forwarded Leaves", + "read_only": 1 }, { "allow_on_submit": 1, From f943dc5dc1d446b6c47beda4e85289464c801699 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 12 Dec 2013 19:45:30 +0600 Subject: [PATCH 27/80] bumped to version 3.2.1 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 779f0638b7..77a00b846f 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.2.0", + "app_version": "3.2.1", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 1251a93fc5aabb477677be119bce899f35868e30 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 13 Dec 2013 11:40:16 +0530 Subject: [PATCH 28/80] [fix] [minor] fixes in packed item --- selling/doctype/sales_order/sales_order.py | 9 ++++----- stock/doctype/delivery_note/delivery_note.py | 7 +++---- stock/doctype/packed_item/packed_item.py | 15 +++------------ 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 771aafa6c3..a66c4460a0 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -110,12 +110,12 @@ class DocType(SellingController): self.validate_uom_is_integer("stock_uom", "qty") self.validate_for_items() self.validate_warehouse() - + from stock.doctype.packed_item.packed_item import make_packing_list self.doclist = make_packing_list(self,'sales_order_details') - + self.validate_with_previous_doc() - + if not self.doc.status: self.doc.status = "Draft" @@ -124,8 +124,7 @@ class DocType(SellingController): "Cancelled"]) if not self.doc.billing_status: self.doc.billing_status = 'Not Billed' - if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered' - + if not self.doc.delivery_status: self.doc.delivery_status = 'Not Delivered' def validate_warehouse(self): from stock.utils import validate_warehouse_user, validate_warehouse_company diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 1089a5697c..b2149b1be8 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -73,6 +73,9 @@ class DocType(SellingController): self.update_current_stock() self.validate_with_previous_doc() + from stock.doctype.packed_item.packed_item import make_packing_list + self.doclist = make_packing_list(self, 'delivery_note_details') + self.doc.status = 'Draft' if not self.doc.installation_status: self.doc.installation_status = 'Not Installed' @@ -142,10 +145,6 @@ class DocType(SellingController): bin = webnotes.conn.sql("select actual_qty, projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) d.actual_qty = bin and flt(bin[0]['actual_qty']) or 0 d.projected_qty = bin and flt(bin[0]['projected_qty']) or 0 - - def on_update(self): - from stock.doctype.packed_item.packed_item import make_packing_list - self.doclist = make_packing_list(self, 'delivery_note_details') def on_submit(self): self.validate_packed_qty() diff --git a/stock/doctype/packed_item/packed_item.py b/stock/doctype/packed_item/packed_item.py index a58444d554..ba3cb30ff3 100644 --- a/stock/doctype/packed_item/packed_item.py +++ b/stock/doctype/packed_item/packed_item.py @@ -56,9 +56,6 @@ def update_packing_list_item(obj, packing_item_code, qty, warehouse, line, packi pi.batch_no = cstr(line.batch_no) pi.idx = packing_list_idx - # saved, since this function is called on_update of delivery note - pi.save() - packing_list_idx += 1 @@ -87,19 +84,13 @@ def cleanup_packing_list(obj, parent_items): for d in obj.doclist.get({"parentfield": "packing_details"}): if [d.parent_item, d.parent_detail_docname] not in parent_items: # mark for deletion from doclist - delete_list.append(d.name) + delete_list.append([d.parent_item, d.parent_detail_docname]) if not delete_list: return obj.doclist # delete from doclist - obj.doclist = webnotes.doclist(filter(lambda d: d.name not in delete_list, obj.doclist)) - - # delete from db - webnotes.conn.sql("""\ - delete from `tabPacked Item` - where name in (%s)""" - % (", ".join(["%s"] * len(delete_list))), - tuple(delete_list)) + obj.doclist = webnotes.doclist(filter(lambda d: [d.parent_item, d.parent_detail_docname] + not in delete_list, obj.doclist)) return obj.doclist \ No newline at end of file From 64c512dd61033f8454e19e64cff6a42e84e0eea0 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 13 Dec 2013 12:34:52 +0530 Subject: [PATCH 29/80] [minor] [fix] allow roles --- setup/page/setup/setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup/page/setup/setup.py b/setup/page/setup/setup.py index 4418f857e4..11025c9607 100644 --- a/setup/page/setup/setup.py +++ b/setup/page/setup/setup.py @@ -233,8 +233,9 @@ items = [ "route": "Report/Scheduler Log", "type": "Link", "icon": "icon-exclamation-sign" }, ] -@webnotes.whitelist(allow_roles=["System Manager"]) +@webnotes.whitelist() def get(): + webnotes.only_for("System Manager") for item in items: if item.get("type")=="Section": continue From dea59996d87c22b02b4f9c44fa84943e30d64b4f Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Sat, 14 Dec 2013 01:15:37 +0600 Subject: [PATCH 30/80] bumped to version 3.2.2 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 77a00b846f..28d1a3d5e3 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.2.1", + "app_version": "3.2.2", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 70cd146bb5d00c78a906947332f70dc176bebe36 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 14 Dec 2013 17:16:21 +0530 Subject: [PATCH 31/80] [fix] [minor] update naming series --- setup/doctype/naming_series/naming_series.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/setup/doctype/naming_series/naming_series.py b/setup/doctype/naming_series/naming_series.py index 234a689a7b..3a14d4182d 100644 --- a/setup/doctype/naming_series/naming_series.py +++ b/setup/doctype/naming_series/naming_series.py @@ -22,7 +22,7 @@ class DocType: where fieldname='naming_series'""") )))), "prefixes": "\n".join([''] + [i[0] for i in - webnotes.conn.sql("""select name from tabSeries""")]) + webnotes.conn.sql("""select name from tabSeries order by name""")]) } def scrub_options_list(self, ol): @@ -38,7 +38,7 @@ class DocType: self.set_series_for(self.doc.select_doc_for_series, series_list) # create series - map(self.insert_series, series_list) + map(self.insert_series, [d.split('.')[0] for d in series_list]) msgprint('Series Updated') @@ -103,7 +103,8 @@ class DocType: dt.validate_series(series, self.doc.select_doc_for_series) for i in sr: if i[0]: - if series in i[0].split("\n"): + existing_series = [d.split('.')[0] for d in i[0].split("\n")] + if series.split(".")[0] in existing_series: msgprint("Oops! Series name %s is already in use in %s. \ Please select a new one" % (series, i[1]), raise_exception=1) @@ -120,17 +121,21 @@ class DocType: def get_current(self, arg=None): """get series current""" - self.doc.current_value = webnotes.conn.get_value("Series", self.doc.prefix, "current") + self.doc.current_value = webnotes.conn.get_value("Series", + self.doc.prefix.split('.')[0], "current") def insert_series(self, series): """insert series if missing""" if not webnotes.conn.exists('Series', series): - webnotes.conn.sql("insert into tabSeries (name, current) values (%s,0)", (series)) + webnotes.conn.sql("insert into tabSeries (name, current) values (%s, 0)", + (series)) def update_series_start(self): if self.doc.prefix: - self.insert_series(self.doc.prefix) - webnotes.conn.sql("update `tabSeries` set current = '%s' where name = '%s'" % (self.doc.current_value,self.doc.prefix)) + prefix = self.doc.prefix.split('.')[0] + self.insert_series(prefix) + webnotes.conn.sql("update `tabSeries` set current = %s where name = %s", + (self.doc.current_value, prefix)) msgprint("Series Updated Successfully") else: msgprint("Please select prefix first") From 45a35ced331a8947ca33da6cc02f16935cba261e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 14 Dec 2013 17:29:42 +0530 Subject: [PATCH 32/80] [fix] [minor] match condition fixes for customer and supplier --- buying/doctype/supplier_quotation/supplier_quotation.txt | 3 ++- selling/doctype/quotation/quotation.txt | 3 ++- stock/doctype/delivery_note/delivery_note.txt | 4 ++-- support/doctype/support_ticket/support_ticket.txt | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/buying/doctype/supplier_quotation/supplier_quotation.txt b/buying/doctype/supplier_quotation/supplier_quotation.txt index cf62a9f9fb..e532aa6dd1 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-11-22 17:16:16", + "modified": "2013-12-14 17:27:47", "modified_by": "Administrator", "owner": "Administrator" }, @@ -632,6 +632,7 @@ "cancel": 0, "create": 0, "doctype": "DocPerm", + "match": "supplier", "role": "Supplier", "submit": 0, "write": 0 diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index dc342726e4..93346d3029 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-11-27 17:57:19", + "modified": "2013-12-14 17:25:46", "modified_by": "Administrator", "owner": "Administrator" }, @@ -863,6 +863,7 @@ "cancel": 0, "create": 0, "doctype": "DocPerm", + "match": "customer", "role": "Customer", "submit": 0, "write": 0 diff --git a/stock/doctype/delivery_note/delivery_note.txt b/stock/doctype/delivery_note/delivery_note.txt index 7fb166e686..450b4f7c2e 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-11-03 14:20:19", + "modified": "2013-12-14 17:26:12", "modified_by": "Administrator", "owner": "Administrator" }, @@ -1058,7 +1058,7 @@ }, { "doctype": "DocPerm", - "match": "customer_name", + "match": "customer", "role": "Customer" } ] \ No newline at end of file diff --git a/support/doctype/support_ticket/support_ticket.txt b/support/doctype/support_ticket/support_ticket.txt index 684c809a90..4fa4874a9c 100644 --- a/support/doctype/support_ticket/support_ticket.txt +++ b/support/doctype/support_ticket/support_ticket.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-01 10:36:25", "docstatus": 0, - "modified": "2013-11-02 14:06:26", + "modified": "2013-12-14 17:27:02", "modified_by": "Administrator", "owner": "Administrator" }, @@ -278,6 +278,7 @@ { "cancel": 0, "doctype": "DocPerm", + "match": "customer", "role": "Customer" }, { From ba31ecc6112223da94c201051b05e0b0f9c13da6 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Sat, 14 Dec 2013 18:29:58 +0600 Subject: [PATCH 33/80] bumped to version 3.2.3 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 28d1a3d5e3..bb88d76293 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.2.2", + "app_version": "3.2.3", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 585e9362638287cd682802a6f64f8e8cdcb2e806 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sun, 15 Dec 2013 12:17:40 +0530 Subject: [PATCH 34/80] [fix] [minor] email digest: consider only submitted documents to get new sum of amount --- setup/doctype/email_digest/email_digest.py | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py index 1078d03268..a9720ae005 100644 --- a/setup/doctype/email_digest/email_digest.py +++ b/setup/doctype/email_digest/email_digest.py @@ -241,7 +241,7 @@ class DocType(DocListController): return self.get_new_count("Lead", self.meta.get_label("new_leads")) def get_new_enquiries(self): - return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries")) + return self.get_new_count("Opportunity", self.meta.get_label("new_enquiries"), docstatus=1) def get_new_quotations(self): return self.get_new_sum("Quotation", self.meta.get_label("new_quotations"), "grand_total") @@ -253,7 +253,8 @@ class DocType(DocListController): return self.get_new_sum("Delivery Note", self.meta.get_label("new_delivery_notes"), "grand_total") def get_new_purchase_requests(self): - return self.get_new_count("Material Request", self.meta.get_label("new_purchase_requests")) + return self.get_new_count("Material Request", + self.meta.get_label("new_purchase_requests"), docstatus=1) def get_new_supplier_quotations(self): return self.get_new_sum("Supplier Quotation", self.meta.get_label("new_supplier_quotations"), @@ -271,13 +272,16 @@ class DocType(DocListController): return self.get_new_sum("Stock Entry", self.meta.get_label("new_stock_entries"), "total_amount") def get_new_support_tickets(self): - return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"), False) + return self.get_new_count("Support Ticket", self.meta.get_label("new_support_tickets"), + filter_by_company=False) def get_new_communications(self): - return self.get_new_count("Communication", self.meta.get_label("new_communications"), False) + return self.get_new_count("Communication", self.meta.get_label("new_communications"), + filter_by_company=False) def get_new_projects(self): - return self.get_new_count("Project", self.meta.get_label("new_projects"), False) + return self.get_new_count("Project", self.meta.get_label("new_projects"), + filter_by_company=False) def get_calendar_events(self, user_id): from core.doctype.event.event import get_events @@ -321,22 +325,22 @@ class DocType(DocListController): else: return 0, "

To Do

" - def get_new_count(self, doctype, label, filter_by_company=True): + def get_new_count(self, doctype, label, docstatus=0, filter_by_company=True): if filter_by_company: company = """and company="%s" """ % self.doc.company else: company = "" count = webnotes.conn.sql("""select count(*) from `tab%s` - where docstatus < 2 %s and - date(creation)>=%s and date(creation)<=%s""" % (doctype, company, "%s", "%s"), - (self.from_date, self.to_date)) + where docstatus=%s %s and + date(creation)>=%s and date(creation)<=%s""" % + (doctype, docstatus, company, "%s", "%s"), (self.from_date, self.to_date)) count = count and count[0][0] or 0 return count, self.get_html(label, None, count) def get_new_sum(self, doctype, label, sum_field): count_sum = webnotes.conn.sql("""select count(*), sum(ifnull(`%s`, 0)) - from `tab%s` where docstatus < 2 and company = %s and + from `tab%s` where docstatus=1 and company = %s and date(creation)>=%s and date(creation)<=%s""" % (sum_field, doctype, "%s", "%s", "%s"), (self.doc.company, self.from_date, self.to_date)) count, total = count_sum and count_sum[0] or (0, 0) From b0636edaf74edbe155bf52591b4e88729fb3f190 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Dec 2013 13:51:09 +0530 Subject: [PATCH 35/80] [minor] [scheduler] send scheduler errors as email digest --- patches/1311/p07_scheduler_errors_digest.py | 23 +++++++++ patches/1311/p08_email_digest_recipients.py | 11 +++++ patches/patch_list.py | 2 + setup/doctype/email_digest/email_digest.js | 4 +- setup/doctype/email_digest/email_digest.py | 27 +++++++---- setup/doctype/email_digest/email_digest.txt | 53 ++++++++++++++++----- setup/page/setup_wizard/setup_wizard.py | 19 ++++++-- startup/bean_handlers.py | 3 +- startup/schedule_handlers.py | 11 ++--- 9 files changed, 119 insertions(+), 34 deletions(-) create mode 100644 patches/1311/p07_scheduler_errors_digest.py create mode 100644 patches/1311/p08_email_digest_recipients.py diff --git a/patches/1311/p07_scheduler_errors_digest.py b/patches/1311/p07_scheduler_errors_digest.py new file mode 100644 index 0000000000..7cfa251847 --- /dev/null +++ b/patches/1311/p07_scheduler_errors_digest.py @@ -0,0 +1,23 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + from webnotes.profile import get_system_managers + system_managers = get_system_managers(only_name=True) + if not system_managers: + return + + # scheduler errors digest + edigest = webnotes.new_bean("Email Digest") + edigest.doc.fields.update({ + "name": "Scheduler Errors", + "company": webnotes.conn.get_default("company"), + "frequency": "Daily", + "enabled": 1, + "recipient_list": "\n".join(system_managers), + "scheduler_errors": 1 + }) + edigest.insert() \ No newline at end of file diff --git a/patches/1311/p08_email_digest_recipients.py b/patches/1311/p08_email_digest_recipients.py new file mode 100644 index 0000000000..fad540844f --- /dev/null +++ b/patches/1311/p08_email_digest_recipients.py @@ -0,0 +1,11 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + from webnotes.utils import extract_email_id + for name, recipients in webnotes.conn.sql("""select name, recipient_list from `tabEmail Digest`"""): + recipients = "\n".join([extract_email_id(r) for r in recipients.split("\n")]) + webnotes.conn.set_value("Email Digest", name, "recipient_list", recipients) \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 9400e08872..9df0207979 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -258,4 +258,6 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", "execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')", "execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')", + "patches.1311.p07_scheduler_errors_digest", + "patches.1311.p08_email_digest_recipients", ] \ No newline at end of file diff --git a/setup/doctype/email_digest/email_digest.js b/setup/doctype/email_digest/email_digest.js index 3367a7237a..79cc681985 100644 --- a/setup/doctype/email_digest/email_digest.js +++ b/setup/doctype/email_digest/email_digest.js @@ -70,8 +70,10 @@ cur_frm.cscript.addremove_recipients = function(doc, dt, dn) { check.checked = 1; add_or_update = 'Update'; } + var fullname = wn.user.full_name(v.name); + if(fullname !== v.name) v.name = fullname + " <" + v.name + ">"; if(v.enabled==0) { - v.name = "" + v.name + " (disabled user)" + v.name = repl(" %(name)s (disabled user)", {name: v.name}); } var profile = $a($td(tab, i+1, 1), 'span', '', '', v.name); //profile.onclick = function() { check.checked = !check.checked; } diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py index a9720ae005..082b92fb7f 100644 --- a/setup/doctype/email_digest/email_digest.py +++ b/setup/doctype/email_digest/email_digest.py @@ -19,16 +19,16 @@ content_sequence = [ ["Selling", ["new_leads", "new_enquiries", "new_quotations", "new_sales_orders"]], ["Stock", ["new_delivery_notes", "new_purchase_receipts", "new_stock_entries"]], ["Support", ["new_communications", "new_support_tickets", "open_tickets"]], - ["Projects", ["new_projects"]] + ["Projects", ["new_projects"]], + ["System", ["scheduler_errors"]], ] user_specific_content = ["calendar_events", "todo_list"] -digest_template = """\ - -

%(digest)s

-

%(date)s

+digest_template = """ +

%(name)s

%(company)s

+

%(date)s


%(with_value)s %(no_value)s @@ -53,10 +53,10 @@ class DocType(DocListController): def get_profiles(self): """get list of profiles""" - import webnotes profile_list = webnotes.conn.sql(""" select name, enabled from tabProfile where docstatus=0 and name not in ('Administrator', 'Guest') + and user_type = "System User" order by enabled desc, name asc""", as_dict=1) if self.doc.recipient_list: @@ -81,7 +81,9 @@ class DocType(DocListController): msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \ common_msg) from webnotes.utils.email_lib import sendmail - sendmail(recipients=user_id, subject="[ERPNext] " + (self.doc.frequency + " Digest"), + sendmail(recipients=user_id, + subject="[ERPNext] [{frequency} Digest] {name}".format( + frequency=self.doc.frequency, name=self.doc.name), msg=msg_for_this_receipient) def get_digest_msg(self): @@ -123,7 +125,7 @@ class DocType(DocListController): if with_value: with_value = "\n".join(with_value) else: - with_value = "

There were no updates in the items selected for this digest.

" + with_value = "

There were no updates in the items selected for this digest.


" # seperate out no value items no_value = [o[1] for o in out if not o[0]] @@ -138,7 +140,8 @@ class DocType(DocListController): "date": date, "company": self.doc.company, "with_value": with_value, - "no_value": no_value or "" + "no_value": no_value or "", + "name": self.doc.name } return msg @@ -452,6 +455,10 @@ class DocType(DocListController): t for t in open_tickets]) else: return 0, "No Open Tickets!" + + def get_scheduler_errors(self): + import webnotes.utils.scheduler + return webnotes.utils.scheduler.get_error_report(self.from_date, self.to_date) def onload(self): self.get_next_sending() @@ -470,4 +477,4 @@ def send(): where enabled=1 and docstatus<2""", as_list=1): ed_obj = get_obj('Email Digest', ed[0]) if (now_date == ed_obj.get_next_sending()): - ed_obj.send() + ed_obj.send() \ No newline at end of file diff --git a/setup/doctype/email_digest/email_digest.txt b/setup/doctype/email_digest/email_digest.txt index f71d82a0e3..b04885a4c9 100644 --- a/setup/doctype/email_digest/email_digest.txt +++ b/setup/doctype/email_digest/email_digest.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-21 14:15:31", "docstatus": 0, - "modified": "2013-07-05 14:36:13", + "modified": "2013-12-16 12:37:43", "modified_by": "Administrator", "owner": "Administrator" }, @@ -100,11 +100,10 @@ "label": "Add/Remove Recipients" }, { - "description": "Check all the items below that you want to send in this digest.", "doctype": "DocField", - "fieldname": "select_digest_content", + "fieldname": "accounts", "fieldtype": "Section Break", - "label": "Select Digest Content" + "label": "Accounts" }, { "doctype": "DocField", @@ -178,7 +177,7 @@ "doctype": "DocField", "fieldname": "section_break_20", "fieldtype": "Section Break", - "options": "Simple" + "label": "Buying & Selling" }, { "doctype": "DocField", @@ -234,6 +233,12 @@ "fieldtype": "Check", "label": "New Sales Orders" }, + { + "doctype": "DocField", + "fieldname": "section_break_34", + "fieldtype": "Section Break", + "label": "Inventory & Support" + }, { "doctype": "DocField", "fieldname": "stock_module", @@ -258,12 +263,6 @@ "fieldtype": "Check", "label": "New Stock Entries" }, - { - "doctype": "DocField", - "fieldname": "section_break_34", - "fieldtype": "Section Break", - "options": "Simple" - }, { "doctype": "DocField", "fieldname": "support_module", @@ -288,6 +287,12 @@ "fieldtype": "Check", "label": "New Communications" }, + { + "doctype": "DocField", + "fieldname": "section_break_40", + "fieldtype": "Section Break", + "label": "Projects & System" + }, { "doctype": "DocField", "fieldname": "projects_module", @@ -302,7 +307,25 @@ }, { "doctype": "DocField", - "fieldname": "utilities_module", + "fieldname": "core_module", + "fieldtype": "Column Break", + "label": "System" + }, + { + "doctype": "DocField", + "fieldname": "scheduler_errors", + "fieldtype": "Check", + "label": "Scheduler Failed Events" + }, + { + "doctype": "DocField", + "fieldname": "user_specific", + "fieldtype": "Section Break", + "label": "User Specific" + }, + { + "doctype": "DocField", + "fieldname": "general", "fieldtype": "Column Break", "label": "General" }, @@ -318,6 +341,12 @@ "fieldtype": "Check", "label": "To Do List" }, + { + "doctype": "DocField", + "fieldname": "stub", + "fieldtype": "Column Break", + "label": "Stub" + }, { "cancel": 1, "create": 1, diff --git a/setup/page/setup_wizard/setup_wizard.py b/setup/page/setup_wizard/setup_wizard.py index bf149059a1..b5133ef479 100644 --- a/setup/page/setup_wizard/setup_wizard.py +++ b/setup/page/setup_wizard/setup_wizard.py @@ -171,7 +171,7 @@ def create_feed_and_todo(): def create_email_digest(): from webnotes.profile import get_system_managers - system_managers = get_system_managers() + system_managers = get_system_managers(only_name=True) if not system_managers: return @@ -186,10 +186,23 @@ def create_email_digest(): }) for fieldname in edigest.meta.get_fieldnames({"fieldtype": "Check"}): - edigest.doc.fields[fieldname] = 1 + if fieldname != "scheduler_errors": + edigest.doc.fields[fieldname] = 1 edigest.insert() - + + # scheduler errors digest + edigest = webnotes.new_bean("Email Digest") + edigest.doc.fields.update({ + "name": "Scheduler Errors", + "company": webnotes.conn.get_default("company"), + "frequency": "Daily", + "recipient_list": "\n".join(system_managers), + "scheduler_errors": 1, + "enabled": 1 + }) + edigest.insert() + def get_fy_details(fy_start_date, fy_end_date): start_year = getdate(fy_start_date).year if start_year == getdate(fy_end_date).year: diff --git a/startup/bean_handlers.py b/startup/bean_handlers.py index 06d27343d8..678c8aa5b4 100644 --- a/startup/bean_handlers.py +++ b/startup/bean_handlers.py @@ -13,4 +13,5 @@ def on_method(bean, method): clear_doctype_notifications(bean.controller, method) if bean.doc.doctype=="Stock Entry" and method in ("on_submit", "on_cancel"): - update_completed_qty(bean.controller, method) \ No newline at end of file + update_completed_qty(bean.controller, method) + \ No newline at end of file diff --git a/startup/schedule_handlers.py b/startup/schedule_handlers.py index cdb0e5d5dd..252a091547 100644 --- a/startup/schedule_handlers.py +++ b/startup/schedule_handlers.py @@ -34,10 +34,6 @@ def execute_daily(): from core.doctype.notification_count.notification_count import delete_notification_count_for delete_notification_count_for("Event") - # email digest - from setup.doctype.email_digest.email_digest import send - run_fn(send) - # run recurring invoices from accounts.doctype.sales_invoice.sales_invoice import manage_recurring_invoices run_fn(manage_recurring_invoices) @@ -53,10 +49,11 @@ def execute_daily(): # check reorder level from stock.utils import reorder_item run_fn(reorder_item) + + # email digest + from setup.doctype.email_digest.email_digest import send + run_fn(send) - # scheduler error - scheduler.report_errors() - def execute_weekly(): from setup.doctype.backup_manager.backup_manager import take_backups_weekly run_fn(take_backups_weekly) From 9ff9dafd009eb2ec7b2fcbac8b23522d934e98d9 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 16 Dec 2013 19:32:22 +0530 Subject: [PATCH 36/80] [feature] create material request sales order wise from production planning tool --- .../purchase_common/purchase_common.py | 9 +- .../production_planning_tool.py | 192 +++++++++++------- .../material_request/material_request.py | 36 ++-- 3 files changed, 140 insertions(+), 97 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index c265874992..6d8be0e79b 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -7,11 +7,9 @@ import webnotes from webnotes.utils import cstr, flt from webnotes.model.utils import getlist from webnotes import msgprint, _ - from buying.utils import get_last_purchase_details - - from controllers.buying_controller import BuyingController + class DocType(BuyingController): def __init__(self, doc, doclist=None): self.doc = doc @@ -107,7 +105,10 @@ class DocType(BuyingController): msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code), raise_exception=True) # list criteria that should not repeat if item is stock item - e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or '', d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', d.fields.has_key('batch_no') and d.batch_no or ''] + e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, + d.fields.has_key('prevdoc_docname') and d.prevdoc_docname or d.fields.has_key('sales_order_no') and d.sales_order_no or '', + d.fields.has_key('prevdoc_detail_docname') and d.prevdoc_detail_docname or '', + d.fields.has_key('batch_no') and d.batch_no or ''] # if is not stock item f = [d.schedule_date, d.item_code, d.description] diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py index ce93d80c6b..17db5f4f85 100644 --- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -9,7 +9,6 @@ from webnotes.model.bean import getlist from webnotes.model.code import get_obj from webnotes import msgprint, _ - class DocType: def __init__(self, doc, doclist=[]): self.doc = doc @@ -47,7 +46,7 @@ class DocType: def validate_company(self): if not self.doc.company: - msgprint("Please enter Company", raise_exception=1) + webnotes.throw(_("Please enter Company")) def get_open_sales_orders(self): """ Pull sales orders which are pending to deliver based on criteria selected""" @@ -106,7 +105,7 @@ class DocType: def get_items(self): so_list = filter(None, [d.sales_order for d in getlist(self.doclist, 'pp_so_details')]) if not so_list: - msgprint("Please enter sales order in the above table") + msgprint(_("Please enter sales order in the above table")) return [] items = webnotes.conn.sql("""select distinct parent, item_code, reserved_warehouse, @@ -155,21 +154,21 @@ class DocType: for d in getlist(self.doclist, 'pp_details'): self.validate_bom_no(d) if not flt(d.planned_qty): - msgprint("Please Enter Planned Qty for item: %s at row no: %s" % - (d.item_code, d.idx), raise_exception=1) + webnotes.throw(_("Please Enter Planned Qty for item: %s at row no: %s") % + (d.item_code, d.idx)) def validate_bom_no(self, d): if not d.bom_no: - msgprint("Please enter bom no for item: %s at row no: %s" % - (d.item_code, d.idx), raise_exception=1) + webnotes.throw(_("Please enter bom no for item: %s at row no: %s") % + (d.item_code, d.idx)) else: bom = webnotes.conn.sql("""select name from `tabBOM` where name = %s and item = %s and docstatus = 1 and is_active = 1""", (d.bom_no, d.item_code), as_dict = 1) if not bom: - msgprint("""Incorrect BOM No: %s entered for item: %s at row no: %s - May be BOM is inactive or for other item or does not exists in the system""" % - (d.bom_no, d.item_doce, d.idx), raise_exception=1) + webnotes.throw(_("""Incorrect BOM No: %s entered for item: %s at row no: %s + May be BOM is inactive or for other item or does not exists in the system""") % + (d.bom_no, d.item_doce, d.idx)) def raise_production_order(self): """It will raise production order (Draft) for all distinct FG items""" @@ -183,16 +182,20 @@ class DocType: if pro: pro = ["""%s""" % \ (p, p) for p in pro] - msgprint("Production Order(s) created:\n\n" + '\n'.join(pro)) + msgprint(_("Production Order(s) created:\n\n") + '\n'.join(pro)) else : - msgprint("No Production Order created.") + msgprint(_("No Production Order created.")) def get_distinct_items_and_boms(self): - """ Club similar BOM and item for processing""" + """ Club similar BOM and item for processing + bom_dict { + bom_no: ['sales_order', 'qty'] + } + """ item_dict, bom_dict = {}, {} for d in self.doclist.get({"parentfield": "pp_details"}): - bom_dict[d.bom_no] = bom_dict.get(d.bom_no, 0) + flt(d.planned_qty) + bom_dict.setdefault(d.bom_no, []).append([d.sales_order, flt(d.planned_qty)]) item_dict[(d.item_code, d.sales_order, d.warehouse)] = { "production_item" : d.item_code, "sales_order" : d.sales_order, @@ -241,48 +244,59 @@ class DocType: "item_code": [qty_required, description, stock_uom, min_order_qty] } """ - for bom in bom_dict: + bom_wise_item_details = {} + item_list = [] + + for bom, so_wise_qty in bom_dict.items(): if self.doc.use_multi_level_bom: # get all raw materials with sub assembly childs - fl_bom_items = webnotes.conn.sql("""select fb.item_code, - ifnull(sum(fb.qty_consumed_per_unit), 0)*%s as qty, + for d in webnotes.conn.sql("""select fb.item_code, + ifnull(sum(fb.qty_consumed_per_unit), 0) as qty, fb.description, fb.stock_uom, it.min_order_qty from `tabBOM Explosion Item` fb,`tabItem` it - where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No' + where it.name = fb.item_code and ifnull(it.is_pro_applicable, 'No') = 'No' and ifnull(it.is_sub_contracted_item, 'No') = 'No' - and fb.docstatus<2 and fb.parent=%s - group by item_code, stock_uom""", (flt(bom_dict[bom]), bom)) + and fb.docstatus<2 and fb.parent=%s + group by item_code, stock_uom""", bom, as_dict=1): + bom_wise_item_details.setdefault(d.item_code, d) else: # Get all raw materials considering SA items as raw materials, # so no childs of SA items - fl_bom_items = webnotes.conn.sql("""select bom_item.item_code, - ifnull(sum(bom_item.qty_consumed_per_unit), 0) * %s, - bom_item.description, bom_item.stock_uom, item.min_order_qty - from `tabBOM Item` bom_item, tabItem item + for d in webnotes.conn.sql("""select bom_item.item_code, + ifnull(sum(bom_item.qty_consumed_per_unit), 0) as qty, + bom_item.description, bom_item.stock_uom, item.min_order_qty + from `tabBOM Item` bom_item, tabItem item where bom_item.parent = %s and bom_item.docstatus < 2 and bom_item.item_code = item.name - group by item_code""", (flt(bom_dict[bom]), bom)) - self.make_items_dict(fl_bom_items) + group by item_code""", bom, as_dict=1): + bom_wise_item_details.setdefault(d.item_code, d) + + for item, item_details in bom_wise_item_details.items(): + for so_qty in so_wise_qty: + item_list.append([item, flt(item_details.qty) * so_qty[1], item_details.description, + item_details.stock_uom, item_details.min_order_qty, so_qty[0]]) + + self.make_items_dict(item_list) def make_items_dict(self, item_list): for i in item_list: - self.item_dict[i[0]] = [(flt(self.item_dict.get(i[0], [0])[0]) + flt(i[1])), - i[2], i[3], i[4]] - + self.item_dict.setdefault(i[0], []).append([flt(i[1]), i[2], i[3], i[4], i[5]]) def get_csv(self): item_list = [['Item Code', 'Description', 'Stock UOM', 'Required Qty', 'Warehouse', 'Quantity Requested for Purchase', 'Ordered Qty', 'Actual Qty']] - for d in self.item_dict: - item_list.append([d, self.item_dict[d][1], self.item_dict[d][2], self.item_dict[d][0]]) - item_qty= webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty - from `tabBin` where item_code = %s""", d) - i_qty, o_qty, a_qty = 0, 0, 0 - for w in item_qty: - i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3]) - item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])]) - if item_qty: - item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty]) + for item in self.item_dict: + total_qty = sum([flt(d[0]) for d in self.item_dict[item]]) + for item_details in self.item_dict[item]: + item_list.append([item, item_details[1], item_details[2], item_details[0]]) + item_qty = webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty + from `tabBin` where item_code = %s""", item) + i_qty, o_qty, a_qty = 0, 0, 0 + for w in item_qty: + i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3]) + item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])]) + if item_qty: + item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty]) return item_list @@ -293,31 +307,49 @@ class DocType: """ self.validate_data() if not self.doc.purchase_request_for_warehouse: - webnotes.msgprint("Please enter Warehouse for which Material Request will be raised", - raise_exception=1) + webnotes.throw(_("Please enter Warehouse for which Material Request will be raised")) bom_dict = self.get_distinct_items_and_boms()[0] self.get_raw_materials(bom_dict) - if not self.item_dict: - return - + if self.item_dict: + self.insert_purchase_request() + + def get_requested_items(self): item_projected_qty = self.get_projected_qty() - - from accounts.utils import get_fiscal_year - fiscal_year = get_fiscal_year(nowdate())[0] - items_to_be_requested = webnotes._dict() - for item in self.item_dict: - if flt(self.item_dict[item][0]) > item_projected_qty.get(item, 0): + + for item, so_item_qty in self.item_dict.items(): + requested_qty = 0 + total_qty = sum([flt(d[0]) for d in so_item_qty]) + if total_qty > item_projected_qty.get(item, 0): # shortage - requested_qty = flt(self.item_dict[item][0]) - item_projected_qty.get(item, 0) - # comsider minimum order qty - requested_qty = requested_qty > flt(self.item_dict[item][3]) and \ - requested_qty or flt(self.item_dict[item][3]) - items_to_be_requested[item] = requested_qty - - self.insert_purchase_request(items_to_be_requested, fiscal_year) + requested_qty = total_qty - item_projected_qty.get(item, 0) + # consider minimum order qty + requested_qty = requested_qty > flt(so_item_qty[0][3]) and \ + requested_qty or flt(so_item_qty[0][3]) + + # distribute requested qty SO wise + for item_details in so_item_qty: + if requested_qty: + sales_order = item_details[4] or "No Sales Order" + if requested_qty <= item_details[0]: + adjusted_qty = requested_qty + else: + adjusted_qty = item_details[0] + + items_to_be_requested.setdefault(item, {}).setdefault(sales_order, 0) + items_to_be_requested[item][sales_order] += adjusted_qty + requested_qty -= adjusted_qty + else: + break + + # requested qty >= total so qty, due to minimum order qty + if requested_qty: + items_to_be_requested.setdefault(item, {}).setdefault("No Sales Order", 0) + items_to_be_requested[item]["No Sales Order"] += requested_qty + + return items_to_be_requested def get_projected_qty(self): items = self.item_dict.keys() @@ -327,24 +359,29 @@ class DocType: return dict(item_projected_qty) - def insert_purchase_request(self, items_to_be_requested, fiscal_year): + def insert_purchase_request(self): + items_to_be_requested = self.get_requested_items() + + from accounts.utils import get_fiscal_year + fiscal_year = get_fiscal_year(nowdate())[0] + purchase_request_list = [] if items_to_be_requested: for item in items_to_be_requested: item_wrapper = webnotes.bean("Item", item) - pr_doclist = [ - { - "doctype": "Material Request", - "__islocal": 1, - "naming_series": "IDT", - "transaction_date": nowdate(), - "status": "Draft", - "company": self.doc.company, - "fiscal_year": fiscal_year, - "requested_by": webnotes.session.user, - "material_request_type": "Purchase" - }, - { + pr_doclist = [{ + "doctype": "Material Request", + "__islocal": 1, + "naming_series": "IDT", + "transaction_date": nowdate(), + "status": "Draft", + "company": self.doc.company, + "fiscal_year": fiscal_year, + "requested_by": webnotes.session.user, + "material_request_type": "Purchase" + }] + for sales_order, requested_qty in items_to_be_requested[item].items(): + pr_doclist.append({ "doctype": "Material Request Item", "__islocal": 1, "parentfield": "indent_details", @@ -354,11 +391,12 @@ class DocType: "uom": item_wrapper.doc.stock_uom, "item_group": item_wrapper.doc.item_group, "brand": item_wrapper.doc.brand, - "qty": items_to_be_requested[item], + "qty": requested_qty, "schedule_date": add_days(nowdate(), cint(item_wrapper.doc.lead_time_days)), - "warehouse": self.doc.purchase_request_for_warehouse - } - ] + "warehouse": self.doc.purchase_request_for_warehouse, + "sales_order_no": sales_order if sales_order!="No Sales Order" else None + }) + pr_wrapper = webnotes.bean(pr_doclist) pr_wrapper.ignore_permissions = 1 pr_wrapper.submit() @@ -367,7 +405,7 @@ class DocType: if purchase_request_list: pur_req = ["""%s""" % \ (p, p) for p in purchase_request_list] - webnotes.msgprint("Material Request(s) created: \n%s" % + msgprint(_("Material Request(s) created: \n%s") % "\n".join(pur_req)) else: - webnotes.msgprint("Nothing to request") + msgprint(_("Nothing to request")) \ No newline at end of file diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py index f340ccaedd..67d36eff1b 100644 --- a/stock/doctype/material_request/material_request.py +++ b/stock/doctype/material_request/material_request.py @@ -37,20 +37,25 @@ class DocType(BuyingController): for so_no in so_items.keys(): for item in so_items[so_no].keys(): - already_indented = webnotes.conn.sql("select sum(qty) from `tabMaterial Request Item` where item_code = '%s' and sales_order_no = '%s' and docstatus = 1 and parent != '%s'" % (item, so_no, self.doc.name)) + already_indented = webnotes.conn.sql("""select sum(qty) from `tabMaterial Request Item` + where item_code = '%s' and sales_order_no = '%s' and + docstatus = 1 and parent != '%s'""" % (item, so_no, self.doc.name)) already_indented = already_indented and flt(already_indented[0][0]) or 0 - actual_so_qty = webnotes.conn.sql("select sum(qty) from `tabSales Order Item` where parent = '%s' and item_code = '%s' and docstatus = 1 group by parent" % (so_no, item)) + actual_so_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item` + where parent = '%s' and item_code = '%s' and docstatus = 1 + group by parent""" % (so_no, item)) actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0 - if flt(so_items[so_no][item]) + already_indented > actual_so_qty: - msgprint("You can raise indent of maximum qty: %s for item: %s against sales order: %s\n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no), raise_exception=1) + if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty): + webnotes.throw(_("You can raise indent of maximum qty: %s for item: %s against sales order: %s\ + \n Anyway, you can add more qty in new row for the same item.") + % (actual_so_qty - already_indented, item, so_no)) def validate_schedule_date(self): for d in getlist(self.doclist, 'indent_details'): if d.schedule_date < self.doc.transaction_date: - msgprint("Expected Date cannot be before Material Request Date") - raise Exception + webnotes.throw(_("Expected Date cannot be before Material Request Date")) # Validate # --------------------- @@ -80,8 +85,8 @@ class DocType(BuyingController): for d in getlist(self.doclist, 'indent_details'): if webnotes.conn.get_value("Item", d.item_code, "is_stock_item") == "Yes": if not d.warehouse: - msgprint("Please Enter Warehouse for Item %s as it is stock item" - % cstr(d.item_code), raise_exception=1) + webnotes.throw("Please Enter Warehouse for Item %s as it is stock item" + % cstr(d.item_code)) qty =flt(d.qty) if is_stopped: @@ -96,16 +101,15 @@ class DocType(BuyingController): update_bin(args) def on_submit(self): - webnotes.conn.set(self.doc,'status','Submitted') + webnotes.conn.set(self.doc, 'status', 'Submitted') self.update_bin(is_submit = 1, is_stopped = 0) def check_modified_date(self): mod_db = webnotes.conn.sql("select modified from `tabMaterial Request` where name = '%s'" % self.doc.name) - date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % ( mod_db[0][0],cstr(self.doc.modified))) + date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % (mod_db[0][0], cstr(self.doc.modified))) if date_diff and date_diff[0][0]: - msgprint(cstr(self.doc.doctype) +" => "+ cstr(self.doc.name) +" has been modified. Please Refresh. ") - raise Exception + webnotes.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.") def update_status(self, status): self.check_modified_date() @@ -113,10 +117,10 @@ class DocType(BuyingController): self.update_bin(is_submit = (status == 'Submitted') and 1 or 0, is_stopped = 1) # Step 2:=> Set status - webnotes.conn.set(self.doc,'status',cstr(status)) + webnotes.conn.set(self.doc, 'status', cstr(status)) # Step 3:=> Acknowledge User - msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status)) ) + msgprint(self.doc.doctype + ": " + self.doc.name + _(" has been %s.") % ((status == 'Submitted') and 'Unstopped' or cstr(status)) ) def on_cancel(self): @@ -177,9 +181,9 @@ def update_completed_qty(controller, caller_method): mr_doctype = webnotes.get_doctype("Material Request") if mr_obj.doc.status in ["Stopped", "Cancelled"]: - msgprint(_("Material Request") + ": %s, " % mr_obj.doc.name + webnotes.throw(_("Material Request") + ": %s, " % mr_obj.doc.name + _(mr_doctype.get_label("status")) + " = %s. " % _(mr_obj.doc.status) - + _("Cannot continue."), raise_exception=webnotes.InvalidStatusError) + + _("Cannot continue."), exc=webnotes.InvalidStatusError) _update_requested_qty(controller, mr_obj, mr_items) From 9ee20e8f5a66f8976f1578ff2e6567df2ffabfc1 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 17 Dec 2013 13:07:00 +0530 Subject: [PATCH 37/80] [fix] [minor] material request sales order wise through production planning tool --- .../purchase_common/purchase_common.py | 62 +++++++++---------- .../production_planning_tool.py | 17 ++--- .../material_request/material_request.py | 20 +++--- 3 files changed, 51 insertions(+), 48 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 6d8be0e79b..b480caffc7 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -36,13 +36,13 @@ class DocType(BuyingController): if flt(d.conversion_factor): last_purchase_rate = flt(d.purchase_rate) / flt(d.conversion_factor) else: - msgprint(_("Row ") + cstr(d.idx) + ": " + - _("UOM Conversion Factor is mandatory"), raise_exception=1) + webnotes.throw(_("Row ") + cstr(d.idx) + ": " + + _("UOM Conversion Factor is mandatory")) # update last purchsae rate if last_purchase_rate: - webnotes.conn.sql("update `tabItem` set last_purchase_rate = %s where name = %s", - (flt(last_purchase_rate),d.item_code)) + webnotes.conn.sql("""update `tabItem` set last_purchase_rate = %s where name = %s""", + (flt(last_purchase_rate), d.item_code)) def get_last_purchase_rate(self, obj): """get last purchase rates for all items""" @@ -74,11 +74,11 @@ class DocType(BuyingController): for d in getlist( obj.doclist, obj.fname): # validation for valid qty if flt(d.qty) < 0 or (d.parenttype != 'Purchase Receipt' and not flt(d.qty)): - msgprint("Please enter valid qty for item %s" % cstr(d.item_code)) - raise Exception + webnotes.throw("Please enter valid qty for item %s" % cstr(d.item_code)) # udpate with latest quantities - bin = webnotes.conn.sql("select projected_qty from `tabBin` where item_code = %s and warehouse = %s", (d.item_code, d.warehouse), as_dict = 1) + bin = webnotes.conn.sql("""select projected_qty from `tabBin` where + item_code = %s and warehouse = %s""", (d.item_code, d.warehouse), as_dict=1) f_lst ={'projected_qty': bin and flt(bin[0]['projected_qty']) or 0, 'ordered_qty': 0, 'received_qty' : 0} if d.doctype == 'Purchase Receipt Item': @@ -87,22 +87,21 @@ class DocType(BuyingController): if d.fields.has_key(x): d.fields[x] = f_lst[x] - item = webnotes.conn.sql("select is_stock_item, is_purchase_item, is_sub_contracted_item, end_of_life from tabItem where name=%s", - d.item_code) + item = webnotes.conn.sql("""select is_stock_item, is_purchase_item, + is_sub_contracted_item, end_of_life from `tabItem` where name=%s""", d.item_code) if not item: - msgprint("Item %s does not exist in Item Master." % cstr(d.item_code), raise_exception=True) + webnotes.throw("Item %s does not exist in Item Master." % cstr(d.item_code)) from stock.utils import validate_end_of_life validate_end_of_life(d.item_code, item[0][3]) # validate stock item if item[0][0]=='Yes' and d.qty and not d.warehouse: - msgprint("Warehouse is mandatory for %s, since it is a stock item" % - d.item_code, raise_exception=1) + webnotes.throw("Warehouse is mandatory for %s, since it is a stock item" % d.item_code) # validate purchase item if item[0][1] != 'Yes' and item[0][2] != 'Yes': - msgprint("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code), raise_exception=True) + webnotes.throw("Item %s is not a purchase item or sub-contracted item. Please check" % (d.item_code)) # list criteria that should not repeat if item is stock item e = [d.schedule_date, d.item_code, d.description, d.warehouse, d.uom, @@ -113,25 +112,25 @@ class DocType(BuyingController): # if is not stock item f = [d.schedule_date, d.item_code, d.description] - ch = webnotes.conn.sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code) + ch = webnotes.conn.sql("""select is_stock_item from `tabItem` where name = %s""", d.item_code) if ch and ch[0][0] == 'Yes': # check for same items if e in check_list: - msgprint("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n - Please change any of the field value to enter the item twice""" % d.item_code, raise_exception = 1) + webnotes.throw("""Item %s has been entered more than once with same description, schedule date, warehouse and uom.\n + Please change any of the field value to enter the item twice""" % d.item_code) else: check_list.append(e) elif ch and ch[0][0] == 'No': # check for same items if f in chk_dupl_itm: - msgprint("""Item %s has been entered more than once with same description, schedule date.\n - Please change any of the field value to enter the item twice.""" % d.item_code, raise_exception = 1) + webnotes.throw("""Item %s has been entered more than once with same description, schedule date.\n + Please change any of the field value to enter the item twice.""" % d.item_code) else: chk_dupl_itm.append(f) - def get_qty(self,curr_doctype,ref_tab_fname,ref_tab_dn,ref_doc_tname, transaction, curr_parent_name): + def get_qty(self, curr_doctype, ref_tab_fname, ref_tab_dn, ref_doc_tname, transaction, curr_parent_name): # Get total Quantities of current doctype (eg. PR) except for qty of this transaction #------------------------------ # please check as UOM changes from Material Request - Purchase Order ,so doing following else uom should be same . @@ -139,35 +138,36 @@ class DocType(BuyingController): # but if in Material Request uom KG it can change in PO get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty' - qty = webnotes.conn.sql("select sum(%s) from `tab%s` where %s = '%s' and docstatus = 1 and parent != '%s'"% ( get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) + qty = webnotes.conn.sql("""select sum(%s) from `tab%s` where %s = %s and + docstatus = 1 and parent != %s""", (get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) qty = qty and flt(qty[0][0]) or 0 # get total qty of ref doctype #-------------------- - max_qty = webnotes.conn.sql("select qty from `tab%s` where name = '%s' and docstatus = 1"% (ref_doc_tname, ref_tab_dn)) + max_qty = webnotes.conn.sql("""select qty from `tab%s` where name = %s + and docstatus = 1""", (ref_doc_tname, ref_tab_dn)) max_qty = max_qty and flt(max_qty[0][0]) or 0 return cstr(qty)+'~~~'+cstr(max_qty) def check_for_stopped_status(self, doctype, docname): - stopped = webnotes.conn.sql("select name from `tab%s` where name = '%s' and status = 'Stopped'" % - ( doctype, docname)) + stopped = webnotes.conn.sql("""select name from `tab%s` where name = '%s' and + status = 'Stopped'""", (doctype, docname)) if stopped: - msgprint("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % - ( doctype, docname), raise_exception=1) + webnotes.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % + (doctype, docname)) - def check_docstatus(self, check, doctype, docname , detail_doctype = ''): + def check_docstatus(self, check, doctype, docname, detail_doctype = ''): if check == 'Next': submitted = webnotes.conn.sql("""select t1.name from `tab%s` t1,`tab%s` t2 where t1.name = t2.parent and t2.prevdoc_docname = %s and t1.docstatus = 1""" % (doctype, detail_doctype, '%s'), docname) if submitted: - msgprint(cstr(doctype) + ": " + cstr(submitted[0][0]) - + _(" has already been submitted."), raise_exception=1) + webnotes.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + + _("has already been submitted.")) if check == 'Previous': submitted = webnotes.conn.sql("""select name from `tab%s` - where docstatus = 1 and name = %s"""% (doctype, '%s'), docname) + where docstatus = 1 and name = %s""" % (doctype, '%s'), docname) if not submitted: - msgprint(cstr(doctype) + ": " + cstr(submitted[0][0]) - + _(" not submitted"), raise_exception=1) + webnotes.throw(cstr(doctype) + ": " + cstr(submitted[0][0]) + _("not submitted")) diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py index 17db5f4f85..c1185a1b12 100644 --- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -154,20 +154,20 @@ class DocType: for d in getlist(self.doclist, 'pp_details'): self.validate_bom_no(d) if not flt(d.planned_qty): - webnotes.throw(_("Please Enter Planned Qty for item: %s at row no: %s") % + webnotes.throw("Please Enter Planned Qty for item: %s at row no: %s" % (d.item_code, d.idx)) def validate_bom_no(self, d): if not d.bom_no: - webnotes.throw(_("Please enter bom no for item: %s at row no: %s") % + webnotes.throw("Please enter bom no for item: %s at row no: %s" % (d.item_code, d.idx)) else: bom = webnotes.conn.sql("""select name from `tabBOM` where name = %s and item = %s and docstatus = 1 and is_active = 1""", (d.bom_no, d.item_code), as_dict = 1) if not bom: - webnotes.throw(_("""Incorrect BOM No: %s entered for item: %s at row no: %s - May be BOM is inactive or for other item or does not exists in the system""") % + webnotes.throw("""Incorrect BOM No: %s entered for item: %s at row no: %s + May be BOM is inactive or for other item or does not exists in the system""" % (d.bom_no, d.item_doce, d.idx)) def raise_production_order(self): @@ -290,11 +290,12 @@ class DocType: for item_details in self.item_dict[item]: item_list.append([item, item_details[1], item_details[2], item_details[0]]) item_qty = webnotes.conn.sql("""select warehouse, indented_qty, ordered_qty, actual_qty - from `tabBin` where item_code = %s""", item) + from `tabBin` where item_code = %s""", item, as_dict=1) i_qty, o_qty, a_qty = 0, 0, 0 for w in item_qty: - i_qty, o_qty, a_qty = i_qty + flt(w[1]), o_qty + flt(w[2]), a_qty + flt(w[3]) - item_list.append(['', '', '', '', w[0], flt(w[1]), flt(w[2]), flt(w[3])]) + i_qty, o_qty, a_qty = i_qty + flt(w.indented_qty), o_qty + flt(w.ordered_qty), a_qty + flt(w.actual_qty) + item_list.append(['', '', '', '', w.warehouse, flt(w.indented_qty), + flt(w.ordered_qty), flt(w.actual_qty)]) if item_qty: item_list.append(['', '', '', '', 'Total', i_qty, o_qty, a_qty]) @@ -405,7 +406,7 @@ class DocType: if purchase_request_list: pur_req = ["""%s""" % \ (p, p) for p in purchase_request_list] - msgprint(_("Material Request(s) created: \n%s") % + msgprint("Material Request(s) created: \n%s" % "\n".join(pur_req)) else: msgprint(_("Nothing to request")) \ No newline at end of file diff --git a/stock/doctype/material_request/material_request.py b/stock/doctype/material_request/material_request.py index 67d36eff1b..50661a316a 100644 --- a/stock/doctype/material_request/material_request.py +++ b/stock/doctype/material_request/material_request.py @@ -38,18 +38,18 @@ class DocType(BuyingController): for so_no in so_items.keys(): for item in so_items[so_no].keys(): already_indented = webnotes.conn.sql("""select sum(qty) from `tabMaterial Request Item` - where item_code = '%s' and sales_order_no = '%s' and - docstatus = 1 and parent != '%s'""" % (item, so_no, self.doc.name)) + where item_code = %s and sales_order_no = %s and + docstatus = 1 and parent != %s""", (item, so_no, self.doc.name)) already_indented = already_indented and flt(already_indented[0][0]) or 0 actual_so_qty = webnotes.conn.sql("""select sum(qty) from `tabSales Order Item` - where parent = '%s' and item_code = '%s' and docstatus = 1 - group by parent""" % (so_no, item)) + where parent = %s and item_code = %s and docstatus = 1 + group by parent""", (so_no, item)) actual_so_qty = actual_so_qty and flt(actual_so_qty[0][0]) or 0 if actual_so_qty and (flt(so_items[so_no][item]) + already_indented > actual_so_qty): - webnotes.throw(_("You can raise indent of maximum qty: %s for item: %s against sales order: %s\ - \n Anyway, you can add more qty in new row for the same item.") + webnotes.throw("You can raise indent of maximum qty: %s for item: %s against sales order: %s\ + \n Anyway, you can add more qty in new row for the same item." % (actual_so_qty - already_indented, item, so_no)) def validate_schedule_date(self): @@ -105,8 +105,10 @@ class DocType(BuyingController): self.update_bin(is_submit = 1, is_stopped = 0) def check_modified_date(self): - mod_db = webnotes.conn.sql("select modified from `tabMaterial Request` where name = '%s'" % self.doc.name) - date_diff = webnotes.conn.sql("select TIMEDIFF('%s', '%s')" % (mod_db[0][0], cstr(self.doc.modified))) + mod_db = webnotes.conn.sql("""select modified from `tabMaterial Request` where name = %s""", + self.doc.name) + date_diff = webnotes.conn.sql("""select TIMEDIFF('%s', '%s')""" + % (mod_db[0][0], cstr(self.doc.modified))) if date_diff and date_diff[0][0]: webnotes.throw(cstr(self.doc.doctype) + " => " + cstr(self.doc.name) + " has been modified. Please Refresh.") @@ -120,7 +122,7 @@ class DocType(BuyingController): webnotes.conn.set(self.doc, 'status', cstr(status)) # Step 3:=> Acknowledge User - msgprint(self.doc.doctype + ": " + self.doc.name + _(" has been %s.") % ((status == 'Submitted') and 'Unstopped' or cstr(status)) ) + msgprint(self.doc.doctype + ": " + self.doc.name + " has been %s." % ((status == 'Submitted') and 'Unstopped' or cstr(status))) def on_cancel(self): From 9d6e10c910b3926d5d47e8342138b9e9882e0f49 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 14:45:55 +0530 Subject: [PATCH 38/80] [fix] [minor] precision in gl entry based on currency format --- .../doctype/sales_invoice/sales_invoice.py | 7 ++- .../sales_taxes_and_charges.txt | 57 ++++++++++--------- accounts/general_ledger.py | 4 -- controllers/selling_controller.py | 4 +- selling/sales_common.js | 1 - 5 files changed, 37 insertions(+), 36 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index b1834d5a5a..bfba30fa1b 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -399,9 +399,10 @@ class DocType(SellingController): if not self.doc.cash_bank_account and flt(self.doc.paid_amount): msgprint("Cash/Bank Account is mandatory for POS, for making payment entry") raise Exception - if (flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) - round(flt(self.doc.grand_total), 2))>0.001: - msgprint("(Paid amount + Write Off Amount) can not be greater than Grand Total") - raise Exception + if flt(self.doc.paid_amount) + flt(self.doc.write_off_amount) \ + - flt(self.doc.grand_total) > 1/(10**(self.precision("grand_total") + 1)): + webnotes.throw(_("""(Paid amount + Write Off Amount) can not be \ + greater than Grand Total""")) def validate_item_code(self): diff --git a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt index fbba6437f2..b006c1d85c 100644 --- a/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt +++ b/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-24 11:39:32", "docstatus": 0, - "modified": "2013-07-10 14:54:21", + "modified": "2013-12-17 12:38:08", "modified_by": "Administrator", "owner": "Administrator" }, @@ -37,11 +37,20 @@ "options": "\nActual\nOn Net Total\nOn Previous Row Amount\nOn Previous Row Total", "reqd": 1 }, + { + "doctype": "DocField", + "fieldname": "row_id", + "fieldtype": "Data", + "hidden": 0, + "label": "Enter Row", + "oldfieldname": "row_id", + "oldfieldtype": "Data" + }, { "doctype": "DocField", "fieldname": "account_head", "fieldtype": "Link", - "in_list_view": 1, + "in_list_view": 0, "label": "Account Head", "oldfieldname": "account_head", "oldfieldtype": "Link", @@ -54,7 +63,7 @@ "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", - "in_list_view": 1, + "in_list_view": 0, "label": "Cost Center", "oldfieldname": "cost_center_other_charges", "oldfieldtype": "Link", @@ -72,6 +81,24 @@ "reqd": 1, "width": "300px" }, + { + "allow_on_submit": 0, + "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", + "doctype": "DocField", + "fieldname": "included_in_print_rate", + "fieldtype": "Check", + "label": "Is this Tax included in Basic Rate?", + "no_copy": 0, + "print_hide": 1, + "print_width": "150px", + "report_hide": 1, + "width": "150px" + }, + { + "doctype": "DocField", + "fieldname": "section_break_6", + "fieldtype": "Section Break" + }, { "doctype": "DocField", "fieldname": "rate", @@ -80,7 +107,7 @@ "label": "Rate", "oldfieldname": "rate", "oldfieldtype": "Currency", - "reqd": 0 + "reqd": 1 }, { "doctype": "DocField", @@ -104,15 +131,6 @@ "options": "Company:company:default_currency", "read_only": 1 }, - { - "doctype": "DocField", - "fieldname": "row_id", - "fieldtype": "Data", - "hidden": 0, - "label": "Enter Row", - "oldfieldname": "row_id", - "oldfieldtype": "Data" - }, { "doctype": "DocField", "fieldname": "item_wise_tax_detail", @@ -134,18 +152,5 @@ "oldfieldtype": "Data", "print_hide": 1, "search_index": 1 - }, - { - "allow_on_submit": 0, - "description": "If checked, the tax amount will be considered as already included in the Print Rate / Print Amount", - "doctype": "DocField", - "fieldname": "included_in_print_rate", - "fieldtype": "Check", - "label": "Is this Tax included in Basic Rate?", - "no_copy": 0, - "print_hide": 1, - "print_width": "150px", - "report_hide": 1, - "width": "150px" } ] \ No newline at end of file diff --git a/accounts/general_ledger.py b/accounts/general_ledger.py index 87814b128f..bc0ac1d93c 100644 --- a/accounts/general_ledger.py +++ b/accounts/general_ledger.py @@ -24,10 +24,6 @@ def process_gl_map(gl_map, merge_entries=True): gl_map = merge_similar_entries(gl_map) for entry in gl_map: - # round off upto 2 decimal - entry.debit = flt(entry.debit, 2) - entry.credit = flt(entry.credit, 2) - # toggle debit, credit if negative entry if flt(entry.debit) < 0: entry.credit = flt(entry.credit) - flt(entry.debit) diff --git a/controllers/selling_controller.py b/controllers/selling_controller.py index fd4ca40947..67c1462662 100644 --- a/controllers/selling_controller.py +++ b/controllers/selling_controller.py @@ -205,8 +205,8 @@ class SellingController(StockController): self.round_floats_in(self.doc, ["grand_total", "total_advance", "write_off_amount", "paid_amount"]) total_amount_to_pay = self.doc.grand_total - self.doc.write_off_amount - self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance - self.doc.paid_amount, - self.precision("outstanding_amount")) + self.doc.outstanding_amount = flt(total_amount_to_pay - self.doc.total_advance \ + - self.doc.paid_amount, self.precision("outstanding_amount")) def calculate_commission(self): if self.meta.get_field("commission_rate"): diff --git a/selling/sales_common.js b/selling/sales_common.js index d6c8fdd0e4..dddc2b568d 100644 --- a/selling/sales_common.js +++ b/selling/sales_common.js @@ -515,7 +515,6 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ } }); }; - setup_field_label_map(["net_total", "other_charges_total", "grand_total", "rounded_total", "in_words", "outstanding_amount", "total_advance", "paid_amount", "write_off_amount"], From d94bab0e1d4ea3858180afe5a23d6e46f0c4d0dc Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 17 Dec 2013 15:05:37 +0530 Subject: [PATCH 39/80] [fix] [minor] sql query related changes in purchase common --- buying/doctype/purchase_common/purchase_common.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index b480caffc7..8c4fbffe5b 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -139,20 +139,21 @@ class DocType(BuyingController): get_qty = (transaction == 'Material Request - Purchase Order') and 'qty * conversion_factor' or 'qty' qty = webnotes.conn.sql("""select sum(%s) from `tab%s` where %s = %s and - docstatus = 1 and parent != %s""", (get_qty, curr_doctype, ref_tab_fname, ref_tab_dn, curr_parent_name)) + docstatus = 1 and parent != %s""" % (get_qty, curr_doctype, ref_tab_fname, '%s', '%s'), + (ref_tab_dn, curr_parent_name)) qty = qty and flt(qty[0][0]) or 0 # get total qty of ref doctype #-------------------- max_qty = webnotes.conn.sql("""select qty from `tab%s` where name = %s - and docstatus = 1""", (ref_doc_tname, ref_tab_dn)) + and docstatus = 1""" % (ref_doc_tname, '%s'), ref_tab_dn) max_qty = max_qty and flt(max_qty[0][0]) or 0 return cstr(qty)+'~~~'+cstr(max_qty) def check_for_stopped_status(self, doctype, docname): - stopped = webnotes.conn.sql("""select name from `tab%s` where name = '%s' and - status = 'Stopped'""", (doctype, docname)) + stopped = webnotes.conn.sql("""select name from `tab%s` where name = %s and + status = 'Stopped'""" % (doctype, '%s'), docname) if stopped: webnotes.throw("One cannot do any transaction against %s : %s, it's status is 'Stopped'" % (doctype, docname)) From 57e89ff6f132bf47e818f26f437fce3a4d1b2205 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 16:09:21 +0530 Subject: [PATCH 40/80] [reports] general ledger: grid report to script report --- accounts/page/accounts_home/accounts_home.js | 3 +- .../report/general_ledger/general_ledger.js | 12 ++--- .../report/general_ledger/general_ledger.py | 47 +++++++++++++++---- stock/report/stock_ageing/stock_ageing.py | 11 +++-- .../stock_projected_qty.py | 5 +- 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 69c7da1b7c..db7a20cc79 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -157,7 +157,8 @@ wn.module_page["Accounts"] = [ items: [ { "label":wn._("General Ledger"), - page: "general-ledger" + doctype: "GL Entry", + route: "query-report/General Ledger" }, { "label":wn._("Trial Balance"), diff --git a/accounts/report/general_ledger/general_ledger.js b/accounts/report/general_ledger/general_ledger.js index b0cd485527..7985277115 100644 --- a/accounts/report/general_ledger/general_ledger.js +++ b/accounts/report/general_ledger/general_ledger.js @@ -22,6 +22,12 @@ wn.query_reports["General Ledger"] = { "label": wn._("Voucher No"), "fieldtype": "Data", }, + { + "fieldname":"group_by", + "label": wn._("Group by"), + "fieldtype": "Select", + "options": "\nGroup by Account\nGroup by Voucher" + }, { "fieldtype": "Break", }, @@ -40,12 +46,6 @@ wn.query_reports["General Ledger"] = { "default": wn.datetime.get_today(), "reqd": 1, "width": "60px" - }, - { - "fieldname":"group_by", - "label": wn._("Group by"), - "fieldtype": "Select", - "options": "\nAccount\nVoucher" } ] } \ No newline at end of file diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index 23c79d8996..fcf8010715 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -4,16 +4,28 @@ from __future__ import unicode_literals import webnotes from webnotes.utils import flt +from webnotes import _ def execute(filters=None): + validate_filters(filters) columns = get_columns() + if filters.get("group_by"): data = get_grouped_gle(filters) else: data = get_gl_entries(filters) + if data: + data.append(get_total_row(data)) return columns, data +def validate_filters(filters): + if filters.get("account") and filters.get("group_by") == "Group by Account": + webnotes.throw(_("Can not filter based on Account, if grouped by Account")) + + if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher": + webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher")) + def get_columns(): return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Currency:100", "Credit:Currency:100", "Voucher Type::120", "Voucher No::160", @@ -27,24 +39,41 @@ def get_gl_entries(filters): and posting_date between %(from_date)s and %(to_date)s {conditions} order by posting_date, account"""\ - .format(conditions=get_conditions(filters)), filters) + .format(conditions=get_conditions(filters)), filters, as_list=1) def get_conditions(filters): - return " and account=%(account)s" if filters.get("account") else "" + conditions = [] + if filters.get("account"): + conditions.append("account=%(account)s") + if filters.get("voucher_no"): + conditions.append("voucher_no=%(voucher_no)s") + return "and {}".format(" and ".join(conditions)) if conditions else "" + def get_grouped_gle(filters): gle_map = {} gle = get_gl_entries(filters) for d in gle: - gle_map.setdefault(d[1 if filters["group_by"]=="Account" else 5], []).append(d) + gle_map.setdefault(d[1 if filters["group_by"]=="Group by Account" else 5], []).append(d) data = [] for entries in gle_map.values(): - total_debit = total_credit = 0.0 + subtotal_debit = subtotal_credit = 0.0 for entry in entries: data.append(entry) - total_debit += flt(entry[2]) - total_credit += flt(entry[3]) - - data.append(["", "Total", total_debit, total_credit, "", "", ""]) - return data \ No newline at end of file + subtotal_debit += flt(entry[2]) + subtotal_credit += flt(entry[3]) + + data.append(["", "Total", subtotal_debit, subtotal_credit, "", "", ""]) + + if data: + data.append(get_total_row(gle)) + return data + +def get_total_row(gle): + total_debit = total_credit = 0.0 + for d in gle: + total_debit += flt(d[2]) + total_credit += flt(d[3]) + + return ["", "Total Debit/Credit", total_debit, total_credit, "", "", ""] \ No newline at end of file diff --git a/stock/report/stock_ageing/stock_ageing.py b/stock/report/stock_ageing/stock_ageing.py index fa052050ca..defe7248d2 100644 --- a/stock/report/stock_ageing/stock_ageing.py +++ b/stock/report/stock_ageing/stock_ageing.py @@ -20,8 +20,8 @@ def execute(filters=None): earliest_age = date_diff(to_date, fifo_queue[0][1]) latest_age = date_diff(to_date, fifo_queue[-1][1]) - data.append([item, details.item_name, details.description, details.brand, - average_age, earliest_age, latest_age, details.stock_uom]) + data.append([item, details.item_name, details.description, details.item_group, + details.brand, average_age, earliest_age, latest_age, details.stock_uom]) return columns, data @@ -36,8 +36,8 @@ def get_average_age(fifo_queue, to_date): def get_columns(): return ["Item Code:Link/Item:100", "Item Name::100", "Description::200", - "Brand:Link/Brand:100", "Average Age:Float:100", "Earliest:Int:80", - "Latest:Int:80", "UOM:Link/UOM:100"] + "Item Group:Link/Item Group:100", "Brand:Link/Brand:100", "Average Age:Float:100", + "Earliest:Int:80", "Latest:Int:80", "UOM:Link/UOM:100"] def get_fifo_queue(filters): item_details = {} @@ -64,7 +64,8 @@ def get_fifo_queue(filters): def get_stock_ledger_entries(filters): return webnotes.conn.sql("""select - item.name, item.item_name, brand, description, item.stock_uom, actual_qty, posting_date + item.name, item.item_name, item_group, brand, description, item.stock_uom, + actual_qty, posting_date from `tabStock Ledger Entry` sle, (select name, item_name, description, stock_uom, brand from `tabItem` {item_conditions}) item diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py index 232c744c87..11d519558d 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.py +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -8,13 +8,14 @@ def execute(filters=None): columns = get_columns() data = webnotes.conn.sql("""select - item.name, item.item_name, description, brand, warehouse, item.stock_uom, + item.name, item.item_name, description, item_group, brand, warehouse, item.stock_uom, actual_qty, planned_qty, indented_qty, ordered_qty, reserved_qty, projected_qty, item.re_order_level, item.re_order_qty from `tabBin` bin, (select name, company from tabWarehouse where company=%(company)s {warehouse_conditions}) wh, - (select name, item_name, description, stock_uom, brand, re_order_level, re_order_qty + (select name, item_name, description, stock_uom, item_group, + brand, re_order_level, re_order_qty from `tabItem` {item_conditions}) item where item_code = item.name and warehouse = wh.name order by item.name, wh.name"""\ From 592d27e7f10aeb0b183ba0f9695e212f6a78f252 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 16:20:11 +0530 Subject: [PATCH 41/80] [reports] general ledger: grid report to script report --- accounts/page/general_ledger/README.md | 1 - accounts/page/general_ledger/__init__.py | 1 - .../page/general_ledger/general_ledger.css | 0 .../page/general_ledger/general_ledger.html | 0 .../page/general_ledger/general_ledger.js | 396 ------------------ .../page/general_ledger/general_ledger.txt | 41 -- patches/1312/p01_delete_old_stock_reports.py | 4 +- 7 files changed, 3 insertions(+), 440 deletions(-) delete mode 100644 accounts/page/general_ledger/README.md delete mode 100644 accounts/page/general_ledger/__init__.py delete mode 100644 accounts/page/general_ledger/general_ledger.css delete mode 100644 accounts/page/general_ledger/general_ledger.html delete mode 100644 accounts/page/general_ledger/general_ledger.js delete mode 100644 accounts/page/general_ledger/general_ledger.txt diff --git a/accounts/page/general_ledger/README.md b/accounts/page/general_ledger/README.md deleted file mode 100644 index 8c51e9152c..0000000000 --- a/accounts/page/general_ledger/README.md +++ /dev/null @@ -1 +0,0 @@ -General Ledger report (for all transactions and accounts). \ No newline at end of file diff --git a/accounts/page/general_ledger/__init__.py b/accounts/page/general_ledger/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/accounts/page/general_ledger/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/accounts/page/general_ledger/general_ledger.css b/accounts/page/general_ledger/general_ledger.css deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/accounts/page/general_ledger/general_ledger.html b/accounts/page/general_ledger/general_ledger.html deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/accounts/page/general_ledger/general_ledger.js b/accounts/page/general_ledger/general_ledger.js deleted file mode 100644 index 7eeab58416..0000000000 --- a/accounts/page/general_ledger/general_ledger.js +++ /dev/null @@ -1,396 +0,0 @@ -// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors -// License: GNU General Public License v3. See license.txt - -wn.pages['general-ledger'].onload = function(wrapper) { - wn.ui.make_app_page({ - parent: wrapper, - title: wn._('General Ledger'), - single_column: true - }); - - erpnext.general_ledger = new erpnext.GeneralLedger(wrapper); - wrapper.appframe.add_module_icon("Accounts") - -} - -erpnext.GeneralLedger = wn.views.GridReport.extend({ - init: function(wrapper) { - this._super({ - title: wn._("General Ledger"), - page: wrapper, - parent: $(wrapper).find('.layout-main'), - appframe: wrapper.appframe, - doctypes: ["Company", "Account", "GL Entry", "Cost Center"], - }); - }, - setup_columns: function() { - this.columns = [ - {id: "posting_date", name: wn._("Posting Date"), field: "posting_date", width: 100, - formatter: this.date_formatter}, - {id: "account", name: wn._("Account"), field: "account", width: 240, - link_formatter: { - filter_input: "account", - open_btn: true, - doctype: "'Account'" - }}, - {id: "against_account", name: wn._("Against Account"), field: "against_account", - width: 240, hidden: !this.account}, - - {id: "debit", name: wn._("Debit"), field: "debit", width: 100, - formatter: this.currency_formatter}, - {id: "credit", name: wn._("Credit"), field: "credit", width: 100, - formatter: this.currency_formatter}, - {id: "voucher_type", name: wn._("Voucher Type"), field: "voucher_type", width: 120}, - {id: "voucher_no", name: wn._("Voucher No"), field: "voucher_no", width: 160, - link_formatter: { - filter_input: "voucher_no", - open_btn: true, - doctype: "dataContext.voucher_type" - }}, - {id: "remarks", name: wn._("Remarks"), field: "remarks", width: 200, - formatter: this.text_formatter}, - - ]; - }, - - filters: [ - {fieldtype:"Select", label: wn._("Company"), link:"Company", default_value: wn._("Select Company..."), - filter: function(val, item, opts) { - return item.company == val || val == opts.default_value; - }}, - {fieldtype:"Link", label: wn._("Account"), link:"Account", - filter: function(val, item, opts, me) { - if(!val) { - return true; - } else { - // true if GL Entry belongs to selected - // account ledger or group - return me.is_child_account(val, item.account); - } - }}, - {fieldtype:"Data", label: wn._("Voucher No"), - filter: function(val, item, opts) { - if(!val) return true; - return (item.voucher_no && item.voucher_no.indexOf(val)!=-1); - }}, - {fieldtype:"Date", label: wn._("From Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) <= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype:"Label", label: wn._("To")}, - {fieldtype:"Date", label: wn._("To Date"), filter: function(val, item) { - return dateutil.str_to_obj(val) >= dateutil.str_to_obj(item.posting_date); - }}, - {fieldtype: "Check", label: wn._("Group by Ledger")}, - {fieldtype: "Check", label: wn._("Group by Voucher")}, - {fieldtype:"Button", label: wn._("Refresh"), icon:"icon-refresh icon-white"}, - {fieldtype:"Button", label: wn._("Reset Filters")} - ], - setup_filters: function() { - this._super(); - var me = this; - - this.accounts_by_company = this.make_accounts_by_company(); - - // filter accounts options by company - this.filter_inputs.company.on("change", function() { - me.setup_account_filter(this); - me.refresh(); - }); - - this.trigger_refresh_on_change(["group_by_ledger", "group_by_voucher"]); - }, - setup_account_filter: function(company_filter) { - var me = this; - - var $account = me.filter_inputs.account; - var company = $(company_filter).val(); - var default_company = this.filter_inputs.company.get(0).opts.default_value; - var opts = $account.get(0).opts; - opts.list = $.map(wn.report_dump.data["Account"], function(ac) { - return (company===default_company || - me.accounts_by_company[company].indexOf(ac.name)!=-1) ? - ac.name : null; - }); - - this.set_autocomplete($account, opts.list); - - }, - init_filter_values: function() { - this._super(); - this.toggle_group_by_checks(); - this.filter_inputs.company.trigger("change"); - }, - apply_filters_from_route: function() { - this._super(); - this.toggle_group_by_checks(); - }, - make_accounts_by_company: function() { - var accounts_by_company = {}; - var me = this; - $.each(wn.report_dump.data["Account"], function(i, ac) { - if(!accounts_by_company[ac.company]) accounts_by_company[ac.company] = []; - accounts_by_company[ac.company].push(ac.name); - }); - return accounts_by_company; - }, - is_child_account: function(account, item_account) { - account = this.account_by_name[account]; - item_account = this.account_by_name[item_account]; - return ((item_account.lft >= account.lft) && (item_account.rgt <= account.rgt)); - }, - toggle_group_by_checks: function() { - this.make_account_by_name(); - - // this.filter_inputs.group_by_ledger - // .parent().toggle(!!(this.account_by_name[this.account] - // && this.account_by_name[this.account].group_or_ledger==="Group")); - // - // this.filter_inputs.group_by_voucher - // .parent().toggle(!!(this.account_by_name[this.account] - // && this.account_by_name[this.account].group_or_ledger==="Ledger")); - }, - prepare_data: function() { - var me = this; - var data = wn.report_dump.data["GL Entry"]; - var out = []; - - this.toggle_group_by_checks(); - - var from_date = dateutil.str_to_obj(this.from_date); - var to_date = dateutil.str_to_obj(this.to_date); - - if(to_date < from_date) { - msgprint(wn._("From Date must be before To Date")); - return; - } - - // add Opening, Closing, Totals rows - // if filtered by account and / or voucher - var opening = this.make_summary_row("Opening", this.account); - var totals = this.make_summary_row("Totals", this.account); - - var grouped_ledgers = {}; - $.each(data, function(i, item) { - if(me.apply_filter(item, "company") && - (me.account ? me.is_child_account(me.account, item.account) - : true) && (me.voucher_no ? item.voucher_no==me.voucher_no : true)) { - var date = dateutil.str_to_obj(item.posting_date); - - // create grouping by ledger - if(!grouped_ledgers[item.account]) { - grouped_ledgers[item.account] = { - entries: [], - entries_group_by_voucher: {}, - opening: me.make_summary_row("Opening", item.account), - totals: me.make_summary_row("Totals", item.account), - closing: me.make_summary_row("Closing (Opening + Totals)", - item.account) - }; - } - - if(!grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no]) { - grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] = { - row: {}, - totals: {"debit": 0, "credit": 0} - } - } - - if(!me.voucher_no && (date < from_date || item.is_opening=="Yes")) { - opening.debit += item.debit; - opening.credit += item.credit; - - grouped_ledgers[item.account].opening.debit += item.debit; - grouped_ledgers[item.account].opening.credit += item.credit; - - } else if(date <= to_date) { - - totals.debit += item.debit; - totals.credit += item.credit; - - grouped_ledgers[item.account].totals.debit += item.debit; - grouped_ledgers[item.account].totals.credit += item.credit; - grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] - .totals.debit += item.debit; - grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] - .totals.credit += item.credit; - } - if(item.account) { - item.against_account = me.voucher_accounts[item.voucher_type + ":" - + item.voucher_no][(item.debit > 0 ? "credits" : "debits")].join(", "); - } - - if(me.apply_filters(item) && (me.voucher_no || item.is_opening=="No")) { - out.push(item); - grouped_ledgers[item.account].entries.push(item); - - if(grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no].row){ - grouped_ledgers[item.account].entries_group_by_voucher[item.voucher_no] - .row = $.extend({}, item); - } - } - } - }); - - var closing = this.make_summary_row("Closing (Opening + Totals)", this.account); - closing.debit = opening.debit + totals.debit; - closing.credit = opening.credit + totals.credit; - - if(me.account) { - me.appframe.set_title(wn._("General Ledger: ") + me.account); - - // group by ledgers - if(this.account_by_name[this.account].group_or_ledger==="Group" - && this.group_by_ledger) { - out = this.group_data_by_ledger(grouped_ledgers); - } - - if(this.account_by_name[this.account].group_or_ledger==="Ledger" - && this.group_by_voucher) { - out = this.group_data_by_voucher(grouped_ledgers); - } - - opening = me.get_balance(me.account_by_name[me.account].debit_or_credit, opening) - closing = me.get_balance(me.account_by_name[me.account].debit_or_credit, closing) - - out = [opening].concat(out).concat([totals, closing]); - } else { - me.appframe.set_title(wn._("General Ledger")); - out = out.concat([totals]); - } - - this.data = out; - }, - - group_data_by_ledger: function(grouped_ledgers) { - var me = this; - var out = [] - $.each(Object.keys(grouped_ledgers).sort(), function(i, account) { - if(grouped_ledgers[account].entries.length) { - grouped_ledgers[account].closing.debit = - grouped_ledgers[account].opening.debit - + grouped_ledgers[account].totals.debit; - - grouped_ledgers[account].closing.credit = - grouped_ledgers[account].opening.credit - + grouped_ledgers[account].totals.credit; - - grouped_ledgers[account].opening = - me.get_balance(me.account_by_name[me.account].debit_or_credit, - grouped_ledgers[account].opening) - grouped_ledgers[account].closing = - me.get_balance(me.account_by_name[me.account].debit_or_credit, - grouped_ledgers[account].closing) - - out = out.concat([grouped_ledgers[account].opening]) - .concat(grouped_ledgers[account].entries) - .concat([grouped_ledgers[account].totals, - grouped_ledgers[account].closing, - {id: "_blank" + i, debit: "", credit: ""}]); - } - }); - return [{id: "_blank_first", debit: "", credit: ""}].concat(out); - }, - - group_data_by_voucher: function(grouped_ledgers) { - var me = this; - var out = [] - $.each(Object.keys(grouped_ledgers).sort(), function(i, account) { - if(grouped_ledgers[account].entries.length) { - $.each(Object.keys(grouped_ledgers[account].entries_group_by_voucher), - function(j, voucher) { - voucher_dict = grouped_ledgers[account].entries_group_by_voucher[voucher]; - if(voucher_dict && - (voucher_dict.totals.debit || voucher_dict.totals.credit)) { - voucher_dict.row.debit = voucher_dict.totals.debit; - voucher_dict.row.credit = voucher_dict.totals.credit; - voucher_dict.row.id = "entry_grouped_by_" + voucher - out = out.concat(voucher_dict.row); - } - }); - } - }); - return out; - }, - - get_balance: function(debit_or_credit, balance) { - if(debit_or_credit == "Debit") { - balance.debit -= balance.credit; balance.credit = 0; - } else { - balance.credit -= balance.debit; balance.debit = 0; - } - return balance - }, - - make_summary_row: function(label, item_account) { - return { - account: label, - debit: 0.0, - credit: 0.0, - id: ["", label, item_account].join("_").replace(" ", "_").toLowerCase(), - _show: true, - _style: "font-weight: bold" - } - }, - - make_account_by_name: function() { - this.account_by_name = this.make_name_map(wn.report_dump.data["Account"]); - this.make_voucher_accounts_map(); - }, - - make_voucher_accounts_map: function() { - this.voucher_accounts = {}; - var data = wn.report_dump.data["GL Entry"]; - for(var i=0, j=data.length; i 0) { - va.debits.push(gl.account); - } else { - va.credits.push(gl.account); - } - } - }, - - get_plot_data: function() { - var data = []; - var me = this; - if(!me.account || me.voucher_no) return false; - var debit_or_credit = me.account_by_name[me.account].debit_or_credit; - var balance = debit_or_credit=="Debit" ? me.data[0].debit : me.data[0].credit; - data.push({ - label: me.account, - data: [[dateutil.str_to_obj(me.from_date).getTime(), balance]] - .concat($.map(me.data, function(col, idx) { - if (col.posting_date) { - var diff = (debit_or_credit == "Debit" ? 1 : -1) * (flt(col.debit) - flt(col.credit)); - balance += diff; - return [[dateutil.str_to_obj(col.posting_date).getTime(), balance - diff], - [dateutil.str_to_obj(col.posting_date).getTime(), balance]] - } - return null; - })).concat([ - // closing - [dateutil.str_to_obj(me.to_date).getTime(), balance] - ]), - points: {show: true}, - lines: {show: true, fill: true}, - }); - return data; - }, - get_plot_options: function() { - return { - grid: { hoverable: true, clickable: true }, - xaxis: { mode: "time", - min: dateutil.str_to_obj(this.from_date).getTime(), - max: dateutil.str_to_obj(this.to_date).getTime() }, - series: { downsample: { threshold: 1000 } } - } - }, -}); \ No newline at end of file diff --git a/accounts/page/general_ledger/general_ledger.txt b/accounts/page/general_ledger/general_ledger.txt deleted file mode 100644 index 2cc8a601e9..0000000000 --- a/accounts/page/general_ledger/general_ledger.txt +++ /dev/null @@ -1,41 +0,0 @@ -[ - { - "creation": "2012-09-14 11:25:48", - "docstatus": 0, - "modified": "2013-07-11 14:42:21", - "modified_by": "Administrator", - "owner": "Administrator" - }, - { - "doctype": "Page", - "icon": "icon-table", - "module": "Accounts", - "name": "__common__", - "page_name": "general-ledger", - "standard": "Yes", - "title": "General Ledger" - }, - { - "doctype": "Page Role", - "name": "__common__", - "parent": "general-ledger", - "parentfield": "roles", - "parenttype": "Page" - }, - { - "doctype": "Page", - "name": "general-ledger" - }, - { - "doctype": "Page Role", - "role": "Analytics" - }, - { - "doctype": "Page Role", - "role": "Accounts Manager" - }, - { - "doctype": "Page Role", - "role": "Accounts User" - } -] \ No newline at end of file diff --git a/patches/1312/p01_delete_old_stock_reports.py b/patches/1312/p01_delete_old_stock_reports.py index 17c8947478..eac9b7b844 100644 --- a/patches/1312/p01_delete_old_stock_reports.py +++ b/patches/1312/p01_delete_old_stock_reports.py @@ -7,7 +7,9 @@ def execute(): webnotes.delete_doc('Page', 'stock-ledger') webnotes.delete_doc('Page', 'stock-ageing') webnotes.delete_doc('Page', 'stock-level') + webnotes.delete_doc('Page', 'general-ledger') os.system("rm -rf app/stock/page/stock_ledger") os.system("rm -rf app/stock/page/stock_ageing") - os.system("rm -rf app/stock/page/stock_level") \ No newline at end of file + os.system("rm -rf app/stock/page/stock_level") + os.system("rm -rf app/accounts/page/general_ledger") \ No newline at end of file From a4080eb8400093c312ef9abd97ea3106004b148b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 17:45:50 +0530 Subject: [PATCH 42/80] [fix] [minor] item validation --- stock/doctype/item/item.py | 49 +++++++++++++++----------------------- 1 file changed, 19 insertions(+), 30 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index a4985e9794..b5884b4111 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -4,7 +4,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cstr, flt, cint +from webnotes.utils import cstr, flt from webnotes.model.doc import addchild from webnotes.model.bean import getlist from webnotes import msgprint, _ @@ -116,40 +116,29 @@ class DocType(DocListController, WebsiteGenerator): self.doc.is_pro_applicable = "No" if self.doc.is_pro_applicable == 'Yes' and self.doc.is_stock_item == 'No': - msgprint("As Production Order can be made for this Item, then Is Stock Item Should be 'Yes' as we maintain it's stock. Refer Manufacturing and Inventory section.", raise_exception=1) + webnotes.throw(_("As Production Order can be made for this item, \ + it must be a stock item.")) if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No': msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1) def check_for_active_boms(self): - def _check_for_active_boms(field_label): - if field_label in ['Is Active', 'Is Purchase Item']: - bom_mat = webnotes.conn.sql("""select distinct t1.parent - from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent - and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1 - and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name) - if bom_mat and bom_mat[0][0]: - msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name + - _(" is present in one or many Active BOMs"), raise_exception=1) - - if ((field_label == 'Allow Production Order' - and self.doc.is_sub_contracted_item != 'Yes') - or (field_label == 'Is Sub Contracted Item' - and self.doc.is_manufactured_item != 'Yes')): - bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s - and is_active = 1""", (self.doc.name,)) - if bom and bom[0][0]: - msgprint(_(field_label) + _(" should be 'Yes'. As Item: ") + self.doc.name + - _(" is present in one or many Active BOMs"), raise_exception=1) - - if not cint(self.doc.fields.get("__islocal")): - fl = {'is_manufactured_item' :'Allow Bill of Materials', - 'is_sub_contracted_item':'Is Sub Contracted Item', - 'is_purchase_item' :'Is Purchase Item', - 'is_pro_applicable' :'Allow Production Order'} - for d in fl: - if cstr(self.doc.fields.get(d)) != 'Yes': - _check_for_active_boms(fl[d]) + if self.doc.is_active != "Yes" or self.doc.is_purchase_item != "Yes": + bom_mat = webnotes.conn.sql("""select distinct t1.parent + from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent + and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1 + and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name) + + if bom_mat and bom_mat[0][0]: + webnotes.throw(_("Item must be active and purchase item, \ + as it is present in one or many Active BOMs")) + + if self.doc.is_manufactured_item != "Yes": + bom = webnotes.conn.sql("""select name from `tabBOM` where item = %s + and is_active = 1""", (self.doc.name,)) + if bom and bom[0][0]: + webnotes.throw(_("""Allow Bill of Materials should be 'Yes'. Because one or many \ + active BOMs present for this item""")) def fill_customer_code(self): """ Append all the customer codes and insert into "customer_code" field of item table """ From ceb940ec17a4cd894254fbb0df7bf78cc63513ad Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Dec 2013 17:53:05 +0530 Subject: [PATCH 43/80] [reports] [minor] patch to delete old report files --- patches/1312/p01_delete_old_stock_reports.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/patches/1312/p01_delete_old_stock_reports.py b/patches/1312/p01_delete_old_stock_reports.py index eac9b7b844..e8d620ba33 100644 --- a/patches/1312/p01_delete_old_stock_reports.py +++ b/patches/1312/p01_delete_old_stock_reports.py @@ -2,14 +2,16 @@ # License: GNU General Public License v3. See license.txt def execute(): - import webnotes, os + import webnotes, os, shutil + from webnotes.utils import get_base_path webnotes.delete_doc('Page', 'stock-ledger') webnotes.delete_doc('Page', 'stock-ageing') webnotes.delete_doc('Page', 'stock-level') webnotes.delete_doc('Page', 'general-ledger') - os.system("rm -rf app/stock/page/stock_ledger") - os.system("rm -rf app/stock/page/stock_ageing") - os.system("rm -rf app/stock/page/stock_level") - os.system("rm -rf app/accounts/page/general_ledger") \ No newline at end of file + for d in [["stock", "stock_ledger"], ["stock", "stock_ageing"], + ["stock", "stock_level"], ["accounts", "general_ledger"]]: + path = os.path.join(get_base_path(), "app", d[0], "page", d[1]) + if os.path.exists(path): + shutil.rmtree(path) \ No newline at end of file From 4d806c5fcb544a208f1d11b612d2b8210d08aea8 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 17 Dec 2013 18:33:05 +0600 Subject: [PATCH 44/80] bumped to version 3.3.0 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index bb88d76293..cf1b11c7c9 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.2.3", + "app_version": "3.3.0", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.2.0" + "requires_framework_version": "==3.3.0" } \ No newline at end of file From 0b1a8e13fd5da3b479ee3c3580332d5e4f230798 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Dec 2013 07:53:49 +0530 Subject: [PATCH 45/80] [patch] Email Digest --- patches/1311/p07_scheduler_errors_digest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/patches/1311/p07_scheduler_errors_digest.py b/patches/1311/p07_scheduler_errors_digest.py index 7cfa251847..b1fa78e14f 100644 --- a/patches/1311/p07_scheduler_errors_digest.py +++ b/patches/1311/p07_scheduler_errors_digest.py @@ -5,6 +5,8 @@ from __future__ import unicode_literals import webnotes def execute(): + webnotes.reload_doc("setup", "doctype", "email_digest") + from webnotes.profile import get_system_managers system_managers = get_system_managers(only_name=True) if not system_managers: From c565de2c1232cbc1605ef0a6342f5eb4afd78693 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 18 Dec 2013 10:41:29 +0530 Subject: [PATCH 46/80] Removed schedule_date from no_copy in purchase receipt item --- stock/doctype/purchase_receipt_item/purchase_receipt_item.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt index 22ded6d2c3..9a641c2ba3 100755 --- a/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt +++ b/stock/doctype/purchase_receipt_item/purchase_receipt_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 19:29:10", "docstatus": 0, - "modified": "2013-11-02 19:41:45", + "modified": "2013-12-18 10:38:39", "modified_by": "Administrator", "owner": "Administrator" }, @@ -326,7 +326,7 @@ "fieldname": "schedule_date", "fieldtype": "Date", "label": "Required By", - "no_copy": 1, + "no_copy": 0, "oldfieldname": "schedule_date", "oldfieldtype": "Date", "print_hide": 1, From 677ef0c3cf21911f0e39f269a5674a07cb43c1c6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Dec 2013 10:56:43 +0530 Subject: [PATCH 47/80] [fix] backup manager --- setup/doctype/backup_manager/backup_dropbox.py | 6 +----- setup/doctype/backup_manager/backup_manager.js | 6 +++--- setup/doctype/backup_manager/backup_manager.py | 16 ++++++---------- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/setup/doctype/backup_manager/backup_dropbox.py b/setup/doctype/backup_manager/backup_dropbox.py index bbd33b5e4b..1583f7ebd6 100644 --- a/setup/doctype/backup_manager/backup_dropbox.py +++ b/setup/doctype/backup_manager/backup_dropbox.py @@ -16,8 +16,6 @@ import webnotes from webnotes.utils import get_request_site_address, cstr from webnotes import _ -from backup_manager import ignore_list - @webnotes.whitelist() def get_dropbox_authorize_url(): sess = get_dropbox_session() @@ -100,9 +98,7 @@ def backup_to_dropbox(): path = get_files_path() for filename in os.listdir(path): filename = cstr(filename) - if filename in ignore_list: - continue - + found = False filepath = os.path.join(path, filename) for file_metadata in response["contents"]: diff --git a/setup/doctype/backup_manager/backup_manager.js b/setup/doctype/backup_manager/backup_manager.js index c0117570b5..6fdb9e4f62 100644 --- a/setup/doctype/backup_manager/backup_manager.js +++ b/setup/doctype/backup_manager/backup_manager.js @@ -87,7 +87,7 @@ $.extend(cur_frm.cscript, { cur_frm.save(); }, - upload_backups_to_gdrive: function() { - cur_frm.save(); - }, + // upload_backups_to_gdrive: function() { + // cur_frm.save(); + // }, }); \ No newline at end of file diff --git a/setup/doctype/backup_manager/backup_manager.py b/setup/doctype/backup_manager/backup_manager.py index 0a83dea38b..b09446485e 100644 --- a/setup/doctype/backup_manager/backup_manager.py +++ b/setup/doctype/backup_manager/backup_manager.py @@ -7,8 +7,6 @@ from __future__ import unicode_literals import webnotes from webnotes import _ -ignore_list = [] - class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl @@ -39,10 +37,6 @@ def take_backups_dropbox(): file_and_error = [" - ".join(f) for f in zip(did_not_upload, error_log)] error_message = ("\n".join(file_and_error) + "\n" + webnotes.getTraceback()) webnotes.errprint(error_message) - - if not webnotes.conn: - webnotes.connect() - send_email(False, "Dropbox", error_message) #backup to gdrive @@ -62,6 +56,7 @@ def take_backups_gdrive(): send_email(False, "Google Drive", error_message) def send_email(success, service_name, error_status=None): + from webnotes.utils.email_lib import sendmail if success: subject = "Backup Upload Successful" message ="""

Backup Uploaded Successfully

Hi there, this is just to inform you @@ -76,7 +71,8 @@ def send_email(success, service_name, error_status=None):

Please contact your system manager for more information.

""" % (service_name, error_status) - # email system managers - from webnotes.utils.email_lib import sendmail - sendmail(webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(","), - subject=subject, msg=message) + if not webnotes.conn: + webnotes.connect() + + recipients = webnotes.conn.get_value("Backup Manager", None, "send_notifications_to").split(",") + sendmail(recipients, subject=subject, msg=message) From 797e0713ea2fd22995005deea8f8d0f0a907028f Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Wed, 18 Dec 2013 12:49:28 +0600 Subject: [PATCH 48/80] bumped to version 3.3.1 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index cf1b11c7c9..d7dcbc1aef 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.0", + "app_version": "3.3.1", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.3.0" + "requires_framework_version": "==3.3.1" } \ No newline at end of file From 1fce0b1f79c23a9c938bdc83ccb22e2b43129faa Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 18 Dec 2013 13:22:18 +0530 Subject: [PATCH 49/80] [fix] scheduler error email digest --- patches/1311/p07_scheduler_errors_digest.py | 11 +++++++++- setup/page/setup_wizard/setup_wizard.py | 24 +++++++++++---------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/patches/1311/p07_scheduler_errors_digest.py b/patches/1311/p07_scheduler_errors_digest.py index b1fa78e14f..6811571ab9 100644 --- a/patches/1311/p07_scheduler_errors_digest.py +++ b/patches/1311/p07_scheduler_errors_digest.py @@ -12,11 +12,20 @@ def execute(): if not system_managers: return + # no default company + company = webnotes.conn.get_default("company") + if not company: + company = webnotes.conn.sql_list("select name from `tabCompany`") + if company: + company = company[0] + if not company: + return + # scheduler errors digest edigest = webnotes.new_bean("Email Digest") edigest.doc.fields.update({ "name": "Scheduler Errors", - "company": webnotes.conn.get_default("company"), + "company": company, "frequency": "Daily", "enabled": 1, "recipient_list": "\n".join(system_managers), diff --git a/setup/page/setup_wizard/setup_wizard.py b/setup/page/setup_wizard/setup_wizard.py index b5133ef479..962f600ca2 100644 --- a/setup/page/setup_wizard/setup_wizard.py +++ b/setup/page/setup_wizard/setup_wizard.py @@ -175,7 +175,8 @@ def create_email_digest(): if not system_managers: return - for company in webnotes.conn.sql_list("select name FROM `tabCompany`"): + companies = webnotes.conn.sql_list("select name FROM `tabCompany`") + for company in companies: if not webnotes.conn.exists("Email Digest", "Default Weekly Digest - " + company): edigest = webnotes.bean({ "doctype": "Email Digest", @@ -192,16 +193,17 @@ def create_email_digest(): edigest.insert() # scheduler errors digest - edigest = webnotes.new_bean("Email Digest") - edigest.doc.fields.update({ - "name": "Scheduler Errors", - "company": webnotes.conn.get_default("company"), - "frequency": "Daily", - "recipient_list": "\n".join(system_managers), - "scheduler_errors": 1, - "enabled": 1 - }) - edigest.insert() + if companies: + edigest = webnotes.new_bean("Email Digest") + edigest.doc.fields.update({ + "name": "Scheduler Errors", + "company": companies[0], + "frequency": "Daily", + "recipient_list": "\n".join(system_managers), + "scheduler_errors": 1, + "enabled": 1 + }) + edigest.insert() def get_fy_details(fy_start_date, fy_end_date): start_year = getdate(fy_start_date).year From 2678ed181a04a76934e075fe3d1e5f6734e172fc Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 18 Dec 2013 13:28:40 +0530 Subject: [PATCH 50/80] [fix] [issue] webnotes/erpnext#1191 - set expected delivery date in production order --- .../production_order/production_order.js | 86 ++++++++++--------- .../production_order/production_order.py | 24 +++--- .../production_order/production_order.txt | 10 ++- .../production_planning_tool.py | 1 - patches/patch_list.py | 1 + setup/page/setup_wizard/setup_wizard.py | 4 + 6 files changed, 74 insertions(+), 52 deletions(-) diff --git a/manufacturing/doctype/production_order/production_order.js b/manufacturing/doctype/production_order/production_order.js index 2277262fd2..31900ea57a 100644 --- a/manufacturing/doctype/production_order/production_order.js +++ b/manufacturing/doctype/production_order/production_order.js @@ -1,28 +1,56 @@ // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -cur_frm.cscript.onload = function(doc, dt, dn) { - if (!doc.status) doc.status = 'Draft'; - cfn_set_fields(doc, dt, dn); -} +$.extend(cur_frm.cscript, { + onload: function (doc, dt, dn) { -cur_frm.cscript.refresh = function(doc, dt, dn) { - cur_frm.dashboard.reset(); - erpnext.hide_naming_series(); - cur_frm.set_intro(""); - cfn_set_fields(doc, dt, dn); + if (!doc.status) doc.status = 'Draft'; + cfn_set_fields(doc, dt, dn); - if(doc.docstatus===0 && !doc.__islocal) { - cur_frm.set_intro(wn._("Submit this Production Order for further processing.")); - } else if(doc.docstatus===1) { - var percent = flt(doc.produced_qty) / flt(doc.qty) * 100; - cur_frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent); + this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date"); + }, - if(doc.status === "Stopped") { - cur_frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop"); + refresh: function(doc, dt, dn) { + this.frm.dashboard.reset(); + erpnext.hide_naming_series(); + this.frm.set_intro(""); + cfn_set_fields(doc, dt, dn); + + if (doc.docstatus === 0 && !doc.__islocal) { + this.frm.set_intro(wn._("Submit this Production Order for further processing.")); + } else if (doc.docstatus === 1) { + var percent = flt(doc.produced_qty) / flt(doc.qty) * 100; + this.frm.dashboard.add_progress(cint(percent) + "% " + wn._("Complete"), percent); + + if(doc.status === "Stopped") { + this.frm.dashboard.set_headline_alert(wn._("Stopped"), "alert-danger", "icon-stop"); + } } + }, + + production_item: function(doc) { + return this.frm.call({ + method: "get_item_details", + args: { item: doc.production_item } + }); + }, + + make_se: function(purpose) { + var me = this; + + wn.call({ + method:"manufacturing.doctype.production_order.production_order.make_stock_entry", + args: { + "production_order_id": me.frm.doc.name, + "purpose": purpose + }, + callback: function(r) { + var doclist = wn.model.sync(r.message); + wn.set_route("Form", doclist[0].doctype, doclist[0].name); + } + }); } -} +}); var cfn_set_fields = function(doc, dt, dn) { if (doc.docstatus == 1) { @@ -38,13 +66,6 @@ var cfn_set_fields = function(doc, dt, dn) { } } -cur_frm.cscript.production_item = function(doc) { - return cur_frm.call({ - method: "get_item_details", - args: { item: doc.production_item } - }); -} - cur_frm.cscript['Stop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(wn._("Do you really want to stop production order: " + doc.name)); @@ -57,7 +78,7 @@ cur_frm.cscript['Unstop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(wn._("Do really want to unstop production order: " + doc.name)); if (check) - return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); + return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); } cur_frm.cscript['Transfer Raw Materials'] = function() { @@ -68,20 +89,6 @@ cur_frm.cscript['Update Finished Goods'] = function() { cur_frm.cscript.make_se('Manufacture/Repack'); } -cur_frm.cscript.make_se = function(purpose) { - wn.call({ - method:"manufacturing.doctype.production_order.production_order.make_stock_entry", - args: { - "production_order_id": cur_frm.doc.name, - "purpose": purpose - }, - callback: function(r) { - var doclist = wn.model.sync(r.message); - wn.set_route("Form", doclist[0].doctype, doclist[0].name); - } - }) -} - cur_frm.fields_dict['production_item'].get_query = function(doc) { return { filters:[ @@ -98,7 +105,6 @@ cur_frm.fields_dict['project_name'].get_query = function(doc, dt, dn) { } } - cur_frm.set_query("bom_no", function(doc) { if (doc.production_item) { return{ diff --git a/manufacturing/doctype/production_order/production_order.py b/manufacturing/doctype/production_order/production_order.py index c5b2b04791..bcb13f8a22 100644 --- a/manufacturing/doctype/production_order/production_order.py +++ b/manufacturing/doctype/production_order/production_order.py @@ -8,7 +8,6 @@ from webnotes.utils import cstr, flt, nowdate from webnotes.model.code import get_obj from webnotes import msgprint, _ - class OverProductionError(webnotes.ValidationError): pass class DocType: @@ -37,15 +36,20 @@ class DocType: and is_active=1 and item=%s""" , (self.doc.bom_no, self.doc.production_item), as_dict =1) if not bom: - msgprint("""Incorrect BOM: %s entered. + webnotes.throw("""Incorrect BOM: %s entered. May be BOM not exists or inactive or not submitted - or for some other item.""" % cstr(self.doc.bom_no), raise_exception=1) + or for some other item.""" % cstr(self.doc.bom_no)) def validate_sales_order(self): if self.doc.sales_order: - if not webnotes.conn.sql("""select name from `tabSales Order` - where name=%s and docstatus = 1""", self.doc.sales_order): - msgprint("Sales Order: %s is not valid" % self.doc.sales_order, raise_exception=1) + so = webnotes.conn.sql("""select name, delivery_date from `tabSales Order` + where name=%s and docstatus = 1""", self.doc.sales_order, as_dict=1)[0] + + if not so.name: + webnotes.throw("Sales Order: %s is not valid" % self.doc.sales_order) + + if not self.doc.expected_delivery_date: + self.doc.expected_delivery_date = so.delivery_date self.validate_production_order_against_so() @@ -76,11 +80,11 @@ class DocType: so_qty = flt(so_item_qty) + flt(dnpi_qty) if total_qty > so_qty: - webnotes.msgprint(_("Total production order qty for item") + ": " + + webnotes.throw(_("Total production order qty for item") + ": " + cstr(self.doc.production_item) + _(" against sales order") + ": " + cstr(self.doc.sales_order) + _(" will be ") + cstr(total_qty) + ", " + _("which is greater than sales order qty ") + "(" + cstr(so_qty) + ")" + - _("Please reduce qty."), raise_exception=OverProductionError) + _("Please reduce qty."), exc=OverProductionError) def stop_unstop(self, status): """ Called from client side on Stop/Unstop event""" @@ -114,8 +118,8 @@ class DocType: stock_entry = webnotes.conn.sql("""select name from `tabStock Entry` where production_order = %s and docstatus = 1""", self.doc.name) if stock_entry: - msgprint("""Submitted Stock Entry %s exists against this production order. - Hence can not be cancelled.""" % stock_entry[0][0], raise_exception=1) + webnotes.throw("""Submitted Stock Entry %s exists against this production order. + Hence can not be cancelled.""" % stock_entry[0][0]) webnotes.conn.set(self.doc,'status', 'Cancelled') self.update_planned_qty(-self.doc.qty) diff --git a/manufacturing/doctype/production_order/production_order.txt b/manufacturing/doctype/production_order/production_order.txt index 85c7c83881..5e76c0e18f 100644 --- a/manufacturing/doctype/production_order/production_order.txt +++ b/manufacturing/doctype/production_order/production_order.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-10 16:34:16", "docstatus": 0, - "modified": "2013-11-02 14:05:44", + "modified": "2013-12-18 13:22:14", "modified_by": "Administrator", "owner": "Administrator" }, @@ -136,6 +136,14 @@ "oldfieldtype": "Currency", "read_only": 1 }, + { + "depends_on": "sales_order", + "doctype": "DocField", + "fieldname": "expected_delivery_date", + "fieldtype": "Date", + "label": "Expected Delivery Date", + "read_only": 1 + }, { "doctype": "DocField", "fieldname": "warehouses", diff --git a/manufacturing/doctype/production_planning_tool/production_planning_tool.py b/manufacturing/doctype/production_planning_tool/production_planning_tool.py index c1185a1b12..29232f5f51 100644 --- a/manufacturing/doctype/production_planning_tool/production_planning_tool.py +++ b/manufacturing/doctype/production_planning_tool/production_planning_tool.py @@ -186,7 +186,6 @@ class DocType: else : msgprint(_("No Production Order created.")) - def get_distinct_items_and_boms(self): """ Club similar BOM and item for processing bom_dict { diff --git a/patches/patch_list.py b/patches/patch_list.py index 9400e08872..1e5f1dee0f 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -258,4 +258,5 @@ patch_list = [ "execute:webnotes.delete_doc('Report', 'Stock Ledger') #2013-11-29", "execute:webnotes.delete_doc('Report', 'Payment Collection With Ageing')", "execute:webnotes.delete_doc('Report', 'Payment Made With Ageing')", + "execute:webnotes.delete_doc('DocType', 'Warehouse Type')", ] \ No newline at end of file diff --git a/setup/page/setup_wizard/setup_wizard.py b/setup/page/setup_wizard/setup_wizard.py index bf149059a1..e431b2ad5e 100644 --- a/setup/page/setup_wizard/setup_wizard.py +++ b/setup/page/setup_wizard/setup_wizard.py @@ -158,6 +158,10 @@ def set_defaults(args): hr_settings.doc.emp_created_by = "Naming Series" hr_settings.save() + email_settings = webnotes.bean("Email Settings") + email_settings.doc.send_print_in_body_and_attachment = 1 + email_settings.save() + # control panel cp = webnotes.doc("Control Panel", "Control Panel") cp.company_name = args["company_name"] From b645a217fd5c26017bf2360acd27ea79aeb07c43 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Wed, 18 Dec 2013 15:10:36 +0600 Subject: [PATCH 51/80] bumped to version 3.3.2 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index d7dcbc1aef..68782da730 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.1", + "app_version": "3.3.2", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From fcbd4d7638169eba6bc940d96d15d33b16a8a52f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 18 Dec 2013 14:53:36 +0530 Subject: [PATCH 52/80] Removed sales_order_no from no_copy in material request item --- stock/doctype/material_request_item/material_request_item.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/material_request_item/material_request_item.txt b/stock/doctype/material_request_item/material_request_item.txt index 15884a3b5e..e0b9330baa 100644 --- a/stock/doctype/material_request_item/material_request_item.txt +++ b/stock/doctype/material_request_item/material_request_item.txt @@ -2,7 +2,7 @@ { "creation": "2013-02-22 01:28:02", "docstatus": 0, - "modified": "2013-11-03 20:36:45", + "modified": "2013-12-18 14:52:02", "modified_by": "Administrator", "owner": "Administrator" }, @@ -219,7 +219,7 @@ "fieldname": "sales_order_no", "fieldtype": "Link", "label": "Sales Order No", - "no_copy": 1, + "no_copy": 0, "options": "Sales Order", "print_hide": 1, "read_only": 1 From 48156e3d8b89f0bc9baf94f098208bcb48469bde Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 18 Dec 2013 18:51:20 +0530 Subject: [PATCH 53/80] fixes in stock projected qty report --- stock/report/stock_projected_qty/stock_projected_qty.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py index 11d519558d..d116d03b59 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.py +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -26,10 +26,10 @@ def execute(filters=None): def get_columns(): return ["Item Code:Link/Item:140", "Item Name::100", "Description::200", - "Brand:Link/Brand:100", "Warehouse:Link/Warehouse:120", "UOM:Link/UOM:100", - "Actual Qty:Float:100", "Planned Qty:Float:100", "Requested Qty:Float:110", - "Ordered Qty:Float:100", "Reserved Qty:Float:100", "Projected Qty:Float:100", - "Reorder Level:Float:100", "Reorder Qty:Float:100"] + "Item Group:Link/Item Group:100", "Brand:Link/Brand:100", "Warehouse:Link/Warehouse:120", + "UOM:Link/UOM:100", "Actual Qty:Float:100", "Planned Qty:Float:100", + "Requested Qty:Float:110", "Ordered Qty:Float:100", "Reserved Qty:Float:100", + "Projected Qty:Float:100", "Reorder Level:Float:100", "Reorder Qty:Float:100"] def get_item_conditions(filters): conditions = [] From 85800fa92944c10a561732b2f9db86b05e26097f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 19 Dec 2013 10:57:43 +0530 Subject: [PATCH 54/80] fixes in item validation --- stock/doctype/item/item.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index b5884b4111..01f1d9f38f 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -123,14 +123,14 @@ class DocType(DocListController, WebsiteGenerator): msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1) def check_for_active_boms(self): - if self.doc.is_active != "Yes" or self.doc.is_purchase_item != "Yes": + if self.doc.is_purchase_item != "Yes": bom_mat = webnotes.conn.sql("""select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2 where t2.name = t1.parent and t1.item_code =%s and ifnull(t1.bom_no, '') = '' and t2.is_active = 1 and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name) if bom_mat and bom_mat[0][0]: - webnotes.throw(_("Item must be active and purchase item, \ + webnotes.throw(_("Item must be a purchase item, \ as it is present in one or many Active BOMs")) if self.doc.is_manufactured_item != "Yes": From fe6409debfda613528059377dc46ea9e929caf43 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 19 Dec 2013 11:41:10 +0530 Subject: [PATCH 55/80] fix company email digest patch --- patches/1311/p07_scheduler_errors_digest.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/patches/1311/p07_scheduler_errors_digest.py b/patches/1311/p07_scheduler_errors_digest.py index 6811571ab9..4527f18725 100644 --- a/patches/1311/p07_scheduler_errors_digest.py +++ b/patches/1311/p07_scheduler_errors_digest.py @@ -13,11 +13,9 @@ def execute(): return # no default company - company = webnotes.conn.get_default("company") - if not company: - company = webnotes.conn.sql_list("select name from `tabCompany`") - if company: - company = company[0] + company = webnotes.conn.sql_list("select name from `tabCompany`") + if company: + company = company[0] if not company: return @@ -31,4 +29,4 @@ def execute(): "recipient_list": "\n".join(system_managers), "scheduler_errors": 1 }) - edigest.insert() \ No newline at end of file + edigest.insert() From 1644fce273b7baa78d74ed4a74416035783df29d Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 19 Dec 2013 12:12:38 +0600 Subject: [PATCH 56/80] bumped to version 3.3.3 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 68782da730..07b0a13c90 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.2", + "app_version": "3.3.3", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 88eedb7397a9e8bfa7cd18203846539a737e8ede Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 19 Dec 2013 14:07:39 +0530 Subject: [PATCH 57/80] Send Email Digest, only if there is atleast one update for selected categories --- setup/doctype/email_digest/email_digest.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/setup/doctype/email_digest/email_digest.py b/setup/doctype/email_digest/email_digest.py index 082b92fb7f..f01c8a8489 100644 --- a/setup/doctype/email_digest/email_digest.py +++ b/setup/doctype/email_digest/email_digest.py @@ -9,6 +9,7 @@ from webnotes.utils import fmt_money, formatdate, now_datetime, cstr, esc, \ from webnotes.utils.dateutils import datetime_in_user_format from datetime import timedelta from dateutil.relativedelta import relativedelta +from webnotes.utils.email_lib import sendmail content_sequence = [ ["Income / Expenses", ["income_year_to_date", "bank_balance", @@ -80,15 +81,15 @@ class DocType(DocListController): for user_id in recipients: msg_for_this_receipient = self.get_msg_html(self.get_user_specific_content(user_id) + \ common_msg) - from webnotes.utils.email_lib import sendmail - sendmail(recipients=user_id, - subject="[ERPNext] [{frequency} Digest] {name}".format( - frequency=self.doc.frequency, name=self.doc.name), - msg=msg_for_this_receipient) + if msg_for_this_receipient: + sendmail(recipients=user_id, + subject="[ERPNext] [{frequency} Digest] {name}".format( + frequency=self.doc.frequency, name=self.doc.name), + msg=msg_for_this_receipient) def get_digest_msg(self): return self.get_msg_html(self.get_user_specific_content(webnotes.session.user) + \ - self.get_common_content()) + self.get_common_content(), send_only_if_updates=False) def get_common_content(self): out = [] @@ -119,14 +120,19 @@ class DocType(DocListController): return out - def get_msg_html(self, out): + def get_msg_html(self, out, send_only_if_updates=True): with_value = [o[1] for o in out if o[0]] if with_value: + has_updates = True with_value = "\n".join(with_value) else: + has_updates = False with_value = "

There were no updates in the items selected for this digest.


" + if not has_updates and send_only_if_updates: + return + # seperate out no value items no_value = [o[1] for o in out if not o[0]] if no_value: From 2a9e4e9a32e0906227caa8cc77620f9eb6dcea37 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 19 Dec 2013 19:11:53 +0530 Subject: [PATCH 58/80] Opening and closing balance in general ledger report --- .../purchase_invoice/purchase_invoice.js | 2 +- .../doctype/sales_invoice/sales_invoice.js | 2 +- .../report/general_ledger/general_ledger.py | 33 +++++++++++++++---- stock/report/stock_ledger/stock_ledger.py | 8 +++-- .../stock_projected_qty.py | 2 +- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index 9d752647ad..fc530ddee3 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -36,7 +36,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ "from_date": doc.posting_date, "to_date": doc.posting_date, }; - wn.set_route("general-ledger"); + wn.set_route("query-report/General Ledger"); }, "icon-table"); } diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 7784005578..55f6ddecec 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -55,7 +55,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte "from_date": doc.posting_date, "to_date": doc.posting_date, }; - wn.set_route("general-ledger"); + wn.set_route("query-report/General Ledger"); }, "icon-table"); var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100); diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index fcf8010715..bf07e25767 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -3,20 +3,24 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import flt +from webnotes.utils import flt, add_days from webnotes import _ +from accounts.utils import get_balance_on def execute(filters=None): validate_filters(filters) columns = get_columns() - + data = [] if filters.get("group_by"): - data = get_grouped_gle(filters) + data += get_grouped_gle(filters) else: - data = get_gl_entries(filters) + data += get_gl_entries(filters) if data: data.append(get_total_row(data)) + if filters.get("account"): + data = [get_opening_balance_row(filters)] + data + [get_closing_balance_row(filters)] + return columns, data def validate_filters(filters): @@ -27,12 +31,20 @@ def validate_filters(filters): webnotes.throw(_("Can not filter based on Voucher No, if grouped by Voucher")) def get_columns(): - return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Currency:100", - "Credit:Currency:100", "Voucher Type::120", "Voucher No::160", + return ["Posting Date:Date:100", "Account:Link/Account:200", "Debit:Float:100", + "Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20", "Cost Center:Link/Cost Center:100", "Remarks::200"] +def get_opening_balance_row(filters): + opening_balance = get_balance_on(filters["account"], add_days(filters["from_date"], -1)) + return ["", "Opening Balance", opening_balance, 0.0, "", "", ""] + +def get_closing_balance_row(filters): + closing_balance = get_balance_on(filters["account"], filters["to_date"]) + return ["", "Closing Balance", closing_balance, 0.0, "", "", ""] + def get_gl_entries(filters): - return webnotes.conn.sql("""select + gl_entries = webnotes.conn.sql("""select posting_date, account, debit, credit, voucher_type, voucher_no, cost_center, remarks from `tabGL Entry` where company=%(company)s @@ -40,6 +52,13 @@ def get_gl_entries(filters): {conditions} order by posting_date, account"""\ .format(conditions=get_conditions(filters)), filters, as_list=1) + + for d in gl_entries: + icon = """""" \ + % ("/".join(["#Form", d[4], d[5]]),) + d.insert(6, icon) + + return gl_entries def get_conditions(filters): conditions = [] diff --git a/stock/report/stock_ledger/stock_ledger.py b/stock/report/stock_ledger/stock_ledger.py index ea1a60fac2..034884b12e 100644 --- a/stock/report/stock_ledger/stock_ledger.py +++ b/stock/report/stock_ledger/stock_ledger.py @@ -13,10 +13,14 @@ def execute(filters=None): data = [] for sle in sl_entries: item_detail = item_details[sle.item_code] + voucher_link_icon = """""" \ + % ("/".join(["#Form", sle.voucher_type, sle.voucher_no]),) + data.append([sle.date, sle.item_code, item_detail.item_name, item_detail.item_group, item_detail.brand, item_detail.description, sle.warehouse, item_detail.stock_uom, sle.actual_qty, sle.qty_after_transaction, sle.stock_value, sle.voucher_type, - sle.voucher_no, sle.batch_no, sle.serial_no, sle.company]) + sle.voucher_no, voucher_link_icon, sle.batch_no, sle.serial_no, sle.company]) return columns, data @@ -25,7 +29,7 @@ def get_columns(): "Item Group:Link/Item Group:100", "Brand:Link/Brand:100", "Description::200", "Warehouse:Link/Warehouse:100", "Stock UOM:Link/UOM:100", "Qty:Float:50", "Balance Qty:Float:80", - "Balance Value:Currency:100", "Voucher Type::100", "Voucher #::100", + "Balance Value:Currency:100", "Voucher Type::100", "Voucher #::100", "Link::30", "Batch:Link/Batch:100", "Serial #:Link/Serial No:100", "Company:Link/Company:100"] def get_stock_ledger_entries(filters): diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py index d116d03b59..0572f7961e 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.py +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -20,7 +20,7 @@ def execute(filters=None): where item_code = item.name and warehouse = wh.name order by item.name, wh.name"""\ .format(item_conditions=get_item_conditions(filters), - warehouse_conditions=get_warehouse_conditions(filters)), filters, debug=1) + warehouse_conditions=get_warehouse_conditions(filters)), filters) return columns, data From 104deeebb5622eebeb39ed1e29ba2f71083dbc28 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 19 Dec 2013 19:16:00 +0530 Subject: [PATCH 59/80] reload packed item in patch, for migration from slow branch --- patches/july_2013/p07_repost_billed_amt_in_sales_cycle.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patches/july_2013/p07_repost_billed_amt_in_sales_cycle.py b/patches/july_2013/p07_repost_billed_amt_in_sales_cycle.py index 64193155d7..95004c0362 100644 --- a/patches/july_2013/p07_repost_billed_amt_in_sales_cycle.py +++ b/patches/july_2013/p07_repost_billed_amt_in_sales_cycle.py @@ -5,7 +5,8 @@ from __future__ import unicode_literals def execute(): import webnotes + webnotes.reload_doc('stock', 'doctype', 'packed_item') for si in webnotes.conn.sql("""select name from `tabSales Invoice` where docstatus = 1"""): webnotes.get_obj("Sales Invoice", si[0], with_children=1).update_qty(change_modified=False) - webnotes.conn.commit() \ No newline at end of file + webnotes.conn.commit() From 1c2bbd77a05c4a0fe7ecf9708ed080339a3c13f2 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Thu, 19 Dec 2013 19:48:56 +0600 Subject: [PATCH 60/80] bumped to version 3.3.4 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 07b0a13c90..f1f433e990 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.3", + "app_version": "3.3.4", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From a888e29b0ace0522a8f39484bd50a938da540328 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Dec 2013 12:18:37 +0530 Subject: [PATCH 61/80] Fixes in stock projected qty report --- stock/report/stock_ledger/stock_ledger.py | 8 -------- .../report/stock_projected_qty/stock_projected_qty.js | 4 +--- .../report/stock_projected_qty/stock_projected_qty.py | 10 ++++++++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/stock/report/stock_ledger/stock_ledger.py b/stock/report/stock_ledger/stock_ledger.py index 034884b12e..b2bc64f009 100644 --- a/stock/report/stock_ledger/stock_ledger.py +++ b/stock/report/stock_ledger/stock_ledger.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import webnotes -from webnotes import _ def execute(filters=None): columns = get_columns() @@ -33,13 +32,6 @@ def get_columns(): "Batch:Link/Batch:100", "Serial #:Link/Serial No:100", "Company:Link/Company:100"] def get_stock_ledger_entries(filters): - if not filters.get("company"): - webnotes.throw(_("Company is mandatory")) - if not filters.get("from_date"): - webnotes.throw(_("From Date is mandatory")) - if not filters.get("to_date"): - webnotes.throw(_("To Date is mandatory")) - return webnotes.conn.sql("""select concat_ws(" ", posting_date, posting_time) as date, item_code, warehouse, actual_qty, qty_after_transaction, stock_value, voucher_type, voucher_no, batch_no, serial_no, company diff --git a/stock/report/stock_projected_qty/stock_projected_qty.js b/stock/report/stock_projected_qty/stock_projected_qty.js index a0ad755ed0..8c25e5d88a 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.js +++ b/stock/report/stock_projected_qty/stock_projected_qty.js @@ -7,9 +7,7 @@ wn.query_reports["Stock Projected Qty"] = { "fieldname":"company", "label": wn._("Company"), "fieldtype": "Link", - "options": "Company", - "default": wn.defaults.get_user_default("company"), - "reqd": 1 + "options": "Company" }, { "fieldname":"warehouse", diff --git a/stock/report/stock_projected_qty/stock_projected_qty.py b/stock/report/stock_projected_qty/stock_projected_qty.py index 0572f7961e..d335ebf846 100644 --- a/stock/report/stock_projected_qty/stock_projected_qty.py +++ b/stock/report/stock_projected_qty/stock_projected_qty.py @@ -13,7 +13,7 @@ def execute(filters=None): projected_qty, item.re_order_level, item.re_order_qty from `tabBin` bin, (select name, company from tabWarehouse - where company=%(company)s {warehouse_conditions}) wh, + {warehouse_conditions}) wh, (select name, item_name, description, stock_uom, item_group, brand, re_order_level, re_order_qty from `tabItem` {item_conditions}) item @@ -41,4 +41,10 @@ def get_item_conditions(filters): return "where {}".format(" and ".join(conditions)) if conditions else "" def get_warehouse_conditions(filters): - return " and name=%(warehouse)s" if filters.get("warehouse") else "" \ No newline at end of file + conditions = [] + if filters.get("company"): + conditions.append("company=%(company)s") + if filters.get("warehouse"): + conditions.append("name=%(warehouse)s") + + return "where {}".format(" and ".join(conditions)) if conditions else "" \ No newline at end of file From 4b5ced03ec1220a03726271664baa11dc9039e0e Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 20 Dec 2013 12:26:48 +0530 Subject: [PATCH 62/80] Fixes in merge functions --- accounts/doctype/account/account.py | 3 +++ stock/doctype/item/item.py | 3 +++ stock/doctype/warehouse/warehouse.py | 3 +++ 3 files changed, 9 insertions(+) diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index cae202847b..0640ad9783 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -211,6 +211,9 @@ class DocType: # Validate properties before merging if merge: + if not webnotes.conn.exists("Account", new): + webnotes.throw(_("Account ") + new +_(" does not exists")) + val = list(webnotes.conn.get_value("Account", new_account, ["group_or_ledger", "debit_or_credit", "is_pl_account"])) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 01f1d9f38f..8dbfef7bac 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -246,6 +246,9 @@ class DocType(DocListController, WebsiteGenerator): def before_rename(self, olddn, newdn, merge=False): if merge: # Validate properties before merging + if not webnotes.conn.exists("Item", newdn): + webnotes.throw(_("Item ") + newdn +_(" does not exists")) + field_list = ["stock_uom", "is_stock_item", "has_serial_no", "has_batch_no"] new_properties = [cstr(d) for d in webnotes.conn.get_value("Item", newdn, field_list)] if new_properties != [cstr(self.doc.fields[fld]) for fld in field_list]: diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 3559960d22..8b1b5b5a1d 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -84,6 +84,9 @@ class DocType: new_warehouse = get_name_with_abbr(newdn, self.doc.company) if merge: + if not webnotes.conn.exists("Warehouse", newdn): + webnotes.throw(_("Warehouse ") + newdn +_(" does not exists")) + if self.doc.company != webnotes.conn.get_value("Warehouse", new_warehouse, "company"): webnotes.throw(_("Both Warehouse must belong to same Company")) From 8709c51e84dff692e19e4bbdd122e45f58317c3a Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Fri, 20 Dec 2013 15:45:45 +0600 Subject: [PATCH 63/80] bumped to version 3.3.5 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index f1f433e990..45f8e276bc 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.4", + "app_version": "3.3.5", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 861453279d757792598bdb3fe378a4fb18cb2e84 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 12:14:45 +0530 Subject: [PATCH 64/80] Incoming rate for stock ledger entry should not be rounded --- .../purchase_invoice/purchase_invoice.py | 23 +++++++++---------- accounts/general_ledger.py | 2 +- controllers/buying_controller.py | 15 ++++++------ .../delivery_note/test_delivery_note.py | 9 ++------ stock/report/item_prices/item_prices.py | 12 ++++++++-- stock/stock_ledger.py | 9 +++++++- 6 files changed, 39 insertions(+), 31 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 6c71fff527..404627af25 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -350,7 +350,7 @@ class DocType(BuyingController): # item gl entries stock_item_and_auto_accounting_for_stock = False stock_items = self.get_stock_items() - rounding_diff = 0.0 + # rounding_diff = 0.0 for item in self.doclist.get({"parentfield": "entries"}): if auto_accounting_for_stock and item.item_code in stock_items: if flt(item.valuation_rate): @@ -359,13 +359,12 @@ class DocType(BuyingController): # expense will be booked in sales invoice stock_item_and_auto_accounting_for_stock = True - valuation_amt = flt(flt(item.valuation_rate) * flt(item.qty) * \ - flt(item.conversion_factor), self.precision("valuation_rate", item)) + valuation_amt = item.amount + item.item_tax_amount + item.rm_supp_cost - rounding_diff += (flt(item.amount, self.precision("amount", item)) + - flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + - flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) - - valuation_amt) + # rounding_diff += (flt(item.amount, self.precision("amount", item)) + + # flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + + # flt(item.rm_supp_cost, self.precision("rm_supp_cost", item)) - + # valuation_amt) gl_entries.append( self.get_gl_dict({ @@ -394,11 +393,11 @@ class DocType(BuyingController): expenses_included_in_valuation = \ self.get_company_default("expenses_included_in_valuation") - if rounding_diff: - import operator - cost_center_with_max_value = max(valuation_tax.iteritems(), - key=operator.itemgetter(1))[0] - valuation_tax[cost_center_with_max_value] -= flt(rounding_diff) + # if rounding_diff: + # import operator + # cost_center_with_max_value = max(valuation_tax.iteritems(), + # key=operator.itemgetter(1))[0] + # valuation_tax[cost_center_with_max_value] -= flt(rounding_diff) for cost_center, amount in valuation_tax.items(): gl_entries.append( diff --git a/accounts/general_ledger.py b/accounts/general_ledger.py index bc0ac1d93c..575a2b02c6 100644 --- a/accounts/general_ledger.py +++ b/accounts/general_ledger.py @@ -45,7 +45,7 @@ def merge_similar_entries(gl_map): same_head.credit = flt(same_head.credit) + flt(entry.credit) else: merged_gl_map.append(entry) - + # filter zero debit and credit entries merged_gl_map = filter(lambda x: flt(x.debit)!=0 or flt(x.credit)!=0, merged_gl_map) return merged_gl_map diff --git a/controllers/buying_controller.py b/controllers/buying_controller.py index b52d51cf31..35b9d25279 100644 --- a/controllers/buying_controller.py +++ b/controllers/buying_controller.py @@ -108,10 +108,11 @@ class BuyingController(StockController): item.import_amount = flt(item.import_rate * item.qty, self.precision("import_amount", item)) item.item_tax_amount = 0.0; - + + self._set_in_company_currency(item, "import_amount", "amount") self._set_in_company_currency(item, "import_ref_rate", "purchase_ref_rate") self._set_in_company_currency(item, "import_rate", "rate") - self._set_in_company_currency(item, "import_amount", "amount") + def calculate_net_total(self): self.doc.net_total = self.doc.net_total_import = 0.0 @@ -183,14 +184,12 @@ class BuyingController(StockController): if item.item_code and item.qty: self.round_floats_in(item) - - purchase_rate = item.rate if self.doc.doctype == "Purchase Invoice" else item.purchase_rate - + # if no item code, which is sometimes the case in purchase invoice, # then it is not possible to track valuation against it - item.valuation_rate = flt((purchase_rate + - (item.item_tax_amount + item.rm_supp_cost) / item.qty) / item.conversion_factor, - self.precision("valuation_rate", item)) + qty_in_stock_uom = flt(item.qty * item.conversion_factor) + item.valuation_rate = ((item.amount + item.item_tax_amount + item.rm_supp_cost) + / qty_in_stock_uom) else: item.valuation_rate = 0.0 diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py index 64ddff80e6..ae69db6b54 100644 --- a/stock/doctype/delivery_note/test_delivery_note.py +++ b/stock/doctype/delivery_note/test_delivery_note.py @@ -58,11 +58,6 @@ class TestDeliveryNote(unittest.TestCase): self.assertEqual(stock_value, 0) self.assertEqual(stock_value_difference, -375) - - gl_entries = webnotes.conn.sql("""select account, debit, credit - from `tabGL Entry` where voucher_type='Delivery Note' and voucher_no=%s - order by account desc""", dn.doc.name, as_dict=1) - self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) def test_delivery_note_gl_entry(self): @@ -111,8 +106,8 @@ class TestDeliveryNote(unittest.TestCase): gl_entries = get_gl_entries("Delivery Note", dn.doc.name) self.assertTrue(gl_entries) expected_values = { - stock_in_hand_account: [0.0, 666.65], - "Cost of Goods Sold - _TC": [666.65, 0.0] + stock_in_hand_account: [0.0, 666.67], + "Cost of Goods Sold - _TC": [666.67, 0.0] } for i, gle in enumerate(gl_entries): self.assertEquals([gle.debit, gle.credit], expected_values.get(gle.account)) diff --git a/stock/report/item_prices/item_prices.py b/stock/report/item_prices/item_prices.py index 9a25c13dfe..da8b5007d5 100644 --- a/stock/report/item_prices/item_prices.py +++ b/stock/report/item_prices/item_prices.py @@ -15,8 +15,8 @@ def execute(filters=None): bom_rate = get_item_bom_rate() val_rate_map = get_valuation_rate() - precision = webnotes.conn.get_value("Global Defaults", None, "float_precision") or 2 - + precision = get_currency_precision or 2 + data = [] for item in sorted(item_map): data.append([item, item_map[item]["item_name"], @@ -30,6 +30,14 @@ def execute(filters=None): ]) return columns, data + +def get_currency_precision(): + company_currency = webnotes.conn.get_value("Company", + webnotes.conn.get_default("company"), "default_currency") + currency_format = webnotes.conn.get_value("Currency", company_currency, "number_format") + + from webnotes.utils import get_number_format_info + return get_number_format_info(currency_format)[2] def get_columns(filters): """return columns based on filters""" diff --git a/stock/stock_ledger.py b/stock/stock_ledger.py index 870274413f..980dcd6d44 100644 --- a/stock/stock_ledger.py +++ b/stock/stock_ledger.py @@ -113,7 +113,14 @@ def update_entries_after(args, verbose=1): (qty_after_transaction * valuation_rate) or 0 else: stock_value = sum((flt(batch[0]) * flt(batch[1]) for batch in stock_queue)) - + + # rounding as per precision + from webnotes.model.meta import get_field_precision + meta = webnotes.get_doctype("Stock Ledger Entry") + + stock_value = flt(stock_value, get_field_precision(meta.get_field("stock_value"), + webnotes._dict({"fields": sle}))) + stock_value_difference = stock_value - prev_stock_value prev_stock_value = stock_value From a0212d8014fc1a7f0c8a188679257fbc2b107c99 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 12:21:14 +0530 Subject: [PATCH 65/80] Fixes in Stock ageing report --- stock/report/stock_ageing/stock_ageing.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stock/report/stock_ageing/stock_ageing.py b/stock/report/stock_ageing/stock_ageing.py index defe7248d2..1a84f939d3 100644 --- a/stock/report/stock_ageing/stock_ageing.py +++ b/stock/report/stock_ageing/stock_ageing.py @@ -67,7 +67,7 @@ def get_stock_ledger_entries(filters): item.name, item.item_name, item_group, brand, description, item.stock_uom, actual_qty, posting_date from `tabStock Ledger Entry` sle, - (select name, item_name, description, stock_uom, brand + (select name, item_name, description, stock_uom, brand, item_group from `tabItem` {item_conditions}) item where item_code = item.name and company = %(company)s and From 7d7661c9ed5c960a1a07b3d801d08f48f42feb7e Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 23 Dec 2013 15:11:05 +0600 Subject: [PATCH 66/80] bumped to version 3.3.6 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 45f8e276bc..23561d588b 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.5", + "app_version": "3.3.6", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From af30c3fdfde8e0a4bfb7d207d515111de49427e2 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 23 Dec 2013 16:13:42 +0530 Subject: [PATCH 67/80] [fix] [minor] update item price on change of item details --- stock/doctype/item/item.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index 8dbfef7bac..ca2a6132d7 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -49,6 +49,7 @@ class DocType(DocListController, WebsiteGenerator): def on_update(self): self.validate_name_with_item_group() self.update_website() + self.update_item_price() def check_warehouse_is_set_for_stock_item(self): if self.doc.is_stock_item=="Yes" and not self.doc.default_warehouse: @@ -210,6 +211,11 @@ class DocType(DocListController, WebsiteGenerator): WebsiteGenerator.on_update(self) + def update_item_price(self): + webnotes.conn.sql("""update `tabItem Price` set item_name=%s, + item_description=%s where item_code=%s""", + (self.doc.item_name, self.doc.description, self.doc.name)) + def get_page_title(self): if self.doc.name==self.doc.item_name: page_name_from = self.doc.name From 61da43f7936c5339db1de007eb4be600b4c95494 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Mon, 23 Dec 2013 16:24:33 +0530 Subject: [PATCH 68/80] [fix] [minor] update modified date and time to item price when updating item and price list --- stock/doctype/item/item.py | 2 +- stock/doctype/price_list/price_list.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stock/doctype/item/item.py b/stock/doctype/item/item.py index ca2a6132d7..4ebf9c49d9 100644 --- a/stock/doctype/item/item.py +++ b/stock/doctype/item/item.py @@ -213,7 +213,7 @@ class DocType(DocListController, WebsiteGenerator): def update_item_price(self): webnotes.conn.sql("""update `tabItem Price` set item_name=%s, - item_description=%s where item_code=%s""", + item_description=%s, modified=NOW() where item_code=%s""", (self.doc.item_name, self.doc.description, self.doc.name)) def get_page_title(self): diff --git a/stock/doctype/price_list/price_list.py b/stock/doctype/price_list/price_list.py index 226b9da8e1..d0e5d2b6d4 100644 --- a/stock/doctype/price_list/price_list.py +++ b/stock/doctype/price_list/price_list.py @@ -44,5 +44,5 @@ class DocType(DocListController): def update_item_price(self): webnotes.conn.sql("""update `tabItem Price` set currency=%s, - buying_or_selling=%s where price_list=%s""", + buying_or_selling=%s, modified=NOW() where price_list=%s""", (self.doc.currency, self.doc.buying_or_selling, self.doc.name)) \ No newline at end of file From 20dc79ac99b0eab69a9030d44ac9adc23d849089 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 17:06:10 +0530 Subject: [PATCH 69/80] General ledger filter by account group --- .../report/general_ledger/general_ledger.py | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index bf07e25767..e76c0c4bf9 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -8,7 +8,9 @@ from webnotes import _ from accounts.utils import get_balance_on def execute(filters=None): - validate_filters(filters) + account_details = webnotes.conn.get_value("Account", filters["account"], + ["debit_or_credit", "group_or_ledger"], as_dict=True) + validate_filters(filters, account_details.group_or_ledger) columns = get_columns() data = [] if filters.get("group_by"): @@ -19,12 +21,13 @@ def execute(filters=None): data.append(get_total_row(data)) if filters.get("account"): - data = [get_opening_balance_row(filters)] + data + [get_closing_balance_row(filters)] + data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \ + [get_closing_balance_row(filters, account_details.debit_or_credit)] return columns, data -def validate_filters(filters): - if filters.get("account") and filters.get("group_by") == "Group by Account": +def validate_filters(filters, group_or_ledger): + if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account": webnotes.throw(_("Can not filter based on Account, if grouped by Account")) if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher": @@ -35,13 +38,19 @@ def get_columns(): "Credit:Float:100", "Voucher Type::120", "Voucher No::160", "Link::20", "Cost Center:Link/Cost Center:100", "Remarks::200"] -def get_opening_balance_row(filters): +def get_opening_balance_row(filters, debit_or_credit): opening_balance = get_balance_on(filters["account"], add_days(filters["from_date"], -1)) - return ["", "Opening Balance", opening_balance, 0.0, "", "", ""] + return get_balance_row(opening_balance, debit_or_credit, "Opening Balance") -def get_closing_balance_row(filters): +def get_closing_balance_row(filters, debit_or_credit): closing_balance = get_balance_on(filters["account"], filters["to_date"]) - return ["", "Closing Balance", closing_balance, 0.0, "", "", ""] + return get_balance_row(closing_balance, debit_or_credit, "Closing Balance") + +def get_balance_row(balance, debit_or_credit, balance_label): + if debit_or_credit == "Debit": + return ["", balance_label, balance, 0.0, "", "", ""] + else: + return ["", balance_label, 0.0, balance, "", "", ""] def get_gl_entries(filters): gl_entries = webnotes.conn.sql("""select @@ -63,7 +72,9 @@ def get_gl_entries(filters): def get_conditions(filters): conditions = [] if filters.get("account"): - conditions.append("account=%(account)s") + lft, rgt = webnotes.conn.get_value("Account", filters["account"], ["lft", "rgt"]) + conditions.append("""account in (select name from tabAccount + where lft>=%s and rgt<=%s and docstatus<2)""" % (lft, rgt)) if filters.get("voucher_no"): conditions.append("voucher_no=%(voucher_no)s") From facde47c6cad74386f8b9fc1cba8ba8fae54dcc3 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 17:06:46 +0530 Subject: [PATCH 70/80] Stock ledger report filter by item and brand --- stock/report/stock_ledger/stock_ledger.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stock/report/stock_ledger/stock_ledger.py b/stock/report/stock_ledger/stock_ledger.py index b2bc64f009..94c8eeda16 100644 --- a/stock/report/stock_ledger/stock_ledger.py +++ b/stock/report/stock_ledger/stock_ledger.py @@ -62,6 +62,9 @@ def get_item_conditions(filters): def get_sle_conditions(filters): conditions = [] + if filters.get("item_code"): + conditions.append("""item_code in (select name from tabItem + {item_conditions})""".format(item_conditions=get_item_conditions(filters))) if filters.get("warehouse"): conditions.append("warehouse=%(warehouse)s") if filters.get("voucher_no"): From c38527ef5f2dc2773961321e117a9fb94af9aa73 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 17:07:57 +0530 Subject: [PATCH 71/80] Show general/stock ledger button links to new query reports --- accounts/doctype/account/account.js | 5 +++-- .../doctype/journal_voucher/journal_voucher.js | 3 ++- .../doctype/purchase_invoice/purchase_invoice.js | 3 ++- accounts/doctype/sales_invoice/sales_invoice.js | 3 ++- .../page/accounts_browser/accounts_browser.js | 5 +++-- accounts/utils.py | 2 +- public/js/account_tree_grid.js | 15 +++++++++++++-- public/js/controllers/stock_controller.js | 14 ++++++++------ public/js/stock_analytics.js | 14 +++++++++++--- 9 files changed, 45 insertions(+), 19 deletions(-) diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js index b6986cf82a..8837586b06 100644 --- a/accounts/doctype/account/account.js +++ b/accounts/doctype/account/account.js @@ -95,9 +95,10 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { wn.route_options = { "account": doc.name, "from_date": sys_defaults.year_start_date, - "to_date": sys_defaults.year_end_date + "to_date": sys_defaults.year_end_date, + "company": doc.company }; - wn.set_route("general-ledger"); + wn.set_route("query-report", "General Ledger"); }, "icon-table"); } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index a5cd06d971..6b94ba170a 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -120,8 +120,9 @@ cur_frm.cscript.refresh = function(doc) { "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, + "company": doc.company }; - wn.set_route("general-ledger"); + wn.set_route("query-report", "General Ledger"); }, "icon-table"); } } diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.js b/accounts/doctype/purchase_invoice/purchase_invoice.js index fc530ddee3..0bdc70e13d 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -35,8 +35,9 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({ "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, + "company": doc.company }; - wn.set_route("query-report/General Ledger"); + wn.set_route("query-report", "General Ledger"); }, "icon-table"); } diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 55f6ddecec..a390fb4ed7 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -54,8 +54,9 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte "voucher_no": doc.name, "from_date": doc.posting_date, "to_date": doc.posting_date, + "company": doc.company }; - wn.set_route("query-report/General Ledger"); + wn.set_route("query-report", "General Ledger"); }, "icon-table"); var percent_paid = cint(flt(doc.grand_total - doc.outstanding_amount) / flt(doc.grand_total) * 100); diff --git a/accounts/page/accounts_browser/accounts_browser.js b/accounts/page/accounts_browser/accounts_browser.js index d57073a072..235e6ab541 100644 --- a/accounts/page/accounts_browser/accounts_browser.js +++ b/accounts/page/accounts_browser/accounts_browser.js @@ -175,9 +175,10 @@ erpnext.AccountsChart = Class.extend({ wn.route_options = { "account": node.data('label'), "from_date": sys_defaults.year_start_date, - "to_date": sys_defaults.year_end_date + "to_date": sys_defaults.year_end_date, + "company": me.company }; - wn.set_route("general-ledger"); + wn.set_route("query-report", "General Ledger"); }, rename: function() { var node = this.selected_node(); diff --git a/accounts/utils.py b/accounts/utils.py index caad793ca1..8971c80f99 100644 --- a/accounts/utils.py +++ b/accounts/utils.py @@ -16,7 +16,7 @@ class BudgetError(webnotes.ValidationError): pass def get_fiscal_year(date=None, fiscal_year=None, label="Date", verbose=1): - return get_fiscal_years(date, fiscal_year, label, verbose=1)[0] + return get_fiscal_years(date, fiscal_year, label, verbose)[0] def get_fiscal_years(date=None, fiscal_year=None, label="Date", verbose=1): # if year start date is 2012-04-01, year end date should be 2013-03-31 (hence subdate) diff --git a/public/js/account_tree_grid.js b/public/js/account_tree_grid.js index 44bef57722..1cd9aa6083 100644 --- a/public/js/account_tree_grid.js +++ b/public/js/account_tree_grid.js @@ -26,9 +26,10 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({ show: true, parent_field: "parent_account", formatter: function(item) { - return repl('%(value)s', { + return repl("\ + %(value)s", { value: item.name, - enc_value: encodeURIComponent(item.name) }); } }, @@ -211,4 +212,14 @@ erpnext.AccountTreeGrid = wn.views.TreeGridReport.extend({ return; } }, + + show_general_ledger: function(account) { + wn.route_options = { + account: account, + company: this.company, + from_date: this.from_date, + to_date: this.to_date + }; + wn.set_route("query-report", "General Ledger"); + } }); \ No newline at end of file diff --git a/public/js/controllers/stock_controller.js b/public/js/controllers/stock_controller.js index ee5c497772..d2fb904419 100644 --- a/public/js/controllers/stock_controller.js +++ b/public/js/controllers/stock_controller.js @@ -11,9 +11,10 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({ wn.route_options = { voucher_no: me.frm.doc.name, from_date: me.frm.doc.posting_date, - to_date: me.frm.doc.posting_date + to_date: me.frm.doc.posting_date, + company: me.frm.doc.company }; - wn.set_route('stock-ledger'); + wn.set_route("query-report", "Stock Ledger"); }, "icon-bar-chart"); } @@ -24,11 +25,12 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({ if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("auto_accounting_for_stock"))) { cur_frm.appframe.add_button(wn._('Accounting Ledger'), function() { wn.route_options = { - "voucher_no": me.frm.doc.name, - "from_date": me.frm.doc.posting_date, - "to_date": me.frm.doc.posting_date, + voucher_no: me.frm.doc.name, + from_date: me.frm.doc.posting_date, + to_date: me.frm.doc.posting_date, + company: me.frm.doc.company }; - wn.set_route("general-ledger"); + wn.set_route("query-report", "General Ledger"); }, "icon-table"); } }, diff --git a/public/js/stock_analytics.js b/public/js/stock_analytics.js index 832cac5d6e..8b68d39e69 100644 --- a/public/js/stock_analytics.js +++ b/public/js/stock_analytics.js @@ -17,10 +17,10 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ parent_field: "parent_item_group", formatter: function(item) { if(!item.is_group) { - return repl('%(value)s', - { + return repl("\ + %(value)s", { value: item.name, - enc_value: encodeURIComponent(item.name) }); } else { return item.name; @@ -183,5 +183,13 @@ erpnext.StockAnalytics = erpnext.StockGridReport.extend({ }, get_plot_points: function(item, col, idx) { return [[dateutil.user_to_obj(col.name).getTime(), item[col.field]]] + }, + show_stock_ledger: function(item_code) { + wn.route_options = { + item_code: item_code, + from_date: this.from_date, + to_date: this.to_date + }; + wn.set_route("query-report", "Stock Ledger"); } }); \ No newline at end of file From 2117afba07aea95c791f8581b75be433a3123018 Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Mon, 23 Dec 2013 18:01:22 +0600 Subject: [PATCH 72/80] bumped to version 3.3.7 --- config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config.json b/config.json index 23561d588b..55c776ad0a 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.6", + "app_version": "3.3.7", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { @@ -74,5 +74,5 @@ "type": "module" } }, - "requires_framework_version": "==3.3.1" + "requires_framework_version": "==3.3.2" } \ No newline at end of file From 9f1b59dfc615cc4b2e240344b182cc5601d0cc66 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 23 Dec 2013 20:34:09 +0530 Subject: [PATCH 73/80] Fixes in sales return validation --- stock/doctype/stock_entry/stock_entry.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index ba0e72478c..2e7e2a4066 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -287,9 +287,15 @@ class DocType(StockController): # validate quantity <= ref item's qty - qty already returned ref_item = ref.doclist.getone({"item_code": item.item_code}) returnable_qty = ref_item.qty - flt(already_returned_item_qty.get(item.item_code)) - self.validate_value("transfer_qty", "<=", returnable_qty, item, - raise_exception=StockOverReturnError) - + if not returnable_qty: + webnotes.throw("{item}: {item_code} {returned}".format( + item=_("Item"), item_code=item.item_code, + returned=_("already returned though some other documents"))) + elif item.transfer_qty > returnable_qty: + webnotes.throw("{item}: {item_code}, {returned}: {qty}".format( + item=_("Item"), item_code=item.item_code, + returned=_("Max Returnable Qty"), qty=returnable_qty)) + def get_already_returned_item_qty(self, ref_fieldname): return dict(webnotes.conn.sql("""select item_code, sum(transfer_qty) as qty from `tabStock Entry Detail` where parent in ( From 4cae8a0d54dbed6036e793a1a406db5024090267 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 10:47:34 +0530 Subject: [PATCH 74/80] Fixes in stock ledger report --- stock/report/stock_ledger/stock_ledger.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stock/report/stock_ledger/stock_ledger.py b/stock/report/stock_ledger/stock_ledger.py index 94c8eeda16..38308c2f31 100644 --- a/stock/report/stock_ledger/stock_ledger.py +++ b/stock/report/stock_ledger/stock_ledger.py @@ -62,9 +62,10 @@ def get_item_conditions(filters): def get_sle_conditions(filters): conditions = [] - if filters.get("item_code"): + item_conditions=get_item_conditions(filters) + if item_conditions: conditions.append("""item_code in (select name from tabItem - {item_conditions})""".format(item_conditions=get_item_conditions(filters))) + {item_conditions})""".format(item_conditions=item_conditions)) if filters.get("warehouse"): conditions.append("warehouse=%(warehouse)s") if filters.get("voucher_no"): From a3d058938e5981f5dd146a35d5c2b335e3ef3c39 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 11:03:04 +0530 Subject: [PATCH 75/80] Company mandatory validation while enabling perpetual inventory --- .../doctype/accounts_settings/accounts_settings.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py index d55b022d2f..a6e993863d 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.py +++ b/accounts/doctype/accounts_settings/accounts_settings.py @@ -5,8 +5,7 @@ from __future__ import unicode_literals import webnotes -from webnotes.utils import cint, cstr -from webnotes import msgprint, _ +from webnotes import _ class DocType: def __init__(self, d, dl): @@ -16,6 +15,11 @@ class DocType: webnotes.conn.set_default("auto_accounting_for_stock", self.doc.auto_accounting_for_stock) if self.doc.auto_accounting_for_stock: - for wh in webnotes.conn.sql("select name from `tabWarehouse`"): - wh_bean = webnotes.bean("Warehouse", wh[0]) + warehouse_list = webnotes.conn.sql("select name, company from tabWarehouse", as_dict=1) + warehouse_with_no_company = [d.name for d in warehouse_list if not d.company] + if warehouse_with_no_company: + webnotes.throw(_("Company is missing in following warehouses") + ": \n" + + "\n".join(warehouse_with_no_company)) + for wh in warehouse_list: + wh_bean = webnotes.bean("Warehouse", wh.name) wh_bean.save() \ No newline at end of file From 25a4bd02f43be98b0b4fba085b669818dada6d1d Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 24 Dec 2013 11:32:57 +0530 Subject: [PATCH 76/80] [fix] [minor] update item_name and description in item price --- patches/1312/p02_update_item_details_in_item_price.py | 10 ++++++++++ patches/patch_list.py | 1 + 2 files changed, 11 insertions(+) create mode 100644 patches/1312/p02_update_item_details_in_item_price.py diff --git a/patches/1312/p02_update_item_details_in_item_price.py b/patches/1312/p02_update_item_details_in_item_price.py new file mode 100644 index 0000000000..c19988c9ef --- /dev/null +++ b/patches/1312/p02_update_item_details_in_item_price.py @@ -0,0 +1,10 @@ +# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors +# License: GNU General Public License v3. See license.txt + +from __future__ import unicode_literals +import webnotes + +def execute(): + webnotes.conn.sql("""update `tabItem Price` ip INNER JOIN `tabItem` i + ON (ip.item_code = i.name) + set ip.item_name = i.item_name, ip.item_description = i.description""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 49c0779872..608ba77168 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -262,4 +262,5 @@ patch_list = [ "patches.1311.p07_scheduler_errors_digest", "patches.1311.p08_email_digest_recipients", "execute:webnotes.delete_doc('DocType', 'Warehouse Type')", + "patches.1312.p02_update_item_details_in_item_price", ] \ No newline at end of file From 6a2edee91453cde85b2f8f547c910462ff9665a1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 11:58:05 +0530 Subject: [PATCH 77/80] Fixes in general ledger report --- accounts/report/general_ledger/general_ledger.py | 12 +++++++----- setup/doctype/features_setup/features_setup.txt | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/accounts/report/general_ledger/general_ledger.py b/accounts/report/general_ledger/general_ledger.py index e76c0c4bf9..b88d5bc296 100644 --- a/accounts/report/general_ledger/general_ledger.py +++ b/accounts/report/general_ledger/general_ledger.py @@ -9,8 +9,9 @@ from accounts.utils import get_balance_on def execute(filters=None): account_details = webnotes.conn.get_value("Account", filters["account"], - ["debit_or_credit", "group_or_ledger"], as_dict=True) - validate_filters(filters, account_details.group_or_ledger) + ["debit_or_credit", "group_or_ledger"], as_dict=True) if filters.get("account") else None + validate_filters(filters, account_details) + columns = get_columns() data = [] if filters.get("group_by"): @@ -20,14 +21,15 @@ def execute(filters=None): if data: data.append(get_total_row(data)) - if filters.get("account"): + if account_details: data = [get_opening_balance_row(filters, account_details.debit_or_credit)] + data + \ [get_closing_balance_row(filters, account_details.debit_or_credit)] return columns, data -def validate_filters(filters, group_or_ledger): - if group_or_ledger == "Ledger" and filters.get("group_by") == "Group by Account": +def validate_filters(filters, account_details): + if account_details and account_details.group_or_ledger == "Ledger" \ + and filters.get("group_by") == "Group by Account": webnotes.throw(_("Can not filter based on Account, if grouped by Account")) if filters.get("voucher_no") and filters.get("group_by") == "Group by Voucher": diff --git a/setup/doctype/features_setup/features_setup.txt b/setup/doctype/features_setup/features_setup.txt index 3f73ee2e25..d68f489af7 100644 --- a/setup/doctype/features_setup/features_setup.txt +++ b/setup/doctype/features_setup/features_setup.txt @@ -2,7 +2,7 @@ { "creation": "2012-12-20 12:50:49", "docstatus": 0, - "modified": "2013-11-03 14:20:18", + "modified": "2013-12-24 11:40:19", "modified_by": "Administrator", "owner": "Administrator" }, @@ -90,7 +90,7 @@ "doctype": "DocField", "fieldname": "fs_packing_details", "fieldtype": "Check", - "label": "Packing Detials" + "label": "Packing Details" }, { "description": "To get Item Group in details table", From 6ebcc5c0069e0b70c7eef2a0536ea4fe66a8b1ad Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Dec 2013 12:14:12 +0530 Subject: [PATCH 78/80] Change parent account of warehouse from inside the warehouse --- stock/doctype/warehouse/warehouse.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/stock/doctype/warehouse/warehouse.py b/stock/doctype/warehouse/warehouse.py index 8b1b5b5a1d..db4ee405f5 100644 --- a/stock/doctype/warehouse/warehouse.py +++ b/stock/doctype/warehouse/warehouse.py @@ -20,6 +20,19 @@ class DocType: if self.doc.email_id and not validate_email_add(self.doc.email_id): msgprint("Please enter valid Email Id", raise_exception=1) + self.update_parent_account() + + def update_parent_account(self): + if not self.doc.__islocal and (self.doc.create_account_under != + webnotes.conn.get_value("Warehouse", self.doc.name, "create_account_under")): + warehouse_account = webnotes.conn.get_value("Account", + {"account_type": "Warehouse", "company": self.doc.company, + "master_name": self.doc.name}, ["name", "parent_account"]) + if warehouse_account and warehouse_account[1] != self.doc.create_account_under: + acc_bean = webnotes.bean("Account", warehouse_account[0]) + acc_bean.doc.parent_account = self.doc.create_account_under + acc_bean.save() + def on_update(self): self.create_account_head() From a402079cd479932b13c993750a2728ab870e0dbf Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 24 Dec 2013 13:42:21 +0600 Subject: [PATCH 79/80] bumped to version 3.3.8 --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 55c776ad0a..b57ba61ba1 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,6 @@ { "app_name": "ERPNext", - "app_version": "3.3.7", + "app_version": "3.3.8", "base_template": "app/portal/templates/base.html", "modules": { "Accounts": { From 9dc1b00d872d2553fb8a1688fd9db7e98ba191f7 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 25 Dec 2013 12:28:54 +0530 Subject: [PATCH 80/80] Removed country field from Search Fields --- selling/doctype/customer/customer.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selling/doctype/customer/customer.txt b/selling/doctype/customer/customer.txt index 7a24531665..43a397743a 100644 --- a/selling/doctype/customer/customer.txt +++ b/selling/doctype/customer/customer.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-11 14:26:44", "docstatus": 0, - "modified": "2013-11-03 14:01:33", + "modified": "2013-12-25 11:15:05", "modified_by": "Administrator", "owner": "Administrator" }, @@ -16,7 +16,7 @@ "icon": "icon-user", "module": "Selling", "name": "__common__", - "search_fields": "customer_name,customer_group,country,territory" + "search_fields": "customer_name,customer_group,territory" }, { "doctype": "DocField",