From c5570c6341a0548a37400f20a1ef10d744458264 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 15:21:24 +0530 Subject: [PATCH 1/6] added warehouse company validation, if warehouse is added to company --- accounts/doctype/journal_voucher/journal_voucher.py | 5 +++++ setup/doctype/company/test_company.py | 6 ++++++ stock/doctype/stock_entry/test_stock_entry.py | 9 ++++++++- stock/doctype/stock_ledger_entry/stock_ledger_entry.py | 10 +++++++++- stock/doctype/warehouse/test_warehouse.py | 8 +++++++- 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index f4bd55cdbf..c58e9bae4c 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -67,6 +67,11 @@ class DocType(AccountsController): remove_against_link_from_jv(self.doc.doctype, self.doc.name, "against_jv") self.make_gl_entries(cancel=1) + + def on_trash(self): + pass + #if self.doc.amended_from: + # webnotes.delete_doc("Journal Voucher", self.doc.amended_from) def validate_debit_credit(self): for d in getlist(self.doclist, 'entries'): diff --git a/setup/doctype/company/test_company.py b/setup/doctype/company/test_company.py index fe793ffce4..6a174ec80f 100644 --- a/setup/doctype/company/test_company.py +++ b/setup/doctype/company/test_company.py @@ -7,4 +7,10 @@ test_records = [ "abbr": "_TC", "default_currency": "INR", }], + [{ + "doctype": "Company", + "company_name": "_Test Company 1", + "abbr": "_TC1", + "default_currency": "USD", + }], ] \ No newline at end of file diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py index ded71db26b..25018930dd 100644 --- a/stock/doctype/stock_entry/test_stock_entry.py +++ b/stock/doctype/stock_entry/test_stock_entry.py @@ -25,7 +25,14 @@ class TestStockEntry(unittest.TestCase): where item_code='_Test Item'""") self.assertTrue(mr_name) - + + def test_warehouse_company_validation(self): + from stock.doctype.stock_ledger_entry.stock_ledger_entry import InvalidWarehouseCompany + st1 = webnotes.bean(copy=test_records[0]) + st1.doclist[1].t_warehouse="_Test Warehouse 2" + st1.insert() + self.assertRaises(InvalidWarehouseCompany, st1.submit) + def test_material_receipt_gl_entry(self): webnotes.conn.sql("delete from `tabStock Ledger Entry`") webnotes.defaults.set_global_default("auto_inventory_accounting", 1) diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 3089a57081..5ca7dd5bed 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -24,7 +24,7 @@ sql = webnotes.conn.sql msgprint = webnotes.msgprint from accounts.utils import get_fiscal_year - +class InvalidWarehouseCompany(Exception): pass class DocType: def __init__(self, doc, doclist=[]): @@ -35,6 +35,7 @@ class DocType: self.validate_mandatory() self.validate_item() self.validate_warehouse_user() + self.validate_warehouse_company() self.actual_amt_check() self.check_stock_frozen_date() self.scrub_posting_time() @@ -63,6 +64,13 @@ class DocType: webnotes.msgprint(_("User not allowed entry in the Warehouse") \ + ": " + webnotes.session.user + " / " + self.doc.warehouse, raise_exception = 1) + def validate_warehouse_company(self): + warehouse_company = webnotes.conn.get_value("Warehouse", self.doc.warehouse, "company") + if warehouse_company and warehouse_company != self.doc.company: + webnotes.msgprint(_("Warehouse does not belong to company.") + " (" + \ + self.doc.warehouse + ", " + self.doc.company +")", + raise_exception=InvalidWarehouseCompany) + def validate_mandatory(self): mandatory = ['warehouse','posting_date','voucher_type','voucher_no','actual_qty','company'] for k in mandatory: diff --git a/stock/doctype/warehouse/test_warehouse.py b/stock/doctype/warehouse/test_warehouse.py index 99f29c1cc8..26501beab9 100644 --- a/stock/doctype/warehouse/test_warehouse.py +++ b/stock/doctype/warehouse/test_warehouse.py @@ -7,6 +7,12 @@ test_records = [ [{ "doctype": "Warehouse", "warehouse_name": "_Test Warehouse 1", - "warehouse_type": "_Test Warehouse Type" + "warehouse_type": "_Test Warehouse Type", + }], + [{ + "doctype": "Warehouse", + "warehouse_name": "_Test Warehouse 2", + "warehouse_type": "_Test Warehouse Type", + "company": "_Test Company 1" }] ] From df8b652402c616514cbedf78dd8c7ad48340633b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 15:44:36 +0530 Subject: [PATCH 2/6] [accounts] [feature] added default_cash_account in company and gets set in Journal Voucher --- accounts/__init__.py | 34 ------------------ .../journal_voucher/journal_voucher.js | 36 ++++++++++--------- .../journal_voucher/journal_voucher.py | 4 +++ setup/doctype/company/company.js | 4 +++ setup/doctype/company/company.txt | 33 ++++++++++++----- 5 files changed, 52 insertions(+), 59 deletions(-) diff --git a/accounts/__init__.py b/accounts/__init__.py index 145ad6b869..e69de29bb2 100644 --- a/accounts/__init__.py +++ b/accounts/__init__.py @@ -1,34 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes -from webnotes.utils import flt -from webnotes.model.code import get_obj -from accounts.utils import get_balance_on - -@webnotes.whitelist() -def get_default_bank_account(): - """ - Get default bank account for a company - """ - company = webnotes.form_dict.get('company') - if not company: return - res = webnotes.conn.sql("""\ - SELECT default_bank_account FROM `tabCompany` - WHERE name=%s AND docstatus<2""", company) - - if res: return res[0][0] diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 80c46cab81..811bc50b80 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -137,23 +137,27 @@ cur_frm.cscript.view_ledger_entry = function(doc,cdt,cdn){ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { - if(doc.voucher_type == 'Bank Voucher' && cstr(doc.company)) { - cur_frm.set_df_property("cheque_no", "reqd", true); - cur_frm.set_df_property("cheque_date", "reqd", true); - - var children = getchildren('Journal Voucher Detail', doc.name, 'entries'); - if(!children || children.length==0) { - $c('accounts.get_default_bank_account', {company: doc.company }, function(r, rt) { - if(!r.exc) { - var jvd = wn.model.add_child(doc, 'Journal Voucher Detail', 'entries'); - jvd.account = cstr(r.message); - refresh_field('entries'); + cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); + cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); + + if(in_list(["Bank Voucher", "Cash Voucher"], doc.voucher_type) + && doc.company + && wn.model.get("Journal Voucher Detail", {"parent":doc.name}).length==0) { + wn.call({ + type: "GET", + method: "accounts.doctype.journal_voucher.journal_voucher.get_default_bank_cash_account", + args: { + "voucher_type": doc.voucher_type, + "company": doc.company + }, + callback: function(r) { + if(r.message) { + var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); + jvdetail.account = r.message || ""; + refresh_field("entries"); } - }); - } - } else { - cur_frm.set_df_property("cheque_no", "reqd", false); - cur_frm.set_df_property("cheque_date", "reqd", false); + } + }) } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index c58e9bae4c..4078701ff9 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -349,6 +349,10 @@ class DocType(AccountsController): from `tabPurchase Invoice` where docstatus = 1 and company = %s and outstanding_amount > 0 %s""" % ('%s', cond), self.doc.company) +@webnotes.whitelist() +def get_default_bank_cash_account(company, voucher_type): + return webnotes.conn.get_value("Company", company, + voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account") def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js index a89882347e..97fc5c7f75 100644 --- a/setup/doctype/company/company.js +++ b/setup/doctype/company/company.js @@ -49,6 +49,10 @@ cur_frm.fields_dict.default_bank_account.get_query = function(doc) { return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50'; } +cur_frm.fields_dict.default_cash_account.get_query = function(doc) { + return 'SELECT `tabAccount`.name, `tabAccount`.debit_or_credit, `tabAccount`.group_or_ledger FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Ledger" AND `tabAccount`.docstatus != 2 AND `tabAccount`.account_type = "Bank or Cash" AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50'; +} + cur_frm.fields_dict.receivables_group.get_query = function(doc) { return 'SELECT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.company = "'+doc.name+'" AND `tabAccount`.group_or_ledger = "Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.%(key)s LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50'; diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt index 4d2dcdae68..1dfbe2f8c1 100644 --- a/setup/doctype/company/company.txt +++ b/setup/doctype/company/company.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-02-27 09:38:05", + "creation": "2013-03-21 17:41:00", "docstatus": 0, - "modified": "2013-03-19 12:52:00", + "modified": "2013-03-25 15:35:34", "modified_by": "Administrator", "owner": "Administrator" }, @@ -25,19 +25,14 @@ }, { "amend": 0, - "cancel": 1, - "create": 1, "doctype": "DocPerm", "name": "__common__", "parent": "Company", "parentfield": "permissions", "parenttype": "DocType", - "permlevel": 0, "read": 1, "report": 1, - "role": "System Manager", - "submit": 0, - "write": 1 + "submit": 0 }, { "doctype": "DocType", @@ -102,6 +97,13 @@ "oldfieldtype": "Link", "options": "Account" }, + { + "doctype": "DocField", + "fieldname": "default_cash_account", + "fieldtype": "Link", + "label": "Default Cash Account", + "options": "Account" + }, { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", @@ -307,6 +309,19 @@ "read_only": 1 }, { - "doctype": "DocPerm" + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "permlevel": 0, + "role": "System Manager", + "write": 1 + }, + { + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "permlevel": 1, + "role": "All", + "write": 0 } ] \ No newline at end of file From 2f8ad5e5c1781db7dab62d701575d357a349c5bb Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 15:48:57 +0530 Subject: [PATCH 3/6] [accounts] [feature] added default_cash_account in company and gets set in Journal Voucher --- accounts/doctype/journal_voucher/journal_voucher.js | 3 ++- accounts/doctype/journal_voucher/journal_voucher.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 811bc50b80..4edbed56cd 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -153,7 +153,8 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { callback: function(r) { if(r.message) { var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); - jvdetail.account = r.message || ""; + jvdetail.account = r.message.account; + jvdetail.balance = r.message.balance; refresh_field("entries"); } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index 4078701ff9..812ab7d0be 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -351,8 +351,14 @@ class DocType(AccountsController): @webnotes.whitelist() def get_default_bank_cash_account(company, voucher_type): - return webnotes.conn.get_value("Company", company, + from accounts.utils import get_balance_on + account = webnotes.conn.get_value("Company", company, voucher_type=="Bank Voucher" and "default_bank_account" or "default_cash_account") + if account: + return { + "account": account, + "balance": get_balance_on(account) + } def get_against_purchase_invoice(doctype, txt, searchfield, start, page_len, filters): return webnotes.conn.sql("""select name, credit_to, outstanding_amount, bill_no, bill_date From e97ce3475d4d6f76876d366c68057a103efe198a Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 15:55:24 +0530 Subject: [PATCH 4/6] [accounts] [feature] added default_cash_account in company and gets set in Journal Voucher --- accounts/doctype/journal_voucher/journal_voucher.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 4edbed56cd..82322c89ec 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -154,7 +154,8 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { if(r.message) { var jvdetail = wn.model.add_child(doc, "Journal Voucher Detail", "entries"); jvdetail.account = r.message.account; - jvdetail.balance = r.message.balance; + // this is a data field???? + jvdetail.balance = format_currency(r.message.balance); refresh_field("entries"); } } From 06d186ba98ec05b2f9224b7cc30c382602c39350 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 17:03:52 +0530 Subject: [PATCH 5/6] [stock] [feature] added project to stock ledger entry and updated stock balance report --- .../doctype/sales_invoice/sales_invoice.py | 33 ++++++----- .../p07_update_project_in_stock_ledger.py | 42 ++++++++++++++ patches/patch_list.py | 4 +- startup/report_data_map.py | 10 +++- stock/doctype/delivery_note/delivery_note.py | 3 +- .../purchase_receipt/purchase_receipt.py | 31 +++++----- stock/doctype/stock_entry/stock_entry.py | 3 +- .../stock_ledger_entry/stock_ledger_entry.txt | 58 ++++++++++++++----- stock/page/stock_balance/stock_balance.js | 9 ++- .../style_settings/custom_template.css | 1 - .../doctype/style_settings/style_settings.py | 2 +- 11 files changed, 142 insertions(+), 54 deletions(-) create mode 100644 patches/march_2013/p07_update_project_in_stock_ledger.py diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 9b5c80cfbb..4b926439a2 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -608,22 +608,23 @@ class DocType(SellingController): def make_sl_entry(self, d, wh, qty, in_value, update_stock): st_uom = webnotes.conn.sql("select stock_uom from `tabItem` where name = '%s'"%d['item_code']) self.values.append({ - 'item_code' : d['item_code'], - 'warehouse' : wh, - 'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'), - 'posting_date' : self.doc.posting_date, - 'posting_time' : self.doc.posting_time, - 'voucher_type' : 'Sales Invoice', - 'voucher_no' : cstr(self.doc.name), - 'voucher_detail_no' : cstr(d['name']), - 'actual_qty' : qty, - 'stock_uom' : st_uom and st_uom[0][0] or '', - 'incoming_rate' : in_value, - 'company' : self.doc.company, - 'fiscal_year' : self.doc.fiscal_year, - 'is_cancelled' : (update_stock==1) and 'No' or 'Yes', - 'batch_no' : cstr(d['batch_no']), - 'serial_no' : d['serial_no'] + 'item_code' : d['item_code'], + 'warehouse' : wh, + 'transaction_date' : getdate(self.doc.modified).strftime('%Y-%m-%d'), + 'posting_date' : self.doc.posting_date, + 'posting_time' : self.doc.posting_time, + 'voucher_type' : 'Sales Invoice', + 'voucher_no' : cstr(self.doc.name), + 'voucher_detail_no' : cstr(d['name']), + 'actual_qty' : qty, + 'stock_uom' : st_uom and st_uom[0][0] or '', + 'incoming_rate' : in_value, + 'company' : self.doc.company, + 'fiscal_year' : self.doc.fiscal_year, + 'is_cancelled' : (update_stock==1) and 'No' or 'Yes', + 'batch_no' : cstr(d['batch_no']), + 'serial_no' : d['serial_no'], + "project" : self.doc.project_name }) def update_stock_ledger(self, update_stock): diff --git a/patches/march_2013/p07_update_project_in_stock_ledger.py b/patches/march_2013/p07_update_project_in_stock_ledger.py new file mode 100644 index 0000000000..ad4d639da9 --- /dev/null +++ b/patches/march_2013/p07_update_project_in_stock_ledger.py @@ -0,0 +1,42 @@ +import webnotes + +def execute(): + webnotes.reload_doc("stock", "doctype", "stock_ledger_entry") + + # from stock entry + webnotes.conn.sql("""update + `tabStock Ledger Entry` sle, + `tabStock Entry` st + set sle.project = st.project_name + where + sle.voucher_type = "Stock Entry" + and sle.voucher_no = st.name""") + + # from purchase + webnotes.conn.sql("""update + `tabStock Ledger Entry` sle, + `tabPurchase Receipt Item` pri + set sle.project = pri.project_name + where + sle.voucher_type = "Purchase Receipt" + and sle.voucher_detail_no = pri.name""") + + # from delivery note + webnotes.conn.sql("""update + `tabStock Ledger Entry` sle, + `tabDelivery Note` dn + set sle.project = dn.project_name + where + sle.voucher_type = "Delivery Note" + and sle.voucher_no = dn.name""") + + # from pos invoice + webnotes.conn.sql("""update + `tabStock Ledger Entry` sle, + `tabSales Invoice` si + set sle.project = si.project_name + where + sle.voucher_type = "Sales Invoice" + and sle.voucher_no = si.name""") + + \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 9c0d9b8199..fc9855d096 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -214,5 +214,7 @@ patch_list = [ "patches.march_2013.p04_pos_update_stock_check", "patches.march_2013.p05_payment_reconciliation", "patches.march_2013.p06_remove_sales_purchase_return_tool", - "execute:webnotes.bean('Global Defaults').save()" + "execute:webnotes.bean('Global Defaults').save()", + "patches.march_2013.p07_update_project_in_stock_ledger", + "execute:webnotes.bean('Style Settings').save() #2013-03-25", ] \ No newline at end of file diff --git a/startup/report_data_map.py b/startup/report_data_map.py index f914277cc3..501db4f6ce 100644 --- a/startup/report_data_map.py +++ b/startup/report_data_map.py @@ -80,6 +80,11 @@ data_map = { "conditions": ["docstatus < 2"], "order_by": "name" }, + "Project": { + "columns": ["name"], + "conditions": ["docstatus < 2"], + "order_by": "name" + }, "Warehouse": { "columns": ["name"], "conditions": ["docstatus < 2"], @@ -87,13 +92,14 @@ data_map = { }, "Stock Ledger Entry": { "columns": ["name", "posting_date", "posting_time", "item_code", "warehouse", - "actual_qty as qty", "voucher_type", "voucher_no", + "actual_qty as qty", "voucher_type", "voucher_no", "project", "ifnull(incoming_rate,0) as incoming_rate", "stock_uom", "serial_no"], "conditions": ["ifnull(is_cancelled, 'No')='No'"], "order_by": "posting_date, posting_time, name", "links": { "item_code": ["Item", "name"], - "warehouse": ["Warehouse", "name"] + "warehouse": ["Warehouse", "name"], + "project": ["Project", "name"] }, "force_index": "posting_sort_index" }, diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index 5e3c9e94fe..90b0ba7e2d 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -387,7 +387,8 @@ class DocType(SellingController): 'fiscal_year' : self.doc.fiscal_year, 'is_cancelled' : (update_stock==1) and 'No' or 'Yes', 'batch_no' : d['batch_no'], - 'serial_no' : d['serial_no'] + 'serial_no' : d['serial_no'], + "project" : self.doc.project_name }) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 7949a1c1c3..4a52a5f692 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -196,21 +196,22 @@ class DocType(BuyingController): serial_no = cstr(d.serial_no).strip() self.values.append({ - 'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code, - 'warehouse' : wh, - 'posting_date' : self.doc.posting_date, - 'posting_time' : self.doc.posting_time, - 'voucher_type' : 'Purchase Receipt', - 'voucher_no' : self.doc.name, - 'voucher_detail_no' : d.name, - 'actual_qty' : qty, - 'stock_uom' : d.stock_uom, - 'incoming_rate' : in_value, - 'company' : self.doc.company, - 'fiscal_year' : self.doc.fiscal_year, - 'is_cancelled' : (is_submit==1) and 'No' or 'Yes', - 'batch_no' : cstr(d.batch_no).strip(), - 'serial_no' : serial_no + 'item_code' : d.fields.has_key('item_code') and d.item_code or d.rm_item_code, + 'warehouse' : wh, + 'posting_date' : self.doc.posting_date, + 'posting_time' : self.doc.posting_time, + 'voucher_type' : 'Purchase Receipt', + 'voucher_no' : self.doc.name, + 'voucher_detail_no' : d.name, + 'actual_qty' : qty, + 'stock_uom' : d.stock_uom, + 'incoming_rate' : in_value, + 'company' : self.doc.company, + 'fiscal_year' : self.doc.fiscal_year, + 'is_cancelled' : (is_submit==1) and 'No' or 'Yes', + 'batch_no' : cstr(d.batch_no).strip(), + 'serial_no' : serial_no, + "project" : d.project_name }) diff --git a/stock/doctype/stock_entry/stock_entry.py b/stock/doctype/stock_entry/stock_entry.py index f54ce605a0..e79e989883 100644 --- a/stock/doctype/stock_entry/stock_entry.py +++ b/stock/doctype/stock_entry/stock_entry.py @@ -604,7 +604,8 @@ class DocType(StockController): 'company': self.doc.company, 'is_cancelled': (is_cancelled ==1) and 'Yes' or 'No', 'batch_no': cstr(d.batch_no).strip(), - 'serial_no': cstr(d.serial_no).strip() + 'serial_no': cstr(d.serial_no).strip(), + "project": self.doc.project_name }) def get_cust_values(self): diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt index 9551b59314..6bcd758733 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.txt @@ -1,8 +1,8 @@ [ { - "creation": "2013-01-14 16:33:26", + "creation": "2013-01-29 19:25:42", "docstatus": 0, - "modified": "2013-01-29 16:27:57", + "modified": "2013-03-25 16:04:59", "modified_by": "Administrator", "owner": "Administrator" }, @@ -24,13 +24,9 @@ "parent": "Stock Ledger Entry", "parentfield": "fields", "parenttype": "DocType", - "permlevel": 0, - "read_only": 1 + "permlevel": 0 }, { - "amend": 0, - "cancel": 0, - "create": 0, "doctype": "DocPerm", "name": "__common__", "parent": "Stock Ledger Entry", @@ -39,9 +35,7 @@ "permlevel": 0, "read": 1, "report": 1, - "role": "Material User", - "submit": 0, - "write": 0 + "submit": 0 }, { "doctype": "DocType", @@ -57,6 +51,7 @@ "oldfieldtype": "Link", "options": "Item", "print_width": "100px", + "read_only": 1, "reqd": 0, "search_index": 1, "width": "100px" @@ -68,6 +63,7 @@ "in_filter": 0, "label": "Serial No", "print_width": "100px", + "read_only": 1, "search_index": 0, "width": "100px" }, @@ -77,7 +73,8 @@ "fieldtype": "Data", "label": "Batch No", "oldfieldname": "batch_no", - "oldfieldtype": "Data" + "oldfieldtype": "Data", + "read_only": 1 }, { "doctype": "DocField", @@ -89,6 +86,7 @@ "oldfieldtype": "Link", "options": "Warehouse", "print_width": "100px", + "read_only": 1, "search_index": 1, "width": "100px" }, @@ -101,6 +99,7 @@ "oldfieldname": "warehouse_type", "oldfieldtype": "Select", "options": "link:Warehouse Type", + "read_only": 1, "search_index": 0 }, { @@ -113,6 +112,7 @@ "oldfieldname": "posting_date", "oldfieldtype": "Date", "print_width": "100px", + "read_only": 1, "reqd": 0, "search_index": 1, "width": "100px" @@ -126,6 +126,7 @@ "oldfieldname": "posting_time", "oldfieldtype": "Time", "print_width": "100px", + "read_only": 1, "search_index": 0, "width": "100px" }, @@ -138,6 +139,7 @@ "oldfieldname": "voucher_type", "oldfieldtype": "Data", "print_width": "150px", + "read_only": 1, "search_index": 0, "width": "150px" }, @@ -150,6 +152,7 @@ "oldfieldname": "voucher_no", "oldfieldtype": "Data", "print_width": "150px", + "read_only": 1, "search_index": 0, "width": "150px" }, @@ -161,6 +164,7 @@ "oldfieldname": "voucher_detail_no", "oldfieldtype": "Data", "print_width": "150px", + "read_only": 1, "width": "150px" }, { @@ -172,6 +176,7 @@ "oldfieldname": "actual_qty", "oldfieldtype": "Currency", "print_width": "150px", + "read_only": 1, "width": "150px" }, { @@ -181,7 +186,8 @@ "label": "Incoming Rate", "oldfieldname": "incoming_rate", "oldfieldtype": "Currency", - "options": "Company:company:default_currency" + "options": "Company:company:default_currency", + "read_only": 1 }, { "doctype": "DocField", @@ -191,6 +197,7 @@ "oldfieldname": "stock_uom", "oldfieldtype": "Data", "print_width": "150px", + "read_only": 1, "width": "150px" }, { @@ -202,6 +209,7 @@ "oldfieldname": "bin_aqat", "oldfieldtype": "Currency", "print_width": "150px", + "read_only": 1, "width": "150px" }, { @@ -213,6 +221,7 @@ "oldfieldtype": "Currency", "options": "Company:company:default_currency", "print_width": "150px", + "read_only": 1, "width": "150px" }, { @@ -222,7 +231,8 @@ "label": "Stock Value", "oldfieldname": "stock_value", "oldfieldtype": "Currency", - "options": "Company:company:default_currency" + "options": "Company:company:default_currency", + "read_only": 1 }, { "doctype": "DocField", @@ -234,9 +244,17 @@ "oldfieldname": "fcfs_stack", "oldfieldtype": "Text", "print_hide": 1, + "read_only": 1, "report_hide": 1, "search_index": 0 }, + { + "doctype": "DocField", + "fieldname": "project", + "fieldtype": "Link", + "label": "Project", + "options": "Project" + }, { "doctype": "DocField", "fieldname": "company", @@ -247,6 +265,7 @@ "oldfieldtype": "Data", "options": "link:Company", "print_width": "150px", + "read_only": 1, "search_index": 0, "width": "150px" }, @@ -259,6 +278,7 @@ "oldfieldname": "fiscal_year", "oldfieldtype": "Data", "print_width": "150px", + "read_only": 1, "search_index": 0, "width": "150px" }, @@ -272,10 +292,20 @@ "oldfieldtype": "Select", "options": "\nYes\nNo", "print_width": "100px", + "read_only": 1, "search_index": 0, "width": "100px" }, { - "doctype": "DocPerm" + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "role": "Material User", + "write": 0 + }, + { + "doctype": "DocPerm", + "role": "Accounts Manager" } ] \ No newline at end of file diff --git a/stock/page/stock_balance/stock_balance.js b/stock/page/stock_balance/stock_balance.js index 47a3344b29..163b74f629 100644 --- a/stock/page/stock_balance/stock_balance.js +++ b/stock/page/stock_balance/stock_balance.js @@ -35,7 +35,7 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ this._super(wrapper, { title: "Stock Balance", doctypes: ["Item", "Item Group", "Warehouse", "Stock Ledger Entry", "Brand", - "Stock Entry"], + "Stock Entry", "Project"], }); }, setup_columns: function() { @@ -76,6 +76,10 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ default_value: "Select Warehouse...", filter: function(val, item, opts, me) { return me.apply_zero_filter(val, item, opts, me); }}, + {fieldtype:"Select", label: "Project", link:"Project", + default_value: "Select Project...", filter: function(val, item, opts, me) { + return me.apply_zero_filter(val, item, opts, me); + }, link_formatter: {filter_input: "project"}}, {fieldtype:"Date", label: "From Date"}, {fieldtype:"Label", label: "To"}, {fieldtype:"Date", label: "To Date"}, @@ -105,7 +109,8 @@ erpnext.StockBalance = erpnext.StockAnalytics.extend({ var sl = data[i]; var sl_posting_date = dateutil.str_to_obj(sl.posting_date); - if(me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) { + if((me.is_default("warehouse") ? true : me.warehouse == sl.warehouse) && + (me.is_default("project") ? true : me.project == sl.project)) { var item = me.item_by_name[sl.item_code]; var wh = me.get_item_warehouse(sl.warehouse, sl.item_code); var valuation_method = item.valuation_method ? diff --git a/website/doctype/style_settings/custom_template.css b/website/doctype/style_settings/custom_template.css index 712c748cb8..e2c0db598a 100644 --- a/website/doctype/style_settings/custom_template.css +++ b/website/doctype/style_settings/custom_template.css @@ -69,7 +69,6 @@ div.web-footer, div.web-footer a { .navbar-inverse .navbar-inner { background-color: #{{ doc.top_bar_background or "444444"}}; background-repeat: repeat-x; - border-color: transparent; background-image: none; } diff --git a/website/doctype/style_settings/style_settings.py b/website/doctype/style_settings/style_settings.py index 71478a4573..58dca7b6a0 100644 --- a/website/doctype/style_settings/style_settings.py +++ b/website/doctype/style_settings/style_settings.py @@ -85,7 +85,7 @@ class DocType: "UPPERCASE": "uppercase", "Title Case":"capitalize", "lowercase": "lowercase" - }[self.doc.heading_text_as] + }.get(self.doc.heading_text_as) or "" self.doc.at_import = "" for f in fonts: From 74506e96d35eeae05dd23d9593cb0d055fc6ade9 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 25 Mar 2013 17:52:14 +0530 Subject: [PATCH 6/6] [profile/email] [feature] added option not to send print as email body. fix in profile delete --- accounts/page/accounts_home/accounts_home.js | 10 ++++ buying/doctype/supplier/supplier.py | 14 ++++- patches/patch_list.py | 1 + .../doctype/email_settings/email_settings.txt | 27 +++++---- startup/boot.py | 50 +++++++++++++++++ startup/event_handlers.py | 56 +++---------------- 6 files changed, 94 insertions(+), 64 deletions(-) create mode 100644 startup/boot.py diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 403d7bdb3f..9981ee9a97 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -39,6 +39,16 @@ wn.module_page["Accounts"] = [ description: wn._("Structure cost centers for budgeting."), doctype:"Cost Center" }, + { + label: wn._("Customer"), + description: wn._("Customer database."), + doctype:"Customer" + }, + { + label: wn._("Supplier"), + description: wn._("Supplier database."), + doctype:"Supplier" + }, ] }, { diff --git a/buying/doctype/supplier/supplier.py b/buying/doctype/supplier/supplier.py index 3af63b022a..6658db3135 100644 --- a/buying/doctype/supplier/supplier.py +++ b/buying/doctype/supplier/supplier.py @@ -106,9 +106,9 @@ class DocType(TransactionBase): def create_account_head(self): if self.doc.company : abbr = self.get_company_abbr() + parent_account = self.get_parent_account(abbr) if not sql("select name from tabAccount where name=%s", (self.doc.name + " - " + abbr)): - parent_account = self.get_parent_account(abbr) ac = add_ac({ 'account_name': self.doc.name, @@ -121,10 +121,18 @@ class DocType(TransactionBase): 'master_name': self.doc.name, }) msgprint(_("Created Account Head: ") + ac) - + else: + self.check_parent_account(parent_account, abbr) else : msgprint("Please select Company under which you want to create account head") - + + def check_parent_account(self, parent_account, abbr): + if webnotes.conn.get_value("Account", self.doc.name + " - " + abbr, + "parent_account") != parent_account: + ac = webnotes.bean("Account", self.doc.name + " - " + abbr) + ac.doc.parent_account = parent_account + ac.save() + def get_contacts(self,nm): if nm: contact_details =webnotes.conn.convert_to_lists(sql("select name, CONCAT(IFNULL(first_name,''),' ',IFNULL(last_name,'')),contact_no,email_id from `tabContact` where supplier = '%s'"%nm)) diff --git a/patches/patch_list.py b/patches/patch_list.py index fc9855d096..00dd5da200 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -217,4 +217,5 @@ patch_list = [ "execute:webnotes.bean('Global Defaults').save()", "patches.march_2013.p07_update_project_in_stock_ledger", "execute:webnotes.bean('Style Settings').save() #2013-03-25", + "execute:webnotes.conn.set_value('Email Settings', None, 'send_print_in_body_and_attachment', 1)" ] \ 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 994d4c9100..1de2c93045 100644 --- a/setup/doctype/email_settings/email_settings.txt +++ b/setup/doctype/email_settings/email_settings.txt @@ -1,13 +1,12 @@ [ { - "creation": "2012-07-03 13:30:55", + "creation": "2012-07-12 23:29:44", "docstatus": 0, - "modified": "2012-07-12 16:16:27", + "modified": "2013-03-25 17:32:05", "modified_by": "Administrator", "owner": "harshada@webnotestech.com" }, { - "_last_update": "1325570647", "allow_copy": 1, "allow_email": 1, "allow_print": 1, @@ -16,9 +15,7 @@ "in_create": 1, "issingle": 1, "module": "Setup", - "name": "__common__", - "section_style": "Simple", - "version": 1 + "name": "__common__" }, { "doctype": "DocField", @@ -37,19 +34,15 @@ "parenttype": "DocType", "permlevel": 0, "read": 1, + "report": 0, "role": "System Manager", + "submit": 0, "write": 1 }, { "doctype": "DocType", "name": "Email Settings" }, - { - "doctype": "DocPerm" - }, - { - "doctype": "DocPerm" - }, { "description": "Set your outgoing mail SMTP settings here. All system generated notifications, emails will go from this mail server. If you are not sure, leave this blank to use ERPNext servers (emails will still be sent from your email id) or contact your email provider.", "doctype": "DocField", @@ -102,6 +95,13 @@ "fieldtype": "Data", "label": "Auto Email Id" }, + { + "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", + "fieldtype": "Check", + "label": "Send Print in Body and Attachment" + }, { "description": "Set the POP3 email settings to pull emails directly from a mailbox and create Support Tickets", "doctype": "DocField", @@ -180,5 +180,8 @@ "fieldname": "support_autoreply", "fieldtype": "Text", "label": "Custom Autoreply Message" + }, + { + "doctype": "DocPerm" } ] \ No newline at end of file diff --git a/startup/boot.py b/startup/boot.py new file mode 100644 index 0000000000..574646f959 --- /dev/null +++ b/startup/boot.py @@ -0,0 +1,50 @@ +# ERPNext: Copyright 2013 Web Notes Technologies Pvt Ltd +# GNU General Public License. See "license.txt" + + +from __future__ import unicode_literals +import webnotes +import home + +def boot_session(bootinfo): + """boot session - send website info if guest""" + import webnotes + import webnotes.model.doc + + bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' + bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings') + + if webnotes.session['user']=='Guest': + bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, + parent_label, parentfield + from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1) + bootinfo['startup_code'] = \ + webnotes.conn.get_value('Website Settings', None, 'startup_code') + else: + bootinfo['letter_heads'] = get_letter_heads() + + import webnotes.model.doctype + bootinfo['notification_settings'] = webnotes.doc("Notification Control", + "Notification Control").get_values() + + bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') + + # if no company, show a dialog box to create a new company + bootinfo['setup_complete'] = webnotes.conn.sql("""select name from + tabCompany limit 1""") and 'Yes' or 'No' + + # load subscription info + import conf + for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']: + if hasattr(conf, key): bootinfo[key] = getattr(conf, key) + + bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", + as_dict=1, update={"doctype":":Company"}) + +def get_letter_heads(): + """load letter heads with startup""" + import webnotes + ret = webnotes.conn.sql("""select name, content from `tabLetter Head` + where ifnull(disabled,0)=0""") + return dict(ret) + \ No newline at end of file diff --git a/startup/event_handlers.py b/startup/event_handlers.py index 0b64ddf03d..f0c73a542b 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -31,55 +31,6 @@ def on_login_post_session(login_manager): login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D') webnotes.conn.commit() - -def comment_added(doc): - """add comment to feed""" - home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by, - '"' + doc.comment + '"', '#6B24B3') - -def boot_session(bootinfo): - """boot session - send website info if guest""" - import webnotes - import webnotes.model.doc - - bootinfo['custom_css'] = webnotes.conn.get_value('Style Settings', None, 'custom_css') or '' - bootinfo['website_settings'] = webnotes.model.doc.getsingle('Website Settings') - - if webnotes.session['user']=='Guest': - bootinfo['website_menus'] = webnotes.conn.sql("""select label, url, custom_page, - parent_label, parentfield - from `tabTop Bar Item` where parent='Website Settings' order by idx asc""", as_dict=1) - bootinfo['startup_code'] = \ - webnotes.conn.get_value('Website Settings', None, 'startup_code') - else: - bootinfo['letter_heads'] = get_letter_heads() - - import webnotes.model.doctype - bootinfo['notification_settings'] = webnotes.doc("Notification Control", - "Notification Control").get_values() - - bootinfo['modules_list'] = webnotes.conn.get_global('modules_list') - - # if no company, show a dialog box to create a new company - bootinfo['setup_complete'] = webnotes.conn.sql("""select name from - tabCompany limit 1""") and 'Yes' or 'No' - - # load subscription info - import conf - for key in ['max_users', 'expires_on', 'max_space', 'status', 'developer_mode']: - if hasattr(conf, key): bootinfo[key] = getattr(conf, key) - - bootinfo['docs'] += webnotes.conn.sql("select name, default_currency from `tabCompany`", - as_dict=1, update={"doctype":":Company"}) - -def get_letter_heads(): - """load letter heads with startup""" - import webnotes - ret = webnotes.conn.sql("""select name, content from `tabLetter Head` - where ifnull(disabled,0)=0""") - return dict(ret) - - def check_if_expired(): """check if account is expired. If expired, do not allow login""" import conf @@ -106,3 +57,10 @@ def check_if_expired(): webnotes.response['message'] = 'Account Expired' raise webnotes.AuthenticationError + + +def comment_added(doc): + """add comment to feed""" + home.make_feed('Comment', doc.comment_doctype, doc.comment_docname, doc.comment_by, + '"' + doc.comment + '"', '#6B24B3') + \ No newline at end of file