From e6cee7b41f1c45563dfdf67d09fee6fc1d7c9b82 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Thu, 10 Jul 2014 19:06:39 +0530 Subject: [PATCH 1/8] Expense account can be liability account for stock reconciliation --- erpnext/controllers/stock_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index bb3ab69ca1..27437a396a 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -240,7 +240,7 @@ class StockController(AccountsController): else: is_expense_account = frappe.db.get_value("Account", item.get("expense_account"), "report_type")=="Profit and Loss" - if self.doctype != "Purchase Receipt" and not is_expense_account: + if self.doctype not in ("Purchase Receipt", "Stock Reconciliation") and not is_expense_account: frappe.throw(_("Expense / Difference account ({0}) must be a 'Profit or Loss' account") .format(item.get("expense_account"))) if is_expense_account and not item.get("cost_center"): From 614fb750b7fb883757f7b5c53ac97ff10ed8cf25 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 10:47:50 +0530 Subject: [PATCH 2/8] set qty as per stock uom in entire purchase cycle --- erpnext/controllers/buying_controller.py | 8 ++++++++ erpnext/stock/get_item_details.py | 1 + 2 files changed, 9 insertions(+) diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index afccdfa0e3..acb00245e6 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -17,6 +17,7 @@ class BuyingController(StockController): self.supplier_name = frappe.db.get_value("Supplier", self.supplier, "supplier_name") self.is_item_table_empty() + self.set_qty_as_per_stock_uom() self.validate_stock_or_nonstock_items() self.validate_warehouse() @@ -317,3 +318,10 @@ class BuyingController(StockController): def is_item_table_empty(self): if not len(self.get(self.fname)): frappe.throw(_("Item table can not be blank")) + + def set_qty_as_per_stock_uom(self): + for d in self.get(self.fname): + if d.meta.get_field("stock_qty") and not d.stock_qty: + if not d.conversion_factor: + frappe.throw(_("Row {0}: Conversion Factor is mandatory")) + d.stock_qty = flt(d.qty) * flt(d.conversion_factor) \ No newline at end of file diff --git a/erpnext/stock/get_item_details.py b/erpnext/stock/get_item_details.py index f9a1d9fa1a..82b396fb39 100644 --- a/erpnext/stock/get_item_details.py +++ b/erpnext/stock/get_item_details.py @@ -152,6 +152,7 @@ def get_basic_details(args, item_doc): "min_order_qty": flt(item.min_order_qty) if args.parenttype == "Material Request" else "", "conversion_factor": 1.0, "qty": 1.0, + "stock_qty": 1.0, "price_list_rate": 0.0, "base_price_list_rate": 0.0, "rate": 0.0, From 5c38488590d8398ce4bb242473884303b3661113 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 11:43:00 +0530 Subject: [PATCH 3/8] Utility: reset serial no status and warehouse --- erpnext/utilities/repost_stock.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index e4028b69f6..1c6782ad36 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -190,3 +190,18 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin "posting_date": posting_date, "posting_time": posting_time }) + +def reset_serial_no_status_and_warehouse(serial_nos=[]): + if not serial_nos: + serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use' + and docstatus = 0""") + for serial_no in serial_nos: + try: + sr = frappe.get_doc("Serial No", serial_no) + sr.via_stock_ledger = True + sr.save() + except: + pass + + frappe.db.sql("""update `tabSerial No` set warehouse='' where status in ('Delivered', 'Purchase Returned')""") + \ No newline at end of file From b0a8d000b1c1d7551fc37d6df8e95e1b37a5da94 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 11:56:03 +0530 Subject: [PATCH 4/8] Utility: reset serial no status and warehouse --- erpnext/utilities/repost_stock.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index 1c6782ad36..4205893893 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -198,6 +198,10 @@ def reset_serial_no_status_and_warehouse(serial_nos=[]): for serial_no in serial_nos: try: sr = frappe.get_doc("Serial No", serial_no) + last_sle = sr.get_last_sle() + if flt(last_sle.actual_qty) > 0: + sr.warehouse = last_sle.warehouse + sr.via_stock_ledger = True sr.save() except: From d5fd5359095dabe9ee9e4c145d470a926ffc0446 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 12:39:50 +0530 Subject: [PATCH 5/8] Minor fix, if no default company --- erpnext/public/js/queries.js | 2 +- erpnext/stock/doctype/stock_entry/stock_entry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/public/js/queries.js b/erpnext/public/js/queries.js index b57b765ad6..4bb3302bd8 100644 --- a/erpnext/public/js/queries.js +++ b/erpnext/public/js/queries.js @@ -71,7 +71,7 @@ $.extend(erpnext.queries, { warehouse: function(doc) { return { - filters: [["Warehouse", "company", "in", ["", doc.company]]] + filters: [["Warehouse", "company", "in", ["", cstr(doc.company)]]] } } }); diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js index 10241983ad..7274ece1fa 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.js +++ b/erpnext/stock/doctype/stock_entry/stock_entry.js @@ -92,7 +92,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ set_default_account: function() { var me = this; - if(cint(frappe.defaults.get_default("auto_accounting_for_stock"))) { + if(cint(frappe.defaults.get_default("auto_accounting_for_stock")) && this.frm.doc.company) { var account_for = "stock_adjustment_account"; if (this.frm.doc.purpose == "Purchase Return") From e8c5cb8c9a7487e59b1205f106117c7cc4061f82 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jul 2014 13:10:24 +0530 Subject: [PATCH 6/8] Fixed Address and Contact report name --- erpnext/config/buying.py | 2 +- erpnext/config/selling.py | 2 +- .../customer_addresses_and_contacts.json | 30 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/erpnext/config/buying.py b/erpnext/config/buying.py index bc6251982b..1b9e5a23b0 100644 --- a/erpnext/config/buying.py +++ b/erpnext/config/buying.py @@ -150,7 +150,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Supplier Addresses And Contacts", + "name": "Supplier Addresses and Contacts", "doctype": "Supplier" }, { diff --git a/erpnext/config/selling.py b/erpnext/config/selling.py index 200ab6d4ba..c95f15aa83 100644 --- a/erpnext/config/selling.py +++ b/erpnext/config/selling.py @@ -206,7 +206,7 @@ def get_data(): { "type": "report", "is_query_report": True, - "name": "Customer Addresses And Contacts", + "name": "Customer Addresses and Contacts", "doctype": "Contact" }, { diff --git a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json index 9bde272c61..deb90b71cd 100644 --- a/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json +++ b/erpnext/selling/report/customer_addresses_and_contacts/customer_addresses_and_contacts.json @@ -1,17 +1,17 @@ { - "apply_user_permissions": 1, - "creation": "2012-10-04 18:45:27", - "docstatus": 0, - "doctype": "Report", - "idx": 1, - "is_standard": "Yes", - "modified": "2014-06-03 07:18:17.006732", - "modified_by": "Administrator", - "module": "Selling", - "name": "Customer Addresses And Contacts", - "owner": "Administrator", - "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", - "ref_doctype": "Customer", - "report_name": "Customer Addresses And Contacts", + "apply_user_permissions": 1, + "creation": "2012-10-04 18:45:27", + "docstatus": 0, + "doctype": "Report", + "idx": 1, + "is_standard": "Yes", + "modified": "2014-07-14 07:18:17.006732", + "modified_by": "Administrator", + "module": "Selling", + "name": "Customer Addresses and Contacts", + "owner": "Administrator", + "query": "SELECT\n\t`tabCustomer`.name as customer_id,\n\t`tabCustomer`.customer_name,\n\t`tabCustomer`.customer_group,\n\t`tabAddress`.address_line1,\n\t`tabAddress`.address_line2,\n\t`tabAddress`.city,\n\t`tabAddress`.state,\n\t`tabAddress`.pincode,\n\t`tabAddress`.country,\n\t`tabAddress`.is_primary_address, \n\t`tabContact`.first_name,\n\t`tabContact`.last_name,\n\t`tabContact`.phone,\n\t`tabContact`.mobile_no,\n\t`tabContact`.email_id,\n\t`tabContact`.is_primary_contact\nFROM\n\t`tabCustomer`\n\tleft join `tabAddress` on (\n\t\t`tabAddress`.customer=`tabCustomer`.name\n\t)\n\tleft join `tabContact` on (\n\t\t`tabContact`.customer=`tabCustomer`.name\n\t)\nWHERE\n\t`tabCustomer`.docstatus<2\nORDER BY\n\t`tabCustomer`.name asc", + "ref_doctype": "Customer", + "report_name": "Customer Addresses And Contacts", "report_type": "Query Report" -} \ No newline at end of file +} From 7700c62fa8ec7290ef2aaeaab975bd55cfee3e16 Mon Sep 17 00:00:00 2001 From: nabinhait Date: Mon, 14 Jul 2014 14:21:21 +0530 Subject: [PATCH 7/8] Minor fix --- erpnext/utilities/repost_stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/utilities/repost_stock.py b/erpnext/utilities/repost_stock.py index 4205893893..159825a495 100644 --- a/erpnext/utilities/repost_stock.py +++ b/erpnext/utilities/repost_stock.py @@ -191,7 +191,7 @@ def set_stock_balance_as_per_serial_no(item_code=None, posting_date=None, postin "posting_time": posting_time }) -def reset_serial_no_status_and_warehouse(serial_nos=[]): +def reset_serial_no_status_and_warehouse(serial_nos=None): if not serial_nos: serial_nos = frappe.db.sql_list("""select name from `tabSerial No` where status != 'Not in Use' and docstatus = 0""") From 1829bd84d3d2d388583548a6b73e9cf85959bfe2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Mon, 14 Jul 2014 14:26:28 +0530 Subject: [PATCH 8/8] hotfix: website_image --- erpnext/setup/doctype/item_group/item_group.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/setup/doctype/item_group/item_group.py b/erpnext/setup/doctype/item_group/item_group.py index 745345e58a..c6f49a1546 100644 --- a/erpnext/setup/doctype/item_group/item_group.py +++ b/erpnext/setup/doctype/item_group/item_group.py @@ -82,7 +82,7 @@ def get_child_groups(item_group_name): def get_item_for_list_in_html(context): # add missing absolute link in files # user may forget it during upload - if context.get("website_image", "").startswith("files/"): + if (context.get("website_image") or "").startswith("files/"): context["website_image"] = "/" + context["website_image"] return frappe.get_template("templates/includes/product_in_grid.html").render(context)