From 589a2980960cd201e79058b3886cdb81c4722242 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 11 Jun 2014 13:00:03 +0530 Subject: [PATCH 01/22] Minor fixes in salary manager. Fixes #1754 --- erpnext/hr/doctype/salary_manager/salary_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.py b/erpnext/hr/doctype/salary_manager/salary_manager.py index dcc16656911..7d962e3c693 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.py +++ b/erpnext/hr/doctype/salary_manager/salary_manager.py @@ -128,7 +128,7 @@ class SalaryManager(Document): for ss in ss_list: ss_obj = frappe.get_doc("Salary Slip",ss[0]) try: - frappe.db.set(ss_obj, 'email_check', cint(self.send_mail)) + frappe.db.set(ss_obj, 'email_check', cint(self.send_email)) if cint(self.send_email) == 1: ss_obj.send_mail_funct() From 6def968c3c39cef0a504b4717a7644c24471152c Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 12 Jun 2014 10:31:43 +0530 Subject: [PATCH 02/22] minor fix for outgoing communication email --- erpnext/controllers/selling_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index df320dcda1b..33f03b6ce4a 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -19,7 +19,7 @@ class SellingController(StockController): if frappe.db.get_value('Sales Email Settings', None, 'extract_emails'): return frappe.db.get_value('Sales Email Settings', None, 'email_id') else: - return frappe.session.user + return comm.sender or frappe.session.user def set_missing_values(self, for_validate=False): super(SellingController, self).set_missing_values(for_validate) From e98b326ba30a8b2b245f741ceca71a7bba19f231 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Jun 2014 12:24:11 +0530 Subject: [PATCH 03/22] Stock Entry: Always set valuation rate automatically if source warehouse provided or sales return. Fixes #932 --- erpnext/stock/doctype/stock_entry/stock_entry.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index ac81f88e887..da176b09766 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -205,8 +205,10 @@ class StockEntry(StockController): # get incoming rate if not d.bom_no: - if not flt(d.incoming_rate): - d.incoming_rate = self.get_incoming_rate(args) + if not flt(d.incoming_rate) or d.s_warehouse or self.purpose == "Sales Return": + incoming_rate = self.get_incoming_rate(args) + if incoming_rate: + d.incoming_rate = incoming_rate d.amount = flt(d.transfer_qty) * flt(d.incoming_rate) raw_material_cost += flt(d.amount) From 2128c98c353285f9d76c2d276af018397a06d41f Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Jun 2014 12:42:22 +0530 Subject: [PATCH 04/22] available qty validation. Fixes #1045 --- erpnext/stock/doctype/stock_entry/stock_entry.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index da176b09766..bbe461e79a5 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -202,6 +202,10 @@ class StockEntry(StockController): }) # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 + if d.s_warehouse and d.actual_qty <= d.transfer_qty: + frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}. + Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, + self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) # get incoming rate if not d.bom_no: From 46dc3b1442d0ab8debb42d385acf343b3d979d04 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Jun 2014 12:48:28 +0530 Subject: [PATCH 05/22] validations added in stock entry --- erpnext/stock/doctype/stock_entry/stock_entry.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index bbe461e79a5..2037117e05b 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -70,6 +70,9 @@ class StockEntry(StockController): def set_transfer_qty(self): for item in self.get("mtn_details"): + if not flt(item.qty): + frappe.throw(_("Row {0}: Qty is mandatory").format(item.idx)) + item.transfer_qty = flt(item.qty * item.conversion_factor, self.precision("transfer_qty", item)) def validate_item(self): @@ -191,6 +194,9 @@ class StockEntry(StockController): raw_material_cost = 0.0 + if not self.posting_date or not self.posting_time: + frappe.throw(_("Posting date and posting time is mandatory")) + for d in self.get('mtn_details'): args = frappe._dict({ "item_code": d.item_code, @@ -200,6 +206,7 @@ class StockEntry(StockController): "qty": d.s_warehouse and -1*d.transfer_qty or d.transfer_qty, "serial_no": d.serial_no }) + # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 if d.s_warehouse and d.actual_qty <= d.transfer_qty: From e7f2d3179d42d121c612e083911ecb423a0b6de8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Jun 2014 14:58:09 +0530 Subject: [PATCH 06/22] update other_charges in custom print formats --- erpnext/patches.txt | 1 + ...other_charges_in_custom_purchase_print_formats.py | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 8755837b700..02c651f9ed0 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -58,3 +58,4 @@ execute:frappe.reset_perms("Stock Ledger Entry") #2014-06-09 erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields erpnext.patches.v4_0.save_default_letterhead erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields +erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats diff --git a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py new file mode 100644 index 00000000000..c0f9ee008f4 --- /dev/null +++ b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py @@ -0,0 +1,12 @@ +# 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 frappe +import re + +def execute(): + for name, html in frappe.db.sql("""select name, html from `tabPrint Format` + where standard = 'No' and html like '%%purchase\\_tax\\_details%%'"""): + html = re.sub(r"\bpurchase_tax_details\b", "other_charges", html) + frappe.db.set_value("Print Format", name, "html", html) From 205438669ad966c2028f20f75d30dfbb1b3c590d Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Jun 2014 12:59:23 +0530 Subject: [PATCH 07/22] Removed clear_custom_buttons, pos view switch fix --- erpnext/accounts/doctype/sales_invoice/sales_invoice.js | 2 +- erpnext/public/js/transaction.js | 1 - erpnext/selling/doctype/lead/lead.js | 1 - erpnext/selling/doctype/opportunity/opportunity.js | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 034880a211b..bfb500c665c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -24,7 +24,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } // toggle to pos view if is_pos is 1 in user_defaults - if ((cint(frappe.defaults.get_user_defaults("is_pos"))===1 || this.frm.doc.is_pos)) { + if ((is_null(this.frm.doc.is_pos) && cint(frappe.defaults.get_user_default("is_pos"))===1) || this.frm.doc.is_pos) { if(this.frm.doc.__islocal && !this.frm.doc.amended_from && !this.frm.doc.customer) { this.frm.set_value("is_pos", 1); this.is_pos(function() { diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 27ee1521c89..2c372042eab 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -47,7 +47,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, refresh: function() { - this.frm.clear_custom_buttons(); erpnext.toggle_naming_series(); erpnext.hide_company(); this.show_item_wise_taxes(); diff --git a/erpnext/selling/doctype/lead/lead.js b/erpnext/selling/doctype/lead/lead.js index 286ce3593c8..ba9741b4f69 100644 --- a/erpnext/selling/doctype/lead/lead.js +++ b/erpnext/selling/doctype/lead/lead.js @@ -30,7 +30,6 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({ refresh: function() { var doc = this.frm.doc; erpnext.toggle_naming_series(); - this.frm.clear_custom_buttons(); if(!this.frm.doc.__islocal && this.frm.doc.__onload && !this.frm.doc.__onload.is_customer) { this.frm.add_custom_button(__("Create Customer"), this.create_customer); diff --git a/erpnext/selling/doctype/opportunity/opportunity.js b/erpnext/selling/doctype/opportunity/opportunity.js index 4cc95ad59bb..ce7c6ea2738 100644 --- a/erpnext/selling/doctype/opportunity/opportunity.js +++ b/erpnext/selling/doctype/opportunity/opportunity.js @@ -80,7 +80,6 @@ $.extend(cur_frm.cscript, new erpnext.selling.Opportunity({frm: cur_frm})); cur_frm.cscript.refresh = function(doc, cdt, cdn) { erpnext.toggle_naming_series(); - cur_frm.clear_custom_buttons(); if(doc.docstatus === 1 && doc.status!=="Lost") { cur_frm.add_custom_button(__('Create Quotation'), cur_frm.cscript.create_quotation); From 3761ff352237567ae8464be08d30d719e7f141ed Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 12 Jun 2014 15:00:25 +0530 Subject: [PATCH 08/22] Fix in patch: split email settings --- erpnext/patches/v4_0/split_email_settings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/erpnext/patches/v4_0/split_email_settings.py b/erpnext/patches/v4_0/split_email_settings.py index 05d9bc58000..1b8a0c6968d 100644 --- a/erpnext/patches/v4_0/split_email_settings.py +++ b/erpnext/patches/v4_0/split_email_settings.py @@ -28,6 +28,7 @@ def map_outgoing_email_settings(email_settings): outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) + outgoing_email_settings._fix_numeric_types() outgoing_email_settings.save() def map_support_email_settings(email_settings): @@ -47,6 +48,7 @@ def map_support_email_settings(email_settings): support_email_settings.set(to_fieldname, email_settings.get(from_fieldname)) + support_email_settings._fix_numeric_types() support_email_settings.save() def get_email_settings(): From f2202fc01419f826d056a62e23879514b4a7d0e8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 12 Jun 2014 15:20:47 +0530 Subject: [PATCH 09/22] minor fix --- erpnext/stock/doctype/stock_entry/stock_entry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 2037117e05b..d8164f7e218 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -197,6 +197,8 @@ class StockEntry(StockController): if not self.posting_date or not self.posting_time: frappe.throw(_("Posting date and posting time is mandatory")) + allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock") + for d in self.get('mtn_details'): args = frappe._dict({ "item_code": d.item_code, @@ -209,7 +211,8 @@ class StockEntry(StockController): # get actual stock at source warehouse d.actual_qty = get_previous_sle(args).get("qty_after_transaction") or 0 - if d.s_warehouse and d.actual_qty <= d.transfer_qty: + + if d.s_warehouse and not allow_negative_stock and d.actual_qty <= d.transfer_qty: frappe.throw(_("""Row {0}: Qty not avalable in warehouse {1} on {2} {3}. Available Qty: {4}, Transfer Qty: {5}""").format(d.idx, d.s_warehouse, self.posting_date, self.posting_time, d.actual_qty, d.transfer_qty)) From c1bfb63d96bb992769d1f6c654f87436d3c72dcc Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 13 Jun 2014 12:41:08 +0530 Subject: [PATCH 10/22] Create price list if missing --- erpnext/patches.txt | 1 + .../v4_0/create_price_list_if_missing.py | 28 +++++++++++++++++++ .../stock/doctype/price_list/price_list.py | 1 + 3 files changed, 30 insertions(+) create mode 100644 erpnext/patches/v4_0/create_price_list_if_missing.py diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 02c651f9ed0..f7342c1d75c 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -59,3 +59,4 @@ erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields erpnext.patches.v4_0.save_default_letterhead erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats +erpnext.patches.v4_0.create_price_list_if_missing diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py new file mode 100644 index 00000000000..eeeae19783e --- /dev/null +++ b/erpnext/patches/v4_0/create_price_list_if_missing.py @@ -0,0 +1,28 @@ +# 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 frappe +from frappe import _ +from frappe.utils.nestedset import get_root_of + +def execute(): + if not frappe.db.sql("select name from `tabPrice List` where buying=1"): + create_price_list(_("Standard Buying"), buying=1) + + if not frappe.db.sql("select name from `tabPrice List` where selling=1"): + create_price_list(_("Standard Selling"), selling=1) + +def create_price_list(pl_name, buying=0, selling=0): + price_list = frappe.get_doc({ + "doctype": "Price List", + "price_list_name": pl_name, + "enabled": 1, + "buying": buying, + "selling": selling, + "currency": frappe.db.get_default("currency"), + "valid_for_territories": [{ + "territory": get_root_of("Territory") + }] + }) + price_list.insert() diff --git a/erpnext/stock/doctype/price_list/price_list.py b/erpnext/stock/doctype/price_list/price_list.py index d992488fc65..a4ff25044b1 100644 --- a/erpnext/stock/doctype/price_list/price_list.py +++ b/erpnext/stock/doctype/price_list/price_list.py @@ -51,6 +51,7 @@ class PriceList(Document): if self.name == b.get(price_list_fieldname): b.set(price_list_fieldname, None) + b.ignore_permissions = True b.save() for module in ["Selling", "Buying"]: From 3dc722b0964af9ad6fd7b008563636ddd378d914 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Fri, 13 Jun 2014 15:30:38 +0530 Subject: [PATCH 11/22] Create price list only if setup complete --- erpnext/patches/v4_0/create_price_list_if_missing.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py index eeeae19783e..eea1fd9ff6a 100644 --- a/erpnext/patches/v4_0/create_price_list_if_missing.py +++ b/erpnext/patches/v4_0/create_price_list_if_missing.py @@ -7,6 +7,10 @@ from frappe import _ from frappe.utils.nestedset import get_root_of def execute(): + # setup not complete + if not frappe.db.sql("""select name from tabCompany limit 1"""): + return + if not frappe.db.sql("select name from `tabPrice List` where buying=1"): create_price_list(_("Standard Buying"), buying=1) From 3474c273a53962d936025cbedd9718b045339d53 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Jun 2014 12:14:14 +0530 Subject: [PATCH 12/22] Ignore mandatory in employee patch --- erpnext/patches/v4_0/apply_user_permissions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py index 36c778195b2..7dae02f7855 100644 --- a/erpnext/patches/v4_0/apply_user_permissions.py +++ b/erpnext/patches/v4_0/apply_user_permissions.py @@ -27,7 +27,9 @@ def update_hr_permissions(): # save employees to run on_update events for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""): try: - frappe.get_doc("Employee", employee).save() + emp = frappe.get_doc("Employee", employee) + emp.ignore_mandatory = True + emp.save() except EmployeeUserDisabledError: pass From e35841a2eab9b62c0ed44b54f2bee2e54ec013df Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Jun 2014 12:59:54 +0530 Subject: [PATCH 13/22] Reload Shopping Cart Settings in create price list patch --- erpnext/patches/v4_0/create_price_list_if_missing.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py index eea1fd9ff6a..f65b7cb571a 100644 --- a/erpnext/patches/v4_0/create_price_list_if_missing.py +++ b/erpnext/patches/v4_0/create_price_list_if_missing.py @@ -11,6 +11,9 @@ def execute(): if not frappe.db.sql("""select name from tabCompany limit 1"""): return + if "shopping_cart" in frappe.get_installed_apps(): + frappe.reload_doc("shopping_cart", "doctype", "shopping_cart_settings") + if not frappe.db.sql("select name from `tabPrice List` where buying=1"): create_price_list(_("Standard Buying"), buying=1) From 0521814deaa61caa5decfd7c145a8dc7be7e6756 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Jun 2014 13:25:20 +0530 Subject: [PATCH 14/22] Fixed item query --- erpnext/controllers/queries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index a30cde72a56..a3b3ed2ffa6 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -141,7 +141,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters): concat(substr(tabItem.description, 1, 40), "..."), description) as decription from tabItem where tabItem.docstatus < 2 - and (ifnull(tabItem.end_of_life, '') = '' or tabItem.end_of_life > %(today)s) + and (ifnull(tabItem.end_of_life, '0000-00-00') = '0000-00-00' or tabItem.end_of_life > %(today)s) and (tabItem.`{key}` LIKE %(txt)s or tabItem.item_name LIKE %(txt)s) {fcond} {mcond} From ccf370f813c920bfbd24940b5b11fdc9ddaba0d6 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 16 Jun 2014 13:50:11 +0530 Subject: [PATCH 15/22] Fixed item query --- erpnext/controllers/queries.py | 2 +- erpnext/patches.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index a3b3ed2ffa6..a4d2b529169 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -141,7 +141,7 @@ def item_query(doctype, txt, searchfield, start, page_len, filters): concat(substr(tabItem.description, 1, 40), "..."), description) as decription from tabItem where tabItem.docstatus < 2 - and (ifnull(tabItem.end_of_life, '0000-00-00') = '0000-00-00' or tabItem.end_of_life > %(today)s) + and (tabItem.end_of_life is null or tabItem.end_of_life > %(today)s) and (tabItem.`{key}` LIKE %(txt)s or tabItem.item_name LIKE %(txt)s) {fcond} {mcond} diff --git a/erpnext/patches.txt b/erpnext/patches.txt index f7342c1d75c..761b63c9fd8 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -60,3 +60,4 @@ erpnext.patches.v4_0.save_default_letterhead erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats erpnext.patches.v4_0.create_price_list_if_missing +execute:frappe.db.sql("update `tabItem` set end_of_life=null where end_of_life='0000-00-00'") #2014-06-16 From e1b2b3e995129d2d553d527d343da6a3a150b786 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Sat, 14 Jun 2014 15:26:10 +0530 Subject: [PATCH 16/22] Account common get_query --- erpnext/controllers/queries.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py index a4d2b529169..789e7a331a2 100644 --- a/erpnext/controllers/queries.py +++ b/erpnext/controllers/queries.py @@ -236,13 +236,21 @@ def get_batch_no(doctype, txt, searchfield, start, page_len, filters): 'page_len': page_len}) def get_account_list(doctype, txt, searchfield, start, page_len, filters): - if isinstance(filters, dict): - if not filters.get("group_or_ledger"): - filters["group_or_ledger"] = "Ledger" - elif isinstance(filters, list): - if "group_or_ledger" not in [d[0] for d in filters]: - filters.append(["Account", "group_or_ledger", "=", "Ledger"]) + filter_list = [] - return frappe.widgets.reportview.execute("Account", filters = filters, + if isinstance(filters, dict): + for key, val in filters.items(): + if isinstance(val, (list, tuple)): + filter_list.append([doctype, key, val[0], val[1]]) + else: + filter_list.append([doctype, key, "=", val]) + + if "group_or_ledger" not in [d[1] for d in filter_list]: + filter_list.append(["Account", "group_or_ledger", "=", "Ledger"]) + + if searchfield and txt: + filter_list.append([doctype, searchfield, "like", "%%%s%%" % txt]) + + return frappe.widgets.reportview.execute("Account", filters = filter_list, fields = ["name", "parent_account"], limit_start=start, limit_page_length=page_len, as_list=True) From 539f352318af8afeed26f6e4ed147a56d91c1e13 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 16 Jun 2014 15:03:02 +0530 Subject: [PATCH 17/22] Delivery note to packing slip mapping --- .../stock/doctype/delivery_note/delivery_note.js | 8 ++++---- .../stock/doctype/delivery_note/delivery_note.py | 16 ++++++++++++++++ .../doctype/material_request/material_request.py | 2 +- .../stock/doctype/packing_slip/packing_slip.js | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index fb94b888092..10fe6503e6d 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -118,10 +118,10 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) { } cur_frm.cscript['Make Packing Slip'] = function() { - n = frappe.model.make_new_doc_and_get_name('Packing Slip'); - ps = locals["Packing Slip"][n]; - ps.delivery_note = cur_frm.doc.name; - loaddoc('Packing Slip', n); + frappe.model.open_mapped_doc({ + method: "erpnext.stock.doctype.delivery_note.delivery_note.make_packing_slip", + frm: cur_frm + }) } var set_print_hide= function(doc, cdt, cdn){ diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index da7dd7af561..1600950fc53 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -346,3 +346,19 @@ def make_installation_note(source_name, target_doc=None): }, target_doc) return doclist + +@frappe.whitelist() +def make_packing_slip(source_name, target_doc=None): + doclist = get_mapped_doc("Delivery Note", source_name, { + "Delivery Note": { + "doctype": "Packing Slip", + "field_map": { + "name": "delivery_note" + }, + "validation": { + "docstatus": ["=", 0] + } + } + }, target_doc) + + return doclist diff --git a/erpnext/stock/doctype/material_request/material_request.py b/erpnext/stock/doctype/material_request/material_request.py index f8f0d097ff6..9951fc88c27 100644 --- a/erpnext/stock/doctype/material_request/material_request.py +++ b/erpnext/stock/doctype/material_request/material_request.py @@ -48,7 +48,7 @@ class MaterialRequest(BuyingController): def validate_schedule_date(self): for d in self.get('indent_details'): - if d.schedule_date < self.transaction_date: + if d.schedule_date and d.schedule_date < self.transaction_date: frappe.throw(_("Expected Date cannot be before Material Request Date")) # Validate diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index acdd27e1ab4..9788290a1bd 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -18,7 +18,7 @@ cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { if(doc.delivery_note && doc.__islocal) { - cur_frm.cscript.get_items(doc, cdt, cdn); + cur_frm.cscript.get_items(doc, cdt, cdn); } } From a6fc3f633767721eb69e498d3dc11ae649b70e38 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 16 Jun 2014 15:34:52 +0530 Subject: [PATCH 18/22] Ignore pricing rule for material request --- erpnext/stock/get_item_details.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index 9c251b8b29b..cdf5aa1f3d5 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -255,7 +255,7 @@ def apply_pricing_rule(args): args = frappe._dict(args) out = frappe._dict() - if not args.get("item_code"): return + if args.get("doctype") == "Material Request" or not args.get("item_code"): return out if not args.get("item_group") or not args.get("brand"): args.item_group, args.brand = frappe.db.get_value("Item", From 98d9d797fde4d0425a75290b76dd4ed52b31d968 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 16 Jun 2014 15:54:05 +0530 Subject: [PATCH 19/22] Tax category validation ignored in material request --- erpnext/controllers/buying_controller.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index accaeb44984..afccdfa0e3f 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -52,9 +52,8 @@ class BuyingController(StockController): validate_warehouse_company(w, self.company) def validate_stock_or_nonstock_items(self): - if not self.get_stock_items(): - tax_for_valuation = [d.account_head for d in - self.get("other_charges") + if self.meta.get_field("other_charges") and not self.get_stock_items(): + tax_for_valuation = [d.account_head for d in self.get("other_charges") if d.category in ["Valuation", "Valuation and Total"]] if tax_for_valuation: frappe.throw(_("Tax Category can not be 'Valuation' or 'Valuation and Total' as all items are non-stock items")) From d2e8a0a96add9f7e0c9f38049a69cb24207b2644 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Jun 2014 12:54:45 +0530 Subject: [PATCH 20/22] Delivery note update after submission --- .../doctype/delivery_note/delivery_note.py | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.py b/erpnext/stock/doctype/delivery_note/delivery_note.py index 1600950fc53..bbc9f81ff47 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.py +++ b/erpnext/stock/doctype/delivery_note/delivery_note.py @@ -68,13 +68,14 @@ class DeliveryNote(SellingController): self.validate_for_items() self.validate_warehouse() self.validate_uom_is_integer("stock_uom", "qty") - self.update_current_stock() self.validate_with_previous_doc() from erpnext.stock.doctype.packed_item.packed_item import make_packing_list make_packing_list(self, 'delivery_note_details') - self.status = 'Draft' + self.update_current_stock() + + if not self.status: self.status = 'Draft' if not self.installation_status: self.installation_status = 'Not Installed' def validate_with_previous_doc(self): @@ -133,14 +134,17 @@ class DeliveryNote(SellingController): def update_current_stock(self): - for d in self.get('delivery_note_details'): - bin = frappe.db.sql("select actual_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 + if self._action != "update_after_submit": + for d in self.get('delivery_note_details'): + d.actual_qty = frappe.db.get_value("Bin", {"item_code": d.item_code, + "warehouse": d.warehouse}, "actual_qty") - for d in self.get('packing_details'): - bin = frappe.db.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 + for d in self.get('packing_details'): + bin_qty = frappe.db.get_value("Bin", {"item_code": d.item_code, + "warehouse": d.warehouse}, ["actual_qty", "projected_qty"], as_dict=True) + if bin_qty: + d.actual_qty = flt(bin_qty.actual_qty) + d.projected_qty = flt(bin_qty.projected_qty) def on_submit(self): self.validate_packed_qty() From 4ee8704b99867c4f33256e479ecec7a1d2dee386 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 17 Jun 2014 13:52:03 +0530 Subject: [PATCH 21/22] Fixes in financial analytics --- .../accounts/page/financial_analytics/financial_analytics.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js index 52298bbf187..4574390ce1f 100644 --- a/erpnext/accounts/page/financial_analytics/financial_analytics.js +++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js @@ -206,11 +206,11 @@ erpnext.FinancialAnalytics = erpnext.AccountTreeGrid.extend({ if(me.pl_or_bs=='Balance Sheet') { $.each(me.data, function(i, ac) { if((ac.rgt - ac.lft)==1 && ac.report_type=='Balance Sheet') { - var opening = 0; + var opening = flt(ac["opening_dr"]) - flt(ac["opening_cr"]); //if(opening) throw opening; $.each(me.columns, function(i, col) { if(col.formatter==me.currency_formatter) { - if(col.balance_type=="Dr") { + if(col.balance_type=="Dr" && !in_list(["opening_dr", "opening_cr"], col.field)) { opening = opening + flt(ac[col.date + "_dr"]) - flt(ac[col.date + "_cr"]); me.set_debit_or_credit(ac, col.date, opening); From b20de6a3ecf7053ac9ccfb551ffe4899c32cf42c Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 17 Jun 2014 13:58:06 +0530 Subject: [PATCH 22/22] Sales Invoice List: show percent paid as 100% if grand total is 0 --- .../accounts/doctype/sales_invoice/sales_invoice_list.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js index 5592bc5220b..42c80b4e26b 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice_list.js @@ -7,8 +7,10 @@ frappe.listview_settings['Sales Invoice'] = { add_columns: [{"content":"Percent Paid", width:"10%", type:"bar-graph", label: "Payment Received"}], prepare_data: function(data) { - data["Percent Paid"] = (data.docstatus===1 && flt(data.grand_total)) - ? (((flt(data.grand_total) - flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) - : 0; + if (data.docstatus === 1) { + data["Percent Paid"] = flt(data.grand_total) + ? (((flt(data.grand_total) - flt(data.outstanding_amount)) / flt(data.grand_total)) * 100) + : 100.0; + } } };