From 939b1523e9c466ddd3fabfdd67d44515bad9c479 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 6 Aug 2013 15:55:44 +0530 Subject: [PATCH] [patch] perpetual accounting patch --- .../p01_perpetual_accounting_patch.py | 33 +++++++++++++++++++ .../june_2013/p09_update_global_defaults.py | 1 - .../may_2013/p01_conversion_factor_and_aii.py | 3 +- .../p05_update_cancelled_gl_entries.py | 3 +- patches/patch_list.py | 1 + 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 patches/august_2013/p01_perpetual_accounting_patch.py diff --git a/patches/august_2013/p01_perpetual_accounting_patch.py b/patches/august_2013/p01_perpetual_accounting_patch.py new file mode 100644 index 0000000000..de231a15f5 --- /dev/null +++ b/patches/august_2013/p01_perpetual_accounting_patch.py @@ -0,0 +1,33 @@ +import webnotes +from webnotes.utils import cint + +def 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.stock_adjustment_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/june_2013/p09_update_global_defaults.py b/patches/june_2013/p09_update_global_defaults.py index 0148b673cf..44d36e1f35 100644 --- a/patches/june_2013/p09_update_global_defaults.py +++ b/patches/june_2013/p09_update_global_defaults.py @@ -3,7 +3,6 @@ import webnotes def execute(): from_global_defaults = { "credit_controller": "Accounts Settings", - "auto_inventory_accounting": "Accounts Settings", "acc_frozen_upto": "Accounts Settings", "bde_auth_role": "Accounts Settings", "auto_indent": "Stock Settings", diff --git a/patches/may_2013/p01_conversion_factor_and_aii.py b/patches/may_2013/p01_conversion_factor_and_aii.py index 2fd0d369a5..e207653fea 100644 --- a/patches/may_2013/p01_conversion_factor_and_aii.py +++ b/patches/may_2013/p01_conversion_factor_and_aii.py @@ -5,8 +5,7 @@ from accounts.utils import create_stock_in_hand_jv def execute(): webnotes.conn.auto_commit_on_many_writes = True - aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None, - "auto_inventory_accounting")) + aii_enabled = cint(webnotes.defaults.get_global_default("perpetual_accounting")) if aii_enabled: create_stock_in_hand_jv(reverse = True) diff --git a/patches/may_2013/p05_update_cancelled_gl_entries.py b/patches/may_2013/p05_update_cancelled_gl_entries.py index 59eed7e66f..1dda214efb 100644 --- a/patches/may_2013/p05_update_cancelled_gl_entries.py +++ b/patches/may_2013/p05_update_cancelled_gl_entries.py @@ -19,8 +19,7 @@ import webnotes from webnotes.utils import cint def execute(): - aii_enabled = cint(webnotes.conn.get_value("Global Defaults", None, - "auto_inventory_accounting")) + aii_enabled = cint(webnotes.defaults.get_global_default("perpetual_accounting")) 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 1426539bbe..b20fcfd85c 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -264,4 +264,5 @@ patch_list = [ "patches.july_2013.p10_change_partner_user_to_website_user", "patches.july_2013.p11_update_price_list_currency", "execute:webnotes.bean('Selling Settings').save() #2013-07-29", + "patches.august_2013.p01_perpetual_accounting_patch", ] \ No newline at end of file