From d85d63bb81cd49fde9621edfb6f4119156ddf577 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 28 Aug 2013 19:24:52 +0530 Subject: [PATCH] [minor] renamed perpetual accounting to make_accounting_entry_for_every_stock_entry --- .../accounts_settings/accounts_settings.py | 14 +++--- .../accounts_settings/accounts_settings.txt | 6 +-- accounts/doctype/pos_setting/pos_setting.py | 2 +- accounts/doctype/pos_setting/pos_setting.txt | 4 +- .../purchase_invoice/purchase_invoice.py | 20 ++++---- .../purchase_invoice/test_purchase_invoice.py | 20 ++++---- .../doctype/sales_invoice/sales_invoice.js | 2 +- .../doctype/sales_invoice/sales_invoice.py | 4 +- .../sales_invoice/test_sales_invoice.py | 14 +++--- controllers/stock_controller.py | 2 +- .../p01_auto_accounting_for_stock_patch.py | 9 ++++ .../p01_perpetual_accounting_patch.py | 39 --------------- .../may_2013/p01_conversion_factor_and_aii.py | 28 ----------- .../p05_update_cancelled_gl_entries.py | 2 +- patches/patch_list.py | 1 - public/js/controllers/stock_controller.js | 2 +- setup/doctype/company/company.js | 2 +- setup/doctype/company/company.txt | 28 ++++++----- setup/doctype/setup_control/setup_control.py | 4 +- stock/doctype/delivery_note/delivery_note.js | 6 +-- .../delivery_note/test_delivery_note.py | 14 +++--- .../material_request/test_material_request.py | 2 +- .../purchase_receipt/test_purchase_receipt.py | 10 ++-- stock/doctype/serial_no/serial_no.txt | 48 +++++++++++-------- stock/doctype/stock_entry/stock_entry.js | 2 +- stock/doctype/stock_entry/test_stock_entry.py | 16 +++---- .../stock_entry_detail/stock_entry_detail.txt | 6 +-- .../stock_reconciliation.js | 4 +- .../stock_reconciliation.py | 2 +- .../test_stock_reconciliation.py | 12 ++--- 30 files changed, 138 insertions(+), 187 deletions(-) create mode 100644 patches/august_2013/p01_auto_accounting_for_stock_patch.py delete mode 100644 patches/august_2013/p01_perpetual_accounting_patch.py delete mode 100644 patches/may_2013/p01_conversion_factor_and_aii.py diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py index a9aa679a6b..5f0d276fb7 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.py +++ b/accounts/doctype/accounts_settings/accounts_settings.py @@ -13,18 +13,18 @@ class DocType: self.doc, self.doclist = d, dl def validate(self): - self.validate_perpetual_accounting() + self.validate_auto_accounting_for_stock() - def validate_perpetual_accounting(self): - if cint(self.doc.perpetual_accounting) == 1: + def validate_auto_accounting_for_stock(self): + if cint(self.doc.auto_accounting_for_stock) == 1: previous_val = cint(webnotes.conn.get_value("Accounts Settings", - None, "perpetual_accounting")) - if cint(self.doc.perpetual_accounting) != previous_val: + None, "auto_accounting_for_stock")) + if cint(self.doc.auto_accounting_for_stock) != previous_val: from accounts.utils import validate_stock_and_account_balance, \ create_stock_in_hand_jv validate_stock_and_account_balance() - create_stock_in_hand_jv(reverse=cint(self.doc.perpetual_accounting) < previous_val) + create_stock_in_hand_jv(reverse=cint(self.doc.auto_accounting_for_stock) < previous_val) def on_update(self): - for key in ["perpetual_accounting"]: + for key in ["auto_accounting_for_stock"]: webnotes.conn.set_default(key, self.doc.fields.get(key, '')) diff --git a/accounts/doctype/accounts_settings/accounts_settings.txt b/accounts/doctype/accounts_settings/accounts_settings.txt index b7ab69e681..9dbed26db5 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.txt +++ b/accounts/doctype/accounts_settings/accounts_settings.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-24 15:49:57", "docstatus": 0, - "modified": "2013-08-01 17:35:16", + "modified": "2013-08-28 18:55:43", "modified_by": "Administrator", "owner": "Administrator" }, @@ -42,9 +42,9 @@ "default": "1", "description": "If enabled, the system will post accounting entries for inventory automatically.", "doctype": "DocField", - "fieldname": "perpetual_accounting", + "fieldname": "auto_accounting_for_stock", "fieldtype": "Check", - "label": "Enable Perpetual Accounting for Inventory" + "label": "Make Accounting Entry For Every Stock Entry" }, { "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", diff --git a/accounts/doctype/pos_setting/pos_setting.py b/accounts/doctype/pos_setting/pos_setting.py index a3984a6121..21d848fe78 100755 --- a/accounts/doctype/pos_setting/pos_setting.py +++ b/accounts/doctype/pos_setting/pos_setting.py @@ -34,6 +34,6 @@ class DocType: (res[0][0], self.doc.company), raise_exception=1) def validate_expense_account(self): - if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \ + if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \ and not self.doc.expense_account: msgprint(_("Expense Account is mandatory"), raise_exception=1) \ No newline at end of file diff --git a/accounts/doctype/pos_setting/pos_setting.txt b/accounts/doctype/pos_setting/pos_setting.txt index 0d4f71bd0d..2420ad5503 100755 --- a/accounts/doctype/pos_setting/pos_setting.txt +++ b/accounts/doctype/pos_setting/pos_setting.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-24 12:15:51", "docstatus": 0, - "modified": "2013-08-09 16:35:03", + "modified": "2013-08-28 19:13:42", "modified_by": "Administrator", "owner": "Administrator" }, @@ -163,7 +163,7 @@ "reqd": 1 }, { - "depends_on": "eval:sys_defaults.perpetual_accounting", + "depends_on": "eval:sys_defaults.auto_accounting_for_stock", "doctype": "DocField", "fieldname": "expense_account", "fieldtype": "Link", diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 2c47ab3e50..33fa52c542 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -212,15 +212,15 @@ class DocType(BuyingController): raise Exception def set_against_expense_account(self): - perpetual_accounting = cint(webnotes.defaults.get_global_default("perpetual_accounting")) + auto_accounting_for_stock = cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) - if perpetual_accounting: + if auto_accounting_for_stock: stock_not_billed_account = self.get_company_default("stock_received_but_not_billed") against_accounts = [] stock_items = self.get_stock_items() for item in self.doclist.get({"parentfield": "entries"}): - if perpetual_accounting and item.item_code in stock_items: + if auto_accounting_for_stock and item.item_code in stock_items: # in case of auto inventory accounting, against expense account is always # Stock Received But Not Billed for a stock item item.expense_head = stock_not_billed_account @@ -234,7 +234,7 @@ class DocType(BuyingController): (item.item_code or item.item_name), raise_exception=1) elif item.expense_head not in against_accounts: - # if no perpetual_accounting or not a stock item + # if no auto_accounting_for_stock or not a stock item against_accounts.append(item.expense_head) self.doc.against_expense_account = ",".join(against_accounts) @@ -317,8 +317,8 @@ class DocType(BuyingController): self.update_prevdoc_status() def make_gl_entries(self): - perpetual_accounting = \ - cint(webnotes.defaults.get_global_default("perpetual_accounting")) + auto_accounting_for_stock = \ + cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) gl_entries = [] @@ -355,15 +355,15 @@ class DocType(BuyingController): valuation_tax += (tax.add_deduct_tax == "Add" and 1 or -1) * flt(tax.tax_amount) # item gl entries - stock_item_and_perpetual_accounting = False + stock_item_and_auto_accounting_for_stock = False stock_items = self.get_stock_items() for item in self.doclist.get({"parentfield": "entries"}): - if perpetual_accounting and item.item_code in stock_items: + if auto_accounting_for_stock and item.item_code in stock_items: if flt(item.valuation_rate): # if auto inventory accounting enabled and stock item, # then do stock related gl entries # expense will be booked in sales invoice - stock_item_and_perpetual_accounting = True + stock_item_and_auto_accounting_for_stock = True valuation_amt = (flt(item.amount, self.precision("amount", item)) + flt(item.item_tax_amount, self.precision("item_tax_amount", item)) + @@ -390,7 +390,7 @@ class DocType(BuyingController): }) ) - if stock_item_and_perpetual_accounting and valuation_tax: + if stock_item_and_auto_accounting_for_stock and valuation_tax: # credit valuation tax amount in "Expenses Included In Valuation" # this will balance out valuation amount included in cost of goods sold gl_entries.append( diff --git a/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/accounts/doctype/purchase_invoice/test_purchase_invoice.py index c9b5e05c43..8826b3ff43 100644 --- a/accounts/doctype/purchase_invoice/test_purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/test_purchase_invoice.py @@ -14,9 +14,9 @@ test_dependencies = ["Item", "Cost Center"] test_ignore = ["Serial No"] class TestPurchaseInvoice(unittest.TestCase): - def test_gl_entries_without_perpetual_accounting(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) - self.assertTrue(not cint(webnotes.defaults.get_global_default("perpetual_accounting"))) + def test_gl_entries_without_auto_accounting_for_stock(self): + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) + self.assertTrue(not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock"))) wrapper = webnotes.bean(copy=test_records[0]) wrapper.run_method("calculate_taxes_and_totals") @@ -41,9 +41,9 @@ class TestPurchaseInvoice(unittest.TestCase): for d in gl_entries: self.assertEqual([d.debit, d.credit], expected_gl_entries.get(d.account)) - def test_gl_entries_with_perpetual_accounting(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) - self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1) + def test_gl_entries_with_auto_accounting_for_stock(self): + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) + self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) pi = webnotes.bean(copy=test_records[1]) pi.run_method("calculate_taxes_and_totals") @@ -68,11 +68,11 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_gl_entries_with_aia_for_non_stock_items(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) - self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) + self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) pi = webnotes.bean(copy=test_records[1]) pi.doclist[1].item_code = "_Test Non Stock Item" @@ -99,7 +99,7 @@ class TestPurchaseInvoice(unittest.TestCase): self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_purchase_invoice_calculation(self): wrapper = webnotes.bean(copy=test_records[0]) diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 7e7f7d4126..dd53c7fe7c 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -358,7 +358,7 @@ cur_frm.set_query("income_account", "entries", function(doc) { }); // expense account -if (sys_defaults.perpetual_accounting) { +if (sys_defaults.auto_accounting_for_stock) { cur_frm.fields_dict['entries'].grid.get_field('expense_account').get_query = function(doc) { return { filters: { diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 6cb0bab4dc..b31eda5fb7 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -558,7 +558,7 @@ class DocType(SellingController): make_gl_entries(gl_entries, cancel=(self.doc.docstatus == 2), update_outstanding=update_outstanding, merge_entries=False) - if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \ + if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \ and cint(self.doc.update_stock): self.update_gl_entries_after() @@ -603,7 +603,7 @@ class DocType(SellingController): ) # expense account gl entries - if cint(webnotes.defaults.get_global_default("perpetual_accounting")) \ + if cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) \ and cint(self.doc.update_stock): gl_entries += self.get_gl_entries_for_stock() diff --git a/accounts/doctype/sales_invoice/test_sales_invoice.py b/accounts/doctype/sales_invoice/test_sales_invoice.py index 3d7959afa5..4f82efca65 100644 --- a/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -298,7 +298,7 @@ class TestSalesInvoice(unittest.TestCase): "Batched for Billing") def test_sales_invoice_gl_entry_without_aii(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) self.clear_stock_account_balance() si = webnotes.bean(copy=test_records[1]) si.insert() @@ -332,7 +332,7 @@ class TestSalesInvoice(unittest.TestCase): def atest_pos_gl_entry_with_aii(self): webnotes.conn.sql("delete from `tabStock Ledger Entry`") - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) old_default_company = webnotes.conn.get_default("company") webnotes.conn.set_default("company", "_Test Company") @@ -392,11 +392,11 @@ class TestSalesInvoice(unittest.TestCase): self.assertFalse(get_stock_and_account_difference([si.doclist[1].warehouse])) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) webnotes.conn.set_default("company", old_default_company) def atest_sales_invoice_gl_entry_with_aii_no_item_code(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) si_copy = webnotes.copy_doclist(test_records[1]) si_copy[1]["item_code"] = None @@ -420,10 +420,10 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def atest_sales_invoice_gl_entry_with_aii_non_stock_item(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) si_copy = webnotes.copy_doclist(test_records[1]) si_copy[1]["item_code"] = "_Test Non Stock Item" @@ -447,7 +447,7 @@ class TestSalesInvoice(unittest.TestCase): self.assertEquals(expected_values[i][1], gle.debit) self.assertEquals(expected_values[i][2], gle.credit) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def _insert_purchase_receipt(self): from stock.doctype.purchase_receipt.test_purchase_receipt import test_records \ diff --git a/controllers/stock_controller.py b/controllers/stock_controller.py index f3f61f9eea..9554913528 100644 --- a/controllers/stock_controller.py +++ b/controllers/stock_controller.py @@ -12,7 +12,7 @@ from accounts.general_ledger import make_gl_entries, delete_gl_entries class StockController(AccountsController): def make_gl_entries(self): - if not cint(webnotes.defaults.get_global_default("perpetual_accounting")): + if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")): return if self.doc.docstatus==1: diff --git a/patches/august_2013/p01_auto_accounting_for_stock_patch.py b/patches/august_2013/p01_auto_accounting_for_stock_patch.py new file mode 100644 index 0000000000..212e5ae018 --- /dev/null +++ b/patches/august_2013/p01_auto_accounting_for_stock_patch.py @@ -0,0 +1,9 @@ +import webnotes +from webnotes.utils import cint + +def execute(): + import patches.september_2012.repost_stock + patches.september_2012.repost_stock.execute() + + import patches.march_2013.p08_create_aii_accounts + patches.march_2013.p08_create_aii_accounts.execute() \ No newline at end of file diff --git a/patches/august_2013/p01_perpetual_accounting_patch.py b/patches/august_2013/p01_perpetual_accounting_patch.py deleted file mode 100644 index 2f08259e90..0000000000 --- a/patches/august_2013/p01_perpetual_accounting_patch.py +++ /dev/null @@ -1,39 +0,0 @@ -import webnotes -from webnotes.utils import cint - -def execute(): - import patches.september_2012.repost_stock - patches.september_2012.repost_stock.execute() - - import patches.march_2013.p08_create_aii_accounts - patches.march_2013.p08_create_aii_accounts.execute() - - copy_perpetual_accounting_settings() - set_missing_cost_center() - - -def set_missing_cost_center(): - reload_docs = [ - ["stock", "doctype", "serial_no"], - ["stock", "doctype", "stock_reconciliation"], - ["stock", "doctype", "stock_entry"] - ] - for d in reload_docs: - webnotes.reload_doc(d[0], d[1], d[2]) - - if cint(webnotes.defaults.get_global_default("perpetual_accounting")): - for dt in ["Serial No", "Stock Reconciliation", "Stock Entry"]: - webnotes.conn.sql("""update `tab%s` t1, tabCompany t2 - set t1.cost_center=t2.cost_center where t1.company = t2.name""" % dt) - -def copy_perpetual_accounting_settings(): - webnotes.reload_doc("accounts", "doctype", "accounts_settings") - aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None, - "auto_inventory_accounting")) - if aii_enabled: - try: - bean= webnotes.bean("Account Settings") - bean.doc.perpetual_accounting = aii_enabled - bean.save() - except: - pass \ No newline at end of file diff --git a/patches/may_2013/p01_conversion_factor_and_aii.py b/patches/may_2013/p01_conversion_factor_and_aii.py deleted file mode 100644 index 3821827bba..0000000000 --- a/patches/may_2013/p01_conversion_factor_and_aii.py +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. -# License: GNU General Public License v3. See license.txt - -import webnotes -from webnotes.utils import cint -from accounts.utils import create_stock_in_hand_jv - -def execute(): - webnotes.conn.auto_commit_on_many_writes = True - - aii_enabled = cint(webnotes.defaults.get_global_default("perpetual_accounting")) - - if aii_enabled: - create_stock_in_hand_jv(reverse = True) - - webnotes.conn.sql("""update `tabPurchase Invoice Item` pi_item - set conversion_factor = (select ifnull(if(conversion_factor=0, 1, conversion_factor), 1) - from `tabUOM Conversion Detail` - where parent = pi_item.item_code and uom = pi_item.uom limit 1 - ) - where ifnull(conversion_factor, 0)=0""") - - if aii_enabled: - create_stock_in_hand_jv() - - webnotes.conn.auto_commit_on_many_writes = False - - \ No newline at end of file diff --git a/patches/may_2013/p05_update_cancelled_gl_entries.py b/patches/may_2013/p05_update_cancelled_gl_entries.py index 1c9cc84fbb..18cefc8a02 100644 --- a/patches/may_2013/p05_update_cancelled_gl_entries.py +++ b/patches/may_2013/p05_update_cancelled_gl_entries.py @@ -6,7 +6,7 @@ import webnotes from webnotes.utils import cint def execute(): - aii_enabled = cint(webnotes.defaults.get_global_default("perpetual_accounting")) + aii_enabled = cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")) if aii_enabled: webnotes.conn.sql("""update `tabGL Entry` gle set is_cancelled = 'Yes' diff --git a/patches/patch_list.py b/patches/patch_list.py index 8dd4c972bb..9492c4fd4b 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -201,7 +201,6 @@ patch_list = [ "patches.april_2013.rebuild_sales_browser", "patches.may_2013.p01_selling_net_total_export", "patches.may_2013.repost_stock_for_no_posting_time", - "patches.may_2013.p01_conversion_factor_and_aii", "patches.may_2013.p02_update_valuation_rate", "patches.may_2013.p03_update_support_ticket", "patches.may_2013.p04_reorder_level", diff --git a/public/js/controllers/stock_controller.js b/public/js/controllers/stock_controller.js index f90317e4a6..e4b03191a1 100644 --- a/public/js/controllers/stock_controller.js +++ b/public/js/controllers/stock_controller.js @@ -20,7 +20,7 @@ erpnext.stock.StockController = wn.ui.form.Controller.extend({ }, show_general_ledger: function() { var me = this; - if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("perpetual_accounting"))) { + if(this.frm.doc.docstatus===1 && cint(wn.defaults.get_default("auto_accounting_for_stock"))) { cur_frm.add_custom_button('Accounting Ledger', function() { wn.route_options = { "voucher_no": me.frm.doc.name, diff --git a/setup/doctype/company/company.js b/setup/doctype/company/company.js index 40e314c181..a8358fab05 100644 --- a/setup/doctype/company/company.js +++ b/setup/doctype/company/company.js @@ -59,7 +59,7 @@ cur_frm.fields_dict.receivables_group.get_query = function(doc) { } } -if (sys_defaults.perpetual_accounting) { +if (sys_defaults.auto_accounting_for_stock) { cur_frm.fields_dict["stock_adjustment_account"].get_query = function(doc) { return { "filters": { diff --git a/setup/doctype/company/company.txt b/setup/doctype/company/company.txt index e1478436dc..1ba1dde481 100644 --- a/setup/doctype/company/company.txt +++ b/setup/doctype/company/company.txt @@ -2,7 +2,7 @@ { "creation": "2013-04-10 08:35:39", "docstatus": 0, - "modified": "2013-08-05 17:23:52", + "modified": "2013-08-28 19:15:04", "modified_by": "Administrator", "owner": "Administrator" }, @@ -25,20 +25,13 @@ "permlevel": 0 }, { - "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 + "read": 1 }, { "doctype": "DocType", @@ -228,9 +221,9 @@ { "depends_on": "eval:!doc.__islocal", "doctype": "DocField", - "fieldname": "perpetual_accounting_settings", + "fieldname": "auto_accounting_for_stock_settings", "fieldtype": "Section Break", - "label": "Perpetual Accounting Settings", + "label": "Auto Accounting For Stock Settings", "read_only": 0 }, { @@ -355,6 +348,17 @@ "read_only": 1 }, { - "doctype": "DocPerm" + "amend": 0, + "cancel": 1, + "create": 1, + "doctype": "DocPerm", + "report": 1, + "role": "System Manager", + "submit": 0, + "write": 1 + }, + { + "doctype": "DocPerm", + "role": "All" } ] \ No newline at end of file diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index 2dd16465a0..9659173c67 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -106,8 +106,8 @@ class DocType: }) global_defaults.save() - webnotes.conn.set_value("Accounts Settings", None, "perpetual_accounting", 1) - webnotes.conn.set_default("perpetual_accounting", 1) + webnotes.conn.set_value("Accounts Settings", None, "auto_accounting_for_stock", 1) + webnotes.conn.set_default("auto_accounting_for_stock", 1) stock_settings = webnotes.bean("Stock Settings") stock_settings.doc.item_naming_by = "Item Code" diff --git a/stock/doctype/delivery_note/delivery_note.js b/stock/doctype/delivery_note/delivery_note.js index f103879a91..550a447caf 100644 --- a/stock/doctype/delivery_note/delivery_note.js +++ b/stock/doctype/delivery_note/delivery_note.js @@ -33,8 +33,8 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( set_print_hide(doc, dt, dn); - // unhide expense_account and cost_center is perpetual_accounting enabled - var aii_enabled = cint(sys_defaults.perpetual_accounting) + // unhide expense_account and cost_center is auto_accounting_for_stock enabled + var aii_enabled = cint(sys_defaults.auto_accounting_for_stock) cur_frm.fields_dict[cur_frm.cscript.fname].grid.set_column_disp(["expense_account", "cost_center"], aii_enabled); if (this.frm.doc.docstatus===0) { @@ -191,7 +191,7 @@ cur_frm.cscript.on_submit = function(doc, cdt, cdn) { } } -if (sys_defaults.perpetual_accounting) { +if (sys_defaults.auto_accounting_for_stock) { cur_frm.cscript.expense_account = function(doc, cdt, cdn){ var d = locals[cdt][cdn]; diff --git a/stock/doctype/delivery_note/test_delivery_note.py b/stock/doctype/delivery_note/test_delivery_note.py index 43378a1654..2b4bfa534f 100644 --- a/stock/doctype/delivery_note/test_delivery_note.py +++ b/stock/doctype/delivery_note/test_delivery_note.py @@ -41,8 +41,8 @@ class TestDeliveryNote(unittest.TestCase): def test_delivery_note_no_gl_entry(self): self.clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 0) - self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) + self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 0) self._insert_purchase_receipt() @@ -66,8 +66,8 @@ class TestDeliveryNote(unittest.TestCase): def test_delivery_note_gl_entry(self): self.clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) - self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) + self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) webnotes.conn.set_value("Item", "_Test Item", "valuation_method", "FIFO") self._insert_purchase_receipt() @@ -119,11 +119,11 @@ class TestDeliveryNote(unittest.TestCase): dn.cancel() self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_delivery_note_gl_entry_packing_item(self): self.clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) self._insert_purchase_receipt() self._insert_purchase_receipt("_Test Item Home Desktop 100") @@ -158,7 +158,7 @@ class TestDeliveryNote(unittest.TestCase): dn.cancel() self.assertFalse(get_gl_entries("Delivery Note", dn.doc.name)) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_serialized(self): from stock.doctype.stock_entry.test_stock_entry import make_serialized_item diff --git a/stock/doctype/material_request/test_material_request.py b/stock/doctype/material_request/test_material_request.py index 1040d647a7..8ebad15810 100644 --- a/stock/doctype/material_request/test_material_request.py +++ b/stock/doctype/material_request/test_material_request.py @@ -10,7 +10,7 @@ from webnotes.utils import flt class TestMaterialRequest(unittest.TestCase): def setUp(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_make_purchase_order(self): from stock.doctype.material_request.material_request import make_purchase_order diff --git a/stock/doctype/purchase_receipt/test_purchase_receipt.py b/stock/doctype/purchase_receipt/test_purchase_receipt.py index a0c72d985e..9bb14954f0 100644 --- a/stock/doctype/purchase_receipt/test_purchase_receipt.py +++ b/stock/doctype/purchase_receipt/test_purchase_receipt.py @@ -12,7 +12,7 @@ from accounts.utils import get_stock_and_account_difference class TestPurchaseReceipt(unittest.TestCase): def test_make_purchase_invoice(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) self._clear_stock_account_balance() from stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice @@ -33,7 +33,7 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertRaises(webnotes.ValidationError, webnotes.bean(pi).submit) def test_purchase_receipt_no_gl_entry(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) self._clear_stock_account_balance() pr = webnotes.bean(copy=test_records[0]) pr.insert() @@ -53,8 +53,8 @@ class TestPurchaseReceipt(unittest.TestCase): self.assertFalse(get_gl_entries("Purchase Receipt", pr.doc.name)) def test_purchase_receipt_gl_entry(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) - self.assertEqual(cint(webnotes.defaults.get_global_default("perpetual_accounting")), 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) + self.assertEqual(cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")), 1) self._clear_stock_account_balance() @@ -84,7 +84,7 @@ class TestPurchaseReceipt(unittest.TestCase): pr.cancel() self.assertFalse(get_gl_entries("Purchase Receipt", pr.doc.name)) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def _clear_stock_account_balance(self): webnotes.conn.sql("delete from `tabStock Ledger Entry`") diff --git a/stock/doctype/serial_no/serial_no.txt b/stock/doctype/serial_no/serial_no.txt index a2fa18f8a7..8500303dc1 100644 --- a/stock/doctype/serial_no/serial_no.txt +++ b/stock/doctype/serial_no/serial_no.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-16 10:59:15", "docstatus": 0, - "modified": "2013-08-21 13:37:01", + "modified": "2013-08-28 19:13:09", "modified_by": "Administrator", "owner": "Administrator" }, @@ -35,7 +35,8 @@ "parenttype": "DocType", "permlevel": 0, "read": 1, - "write": 1 + "report": 1, + "submit": 0 }, { "doctype": "DocType", @@ -167,14 +168,6 @@ "reqd": 0, "search_index": 0 }, - { - "depends_on": "eval:sys_defaults.perpetual_accounting", - "doctype": "DocField", - "fieldname": "cost_center", - "fieldtype": "Link", - "label": "Cost Center", - "options": "Cost Center" - }, { "doctype": "DocField", "fieldname": "purchase_details", @@ -315,6 +308,18 @@ "no_copy": 1, "read_only": 1 }, + { + "doctype": "DocField", + "fieldname": "is_cancelled", + "fieldtype": "Select", + "hidden": 1, + "label": "Is Cancelled", + "oldfieldname": "is_cancelled", + "oldfieldtype": "Select", + "options": "\nYes\nNo", + "read_only": 0, + "report_hide": 1 + }, { "doctype": "DocField", "fieldname": "column_break5", @@ -445,22 +450,23 @@ "cancel": 1, "create": 1, "doctype": "DocPerm", - "report": 1, - "role": "Material Manager", - "submit": 0 + "role": "Material Master Manager", + "write": 1 }, { "amend": 0, "cancel": 0, - "create": 1, - "doctype": "DocPerm", - "report": 1, - "role": "Material User", - "submit": 0 - }, - { "create": 0, "doctype": "DocPerm", - "role": "Accounts User" + "role": "Material Manager", + "write": 0 + }, + { + "amend": 0, + "cancel": 0, + "create": 0, + "doctype": "DocPerm", + "role": "Material User", + "write": 0 } ] \ No newline at end of file diff --git a/stock/doctype/stock_entry/stock_entry.js b/stock/doctype/stock_entry/stock_entry.js index 01c28d8c33..d8983d5c12 100644 --- a/stock/doctype/stock_entry/stock_entry.js +++ b/stock/doctype/stock_entry/stock_entry.js @@ -38,7 +38,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({ } }; - if(cint(wn.defaults.get_default("perpetual_accounting"))) { + if(cint(wn.defaults.get_default("auto_accounting_for_stock"))) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_adjustment_account"); this.frm.fields_dict["expense_adjustment_account"].get_query = function() { diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py index 10b2e751dc..cee231e62f 100644 --- a/stock/doctype/stock_entry/test_stock_entry.py +++ b/stock/doctype/stock_entry/test_stock_entry.py @@ -11,7 +11,7 @@ from stock.doctype.stock_ledger_entry.stock_ledger_entry import * class TestStockEntry(unittest.TestCase): def tearDown(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) if hasattr(self, "old_default_company"): webnotes.conn.set_default("company", self.old_default_company) @@ -50,7 +50,7 @@ class TestStockEntry(unittest.TestCase): def test_material_receipt_gl_entry(self): self._clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) mr = webnotes.bean(copy=test_records[0]) mr.insert() @@ -80,7 +80,7 @@ class TestStockEntry(unittest.TestCase): def test_material_issue_gl_entry(self): self._clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) self._insert_material_receipt() @@ -115,7 +115,7 @@ class TestStockEntry(unittest.TestCase): def test_material_transfer_gl_entry(self): self._clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) self._insert_material_receipt() @@ -149,7 +149,7 @@ class TestStockEntry(unittest.TestCase): def test_repack_no_change_in_valuation(self): self._clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) self._insert_material_receipt() @@ -166,11 +166,11 @@ class TestStockEntry(unittest.TestCase): order by account desc""", repack.doc.name, as_dict=1) self.assertFalse(gl_entries) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_repack_with_change_in_valuation(self): self._clear_stock_account_balance() - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) self._insert_material_receipt() @@ -188,7 +188,7 @@ class TestStockEntry(unittest.TestCase): ["Stock Adjustment - _TC", 0.0, 1000.0], ]) ) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def check_stock_ledger_entries(self, voucher_type, voucher_no, expected_sle): expected_sle.sort(key=lambda x: x[0]) diff --git a/stock/doctype/stock_entry_detail/stock_entry_detail.txt b/stock/doctype/stock_entry_detail/stock_entry_detail.txt index a665edcaf9..051eb7c6e6 100644 --- a/stock/doctype/stock_entry_detail/stock_entry_detail.txt +++ b/stock/doctype/stock_entry_detail/stock_entry_detail.txt @@ -2,7 +2,7 @@ { "creation": "2013-03-29 18:22:12", "docstatus": 0, - "modified": "2013-08-25 21:00:24", + "modified": "2013-08-28 19:15:55", "modified_by": "Administrator", "owner": "Administrator" }, @@ -145,7 +145,7 @@ "read_only": 0 }, { - "depends_on": "eval:sys_defaults.perpetual_accounting", + "depends_on": "eval:sys_defaults.auto_accounting_for_stock", "doctype": "DocField", "fieldname": "expense_account", "fieldtype": "Link", @@ -154,7 +154,7 @@ "print_hide": 1 }, { - "depends_on": "eval:sys_defaults.perpetual_accounting", + "depends_on": "eval:sys_defaults.auto_accounting_for_stock", "doctype": "DocField", "fieldname": "cost_center", "fieldtype": "Link", diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.js b/stock/doctype/stock_reconciliation/stock_reconciliation.js index 1847864ff1..7373648972 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.js +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.js @@ -12,7 +12,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ set_default_expense_account: function() { var me = this; - if (sys_defaults.perpetual_accounting && !this.frm.doc.expense_account) { + if (sys_defaults.auto_accounting_for_stock && !this.frm.doc.expense_account) { return this.frm.call({ method: "accounts.utils.get_company_default", args: { @@ -28,7 +28,7 @@ erpnext.stock.StockReconciliation = erpnext.stock.StockController.extend({ setup: function() { var me = this; - if (sys_defaults.perpetual_accounting) { + if (sys_defaults.auto_accounting_for_stock) { this.frm.add_fetch("company", "stock_adjustment_account", "expense_account"); this.frm.add_fetch("company", "cost_center", "cost_center"); diff --git a/stock/doctype/stock_reconciliation/stock_reconciliation.py b/stock/doctype/stock_reconciliation/stock_reconciliation.py index 6b2855a7c2..f36daad258 100644 --- a/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -303,7 +303,7 @@ class DocType(StockController): def validate_expense_account(self): - if not cint(webnotes.defaults.get_global_default("perpetual_accounting")): + if not cint(webnotes.defaults.get_global_default("auto_accounting_for_stock")): return if not self.doc.expense_account: diff --git a/stock/doctype/stock_reconciliation/test_stock_reconciliation.py b/stock/doctype/stock_reconciliation/test_stock_reconciliation.py index df9e2291e8..0434f82d09 100644 --- a/stock/doctype/stock_reconciliation/test_stock_reconciliation.py +++ b/stock/doctype/stock_reconciliation/test_stock_reconciliation.py @@ -13,7 +13,7 @@ from accounts.utils import get_fiscal_year, get_stock_and_account_difference, ge class TestStockReconciliation(unittest.TestCase): def test_reco_for_fifo(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) # [[qty, valuation_rate, posting_date, # posting_time, expected_stock_value, bin_qty, bin_valuation]] input_data = [ @@ -57,7 +57,7 @@ class TestStockReconciliation(unittest.TestCase): def test_reco_for_moving_average(self): - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) # [[qty, valuation_rate, posting_date, # posting_time, expected_stock_value, bin_qty, bin_valuation]] input_data = [ @@ -103,7 +103,7 @@ class TestStockReconciliation(unittest.TestCase): self.assertFalse(gl_entries) def test_reco_fifo_gl_entries(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) # [[qty, valuation_rate, posting_date, posting_time, stock_in_hand_debit]] input_data = [ @@ -133,10 +133,10 @@ class TestStockReconciliation(unittest.TestCase): stock_reco.cancel() self.assertFalse(get_stock_and_account_difference(["_Test Account Stock In Hand - _TC"])) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def test_reco_moving_average_gl_entries(self): - webnotes.defaults.set_global_default("perpetual_accounting", 1) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 1) # [[qty, valuation_rate, posting_date, # posting_time, stock_in_hand_debit]] @@ -166,7 +166,7 @@ class TestStockReconciliation(unittest.TestCase): stock_reco.cancel() self.assertFalse(get_stock_and_account_difference(["_Test Warehouse - _TC"])) - webnotes.defaults.set_global_default("perpetual_accounting", 0) + webnotes.defaults.set_global_default("auto_accounting_for_stock", 0) def cleanup_data(self):