From 7a93d5de304fa1368e4a121427126918dd686930 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Mon, 24 Jun 2013 18:18:46 +0530 Subject: [PATCH] [bug fixes] [global defaults] [cleanup] --- accounts/doctype/account/account.py | 2 +- .../doctype/accounts_settings/__init__.py | 0 .../accounts_settings/accounts_settings.py | 23 ++ .../accounts_settings/accounts_settings.txt | 73 +++++ .../doctype/cost_center/test_cost_center.py | 2 +- accounts/doctype/gl_entry/gl_entry.py | 4 +- accounts/page/accounts_home/accounts_home.js | 6 + .../purchase_common/purchase_common.py | 2 +- .../june_2013/p09_update_global_defaults.py | 31 ++ selling/doctype/sales_common/sales_common.py | 2 +- setup/doctype/company/company.py | 3 +- .../global_defaults/global_defaults.js | 6 +- .../global_defaults/global_defaults.py | 16 +- .../global_defaults/global_defaults.txt | 289 +++--------------- setup/doctype/price_list/test_price_list.py | 4 +- setup/doctype/setup_control/setup_control.py | 11 +- stock/doctype/stock_entry/test_stock_entry.py | 2 +- .../stock_ledger_entry/stock_ledger_entry.py | 4 +- stock/doctype/stock_settings/__init__.py | 0 .../doctype/stock_settings/stock_settings.py | 13 + .../doctype/stock_settings/stock_settings.txt | 127 ++++++++ stock/page/stock_home/stock_home.js | 6 + stock/utils.py | 4 +- 23 files changed, 339 insertions(+), 291 deletions(-) create mode 100644 accounts/doctype/accounts_settings/__init__.py create mode 100644 accounts/doctype/accounts_settings/accounts_settings.py create mode 100644 accounts/doctype/accounts_settings/accounts_settings.txt create mode 100644 patches/june_2013/p09_update_global_defaults.py create mode 100644 stock/doctype/stock_settings/__init__.py create mode 100644 stock/doctype/stock_settings/stock_settings.py create mode 100644 stock/doctype/stock_settings/stock_settings.txt diff --git a/accounts/doctype/account/account.py b/accounts/doctype/account/account.py index 45b02a8d15..2d49f0dad0 100644 --- a/accounts/doctype/account/account.py +++ b/accounts/doctype/account/account.py @@ -147,7 +147,7 @@ class DocType: def get_authorized_user(self): # Check logged-in user is authorized - if webnotes.conn.get_value('Global Defaults', None, 'credit_controller') \ + if webnotes.conn.get_value('Accounts Settings', None, 'credit_controller') \ in webnotes.user.get_roles(): return 1 diff --git a/accounts/doctype/accounts_settings/__init__.py b/accounts/doctype/accounts_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/accounts/doctype/accounts_settings/accounts_settings.py b/accounts/doctype/accounts_settings/accounts_settings.py new file mode 100644 index 0000000000..4b580488bb --- /dev/null +++ b/accounts/doctype/accounts_settings/accounts_settings.py @@ -0,0 +1,23 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + self.make_adjustment_jv_for_auto_inventory() + + def make_adjustment_jv_for_auto_inventory(self): + previous_auto_inventory_accounting = cint(webnotes.conn.get_value("Accounts Settings", + None, "auto_inventory_accounting")) + if cint(self.doc.auto_inventory_accounting) != previous_auto_inventory_accounting: + from accounts.utils import create_stock_in_hand_jv + create_stock_in_hand_jv(reverse = \ + cint(self.doc.auto_inventory_accounting) < previous_auto_inventory_accounting) + + def on_update(self): + for key in ["auto_inventory_accounting"]: + 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 new file mode 100644 index 0000000000..d10f63946a --- /dev/null +++ b/accounts/doctype/accounts_settings/accounts_settings.txt @@ -0,0 +1,73 @@ +[ + { + "creation": "2013-06-24 15:49:57", + "docstatus": 0, + "modified": "2013-06-24 16:12:29", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "description": "Settings for Accounts", + "doctype": "DocType", + "issingle": 1, + "module": "Accounts", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Accounts Settings", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Accounts Settings", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "read": 1, + "role": "Accounts Manager", + "write": 1 + }, + { + "doctype": "DocType", + "name": "Accounts Settings" + }, + { + "description": "If enabled, the system will post accounting entries for inventory automatically.", + "doctype": "DocField", + "fieldname": "auto_inventory_accounting", + "fieldtype": "Check", + "label": "Enable Auto Inventory Accounting" + }, + { + "description": "Accounting entry frozen up to this date, nobody can do / modify entry except role specified below.", + "doctype": "DocField", + "fieldname": "acc_frozen_upto", + "fieldtype": "Date", + "label": "Accounts Frozen Upto" + }, + { + "description": "Users with this role are allowed to do / modify accounting entry before frozen date", + "doctype": "DocField", + "fieldname": "bde_auth_role", + "fieldtype": "Link", + "label": "Allow Editing of Frozen Accounts For", + "options": "Role" + }, + { + "description": "Role that is allowed to submit transactions that exceed credit limits set.", + "doctype": "DocField", + "fieldname": "credit_controller", + "fieldtype": "Link", + "label": "Credit Controller", + "options": "Role" + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/accounts/doctype/cost_center/test_cost_center.py b/accounts/doctype/cost_center/test_cost_center.py index 1692d13d33..8500bd3ef0 100644 --- a/accounts/doctype/cost_center/test_cost_center.py +++ b/accounts/doctype/cost_center/test_cost_center.py @@ -2,7 +2,7 @@ test_records = [ [{ "doctype": "Cost Center", "cost_center_name": "_Test Cost Center", - "parent_cost_center": "Root - _TC", + "parent_cost_center": "_Test Company - _TC", "company_name": "_Test Company", "group_or_ledger": "Ledger" }], diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py index a2ef25a777..d39155d76f 100644 --- a/accounts/doctype/gl_entry/gl_entry.py +++ b/accounts/doctype/gl_entry/gl_entry.py @@ -135,9 +135,9 @@ class DocType: except authorized person """ if not adv_adj: - acc_frozen_upto = webnotes.conn.get_value('Global Defaults', None, 'acc_frozen_upto') + acc_frozen_upto = webnotes.conn.get_value('Accounts Settings', None, 'acc_frozen_upto') if acc_frozen_upto: - bde_auth_role = webnotes.conn.get_value( 'Global Defaults', None,'bde_auth_role') + bde_auth_role = webnotes.conn.get_value( 'Accounts Settings', None,'bde_auth_role') if getdate(self.doc.posting_date) <= getdate(acc_frozen_upto) \ and not bde_auth_role in webnotes.user.get_roles(): msgprint(_("You are not authorized to do/modify back dated entries before ") + diff --git a/accounts/page/accounts_home/accounts_home.js b/accounts/page/accounts_home/accounts_home.js index 31660eb904..a998818767 100644 --- a/accounts/page/accounts_home/accounts_home.js +++ b/accounts/page/accounts_home/accounts_home.js @@ -84,6 +84,12 @@ wn.module_page["Accounts"] = [ title: wn._("Setup"), icon: "icon-cog", items: [ + { + "label": wn._("Accounts Settings"), + "route": "Form/Accounts Settings", + "doctype":"Accounts Settings", + "description": "Settings for Accounts" + }, { "label": wn._("Sales Taxes and Charges Master"), "doctype":"Sales Taxes and Charges Master", diff --git a/buying/doctype/purchase_common/purchase_common.py b/buying/doctype/purchase_common/purchase_common.py index 4b5fe020bd..2d20e3c84f 100644 --- a/buying/doctype/purchase_common/purchase_common.py +++ b/buying/doctype/purchase_common/purchase_common.py @@ -307,7 +307,7 @@ class DocType(BuyingController): tolerance = flt(webnotes.conn.get_value('Item',item_code,'tolerance') or 0) if not(tolerance): - tolerance = flt(webnotes.conn.get_value('Global Defaults',None,'tolerance') or 0) + tolerance = flt(webnotes.conn.get_value('Stock Settings',None,'tolerance') or 0) if is_submit: qty = qty + flt(curr_qty) diff --git a/patches/june_2013/p09_update_global_defaults.py b/patches/june_2013/p09_update_global_defaults.py new file mode 100644 index 0000000000..d2aebb1a90 --- /dev/null +++ b/patches/june_2013/p09_update_global_defaults.py @@ -0,0 +1,31 @@ +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", + "reorder_email_notify": "Stock Settings", + "tolerance": "Stock Settings", + "stock_frozen_upto": "Stock Settings", + "stock_auth_role": "Stock Settings" + } + + from_defaults = { + "item_group": "Stock Settings", + "item_naming_by": "Stock Settings", + "stock_uom": "Stock Settings", + "valuation_method": "Stock Settings", + "allow_negative_stock": "Stock Settings" + } + + for key in from_global_defaults: + webnotes.conn.set_value(from_global_defaults[key], None, key, + webnotes.conn.get_value("Global Defaults", None, key)) + + for key in from_defaults: + webnotes.conn.set_value(from_defaults[key], None, key, + webnotes.conn.get_default(key)) + \ No newline at end of file diff --git a/selling/doctype/sales_common/sales_common.py b/selling/doctype/sales_common/sales_common.py index c524a92773..7ba0bb4354 100644 --- a/selling/doctype/sales_common/sales_common.py +++ b/selling/doctype/sales_common/sales_common.py @@ -457,7 +457,7 @@ class StatusUpdater: if not tolerance: if self.global_tolerance == None: - self.global_tolerance = flt(webnotes.conn.get_value('Global Defaults',None,'tolerance') or 0) + self.global_tolerance = flt(webnotes.conn.get_value('Stock Settings',None,'tolerance') or 0) tolerance = self.global_tolerance self.tolerance[item_code] = tolerance diff --git a/setup/doctype/company/company.py b/setup/doctype/company/company.py index c5a5d49dba..64783a0c60 100644 --- a/setup/doctype/company/company.py +++ b/setup/doctype/company/company.py @@ -240,8 +240,7 @@ class DocType: cc_bean.ignore_permissions = True cc_bean.insert() - webnotes.conn.set_value("Company", self.doc.name, "cost_center", - "Main - " + self.doc.abbr) + webnotes.conn.set(self.doc, "cost_center", "Main - " + self.doc.abbr) def on_update(self): self.set_letter_head() diff --git a/setup/doctype/global_defaults/global_defaults.js b/setup/doctype/global_defaults/global_defaults.js index e8a174b6c9..246bacf49e 100644 --- a/setup/doctype/global_defaults/global_defaults.js +++ b/setup/doctype/global_defaults/global_defaults.js @@ -27,8 +27,4 @@ cur_frm.fields_dict['default_territory'].get_query = function(doc,cdt,cdn) { cur_frm.fields_dict['default_customer_group'].get_query = function(doc,cdt,cdn) { return 'SELECT `tabCustomer Group`.`name`, `tabCustomer Group`.`parent_customer_group` FROM `tabCustomer Group` WHERE `tabCustomer Group`.`is_group` = "No" AND `tabCustomer Group`.`docstatus`!= 2 AND `tabCustomer Group`.%(key)s LIKE "%s" ORDER BY `tabCustomer Group`.`name` ASC LIMIT 50'; -} - -cur_frm.fields_dict['default_item_group'].get_query = function(doc,cdt,cdn) { - return 'SELECT `tabItem Group`.`name`,`tabItem Group`.`parent_item_group` FROM `tabItem Group` WHERE `tabItem Group`.is_group="No" AND `tabItem Group`.docstatus != 2 AND `tabItem Group`.%(key)s LIKE "%s" LIMIT 50' -} +} \ No newline at end of file diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py index 2d28009650..349bba5d45 100644 --- a/setup/doctype/global_defaults/global_defaults.py +++ b/setup/doctype/global_defaults/global_defaults.py @@ -29,38 +29,24 @@ keydict = { 'hide_currency_symbol':'hide_currency_symbol', 'price_list_name': 'default_price_list', 'price_list_currency': 'default_price_list_currency', - 'item_group': 'default_item_group', 'customer_group': 'default_customer_group', 'cust_master_name': 'cust_master_name', - "item_naming_by": "item_naming_by", 'supplier_type': 'default_supplier_type', 'supp_master_name': 'supp_master_name', 'territory': 'default_territory', - 'stock_uom': 'default_stock_uom', - 'valuation_method': 'default_valuation_method', 'date_format': 'date_format', 'number_format': 'number_format', 'float_precision': 'float_precision', 'account_url':'account_url', - 'allow_negative_stock' : 'allow_negative_stock', 'maintain_same_rate' : 'maintain_same_rate', 'session_expiry': 'session_expiry', - 'disable_rounded_total': 'disable_rounded_total', - "auto_inventory_accounting": "auto_inventory_accounting", + 'disable_rounded_total': 'disable_rounded_total' } class DocType: def __init__(self, d, dl): self.doc, self.doclist = d, dl - def validate(self): - previous_auto_inventory_accounting = cint(webnotes.conn.get_value("Global Defaults", None, - "auto_inventory_accounting")) - if cint(self.doc.auto_inventory_accounting) != previous_auto_inventory_accounting: - from accounts.utils import create_stock_in_hand_jv - create_stock_in_hand_jv(reverse = \ - cint(self.doc.auto_inventory_accounting) < previous_auto_inventory_accounting) - def on_update(self): """update defaults""" self.validate_session_expiry() diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 16954a0f32..7f17f16dcc 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -2,7 +2,7 @@ { "creation": "2013-05-02 17:53:24", "docstatus": 0, - "modified": "2013-05-30 12:23:34", + "modified": "2013-06-24 17:07:55", "modified_by": "Administrator", "owner": "Administrator" }, @@ -24,9 +24,12 @@ "parent": "Global Defaults", "parentfield": "fields", "parenttype": "DocType", - "permlevel": 0 + "permlevel": 0, + "read_only": 0 }, { + "amend": 0, + "cancel": 0, "create": 1, "doctype": "DocPerm", "name": "__common__", @@ -48,22 +51,19 @@ "doctype": "DocField", "fieldname": "general", "fieldtype": "Section Break", - "label": "General", - "read_only": 0 + "label": "General" }, { "description": "Session Expiry in Hours e.g. 06:00", "doctype": "DocField", "fieldname": "session_expiry", "fieldtype": "Data", - "label": "Session Expiry", - "read_only": 0 + "label": "Session Expiry" }, { "doctype": "DocField", "fieldname": "column_break_3", - "fieldtype": "Column Break", - "read_only": 0 + "fieldtype": "Column Break" }, { "description": "For Server Side Print Formats", @@ -71,15 +71,13 @@ "fieldname": "print_style", "fieldtype": "Select", "label": "Print Format Style", - "options": "Standard\nClassic\nModern\nSpartan", - "read_only": 0 + "options": "Standard\nClassic\nModern\nSpartan" }, { "doctype": "DocField", "fieldname": "company", "fieldtype": "Section Break", - "label": "Company", - "read_only": 0 + "label": "Company" }, { "doctype": "DocField", @@ -87,7 +85,6 @@ "fieldtype": "Link", "label": "Default Company", "options": "Company", - "read_only": 0, "reqd": 0 }, { @@ -96,7 +93,6 @@ "fieldtype": "Link", "label": "Current Fiscal Year", "options": "Fiscal Year", - "read_only": 0, "reqd": 1 }, { @@ -104,14 +100,12 @@ "fieldname": "date_format", "fieldtype": "Select", "label": "Date Format", - "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy", - "read_only": 0 + "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy" }, { "doctype": "DocField", "fieldname": "column_break1", "fieldtype": "Column Break", - "read_only": 0, "width": "50%" }, { @@ -120,8 +114,7 @@ "fieldname": "hide_currency_symbol", "fieldtype": "Select", "label": "Hide Currency Symbol", - "options": "\nNo\nYes", - "read_only": 0 + "options": "\nNo\nYes" }, { "default": "INR", @@ -130,7 +123,6 @@ "fieldtype": "Link", "label": "Default Currency", "options": "Currency", - "read_only": 0, "reqd": 1 }, { @@ -139,8 +131,7 @@ "fieldname": "number_format", "fieldtype": "Select", "label": "Number Format", - "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###", - "read_only": 0 + "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###" }, { "description": "Precision for Float fields (quantities, discounts, percentages etc) only for display. Floats will still be calculated up to 6 decimals.", @@ -148,196 +139,13 @@ "fieldname": "float_precision", "fieldtype": "Select", "label": "Float Precision", - "options": "\n2\n3\n4\n5\n6", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "stock", - "fieldtype": "Section Break", - "label": "Stock", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break2", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "item_naming_by", - "fieldtype": "Select", - "label": "Item Naming By", - "options": "Item Code\nNaming Series", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_item_group", - "fieldtype": "Link", - "label": "Default Item Group", - "options": "Item Group", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "ighelp", - "fieldtype": "HTML", - "label": "IGHelp", - "options": "To manage Item Groups, click here", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_stock_uom", - "fieldtype": "Link", - "label": "Default Stock UOM", - "options": "UOM", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "default_valuation_method", - "fieldtype": "Select", - "label": "Default Valuation Method", - "options": "FIFO\nMoving Average", - "read_only": 0 - }, - { - "description": "Applicable only if valuation method is moving average", - "doctype": "DocField", - "fieldname": "allow_negative_stock", - "fieldtype": "Check", - "label": "Allow Negative Stock", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "auto_indent", - "fieldtype": "Check", - "label": "Raise Material Request when stock reaches re-order level", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "reorder_email_notify", - "fieldtype": "Check", - "label": "Notify by Email on creation of automatic Material Request" - }, - { - "default": "Hourly", - "doctype": "DocField", - "fieldname": "reorder_level_checking_frequency", - "fieldtype": "Select", - "hidden": 1, - "label": "Reorder Level Checking Frequency", - "options": "Hourly\nDaily" - }, - { - "default": "1", - "doctype": "DocField", - "fieldname": "column_break3", - "fieldtype": "Column Break", - "read_only": 0, - "width": "50%" - }, - { - "doctype": "DocField", - "fieldname": "default_warehouse_type", - "fieldtype": "Link", - "label": "Default Warehouse Type", - "options": "Warehouse Type", - "read_only": 0 - }, - { - "description": "Percentage you are allowed to receive or deliver more against the quantity ordered.

For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units

", - "doctype": "DocField", - "fieldname": "tolerance", - "fieldtype": "Float", - "label": "Allowance Percent", - "read_only": 0 - }, - { - "description": "Stock level frozen up to this date, nobody can do / modify entry except authorized person", - "doctype": "DocField", - "fieldname": "stock_frozen_upto", - "fieldtype": "Date", - "label": "Stock Frozen Upto", - "read_only": 0 - }, - { - "description": "Users with this role are allowed to do / modify stock entry before frozen date", - "doctype": "DocField", - "fieldname": "stock_auth_role", - "fieldtype": "Link", - "label": "Authorized Role (Frozen Entry)", - "options": "Role", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "accounts", - "fieldtype": "Section Break", - "label": "Accounts", - "read_only": 0 - }, - { - "description": "If enabled, the system will post accounting entries for inventory automatically", - "doctype": "DocField", - "fieldname": "auto_inventory_accounting", - "fieldtype": "Check", - "label": "Auto Inventory Accounting", - "no_copy": 0, - "print_hide": 1, - "read_only": 0 - }, - { - "description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person", - "doctype": "DocField", - "fieldname": "acc_frozen_upto", - "fieldtype": "Date", - "label": "Accounts Frozen Upto", - "read_only": 0 - }, - { - "description": "Users with this role are allowed to do / modify accounting entry before frozen date", - "doctype": "DocField", - "fieldname": "bde_auth_role", - "fieldtype": "Link", - "label": "Authourized Role (Frozen Entry)", - "options": "Role", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "credit_controller", - "fieldtype": "Link", - "label": "Credit Controller", - "options": "Role", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "column_break4", - "fieldtype": "Column Break", - "read_only": 0 - }, - { - "doctype": "DocField", - "fieldname": "account_info", - "fieldtype": "HTML", - "label": "Account Info", - "options": "
For more accounting defaults, Open Company
", - "read_only": 0 + "options": "\n2\n3\n4\n5\n6" }, { "doctype": "DocField", "fieldname": "selling", "fieldtype": "Section Break", - "label": "Selling", - "read_only": 0 + "label": "Selling" }, { "default": "Customer Name", @@ -345,46 +153,40 @@ "fieldname": "cust_master_name", "fieldtype": "Select", "label": "Customer Master created by ", - "options": "Customer Name\nNaming Series", - "read_only": 0 + "options": "Customer Name\nNaming Series" }, { "doctype": "DocField", "fieldname": "default_customer_group", "fieldtype": "Link", "label": "Default Customer Group", - "options": "Customer Group", - "read_only": 0 + "options": "Customer Group" }, { "doctype": "DocField", "fieldname": "cghelp", "fieldtype": "HTML", "label": "CGHelp", - "options": "To manage Customer Groups, click here", - "read_only": 0 + "options": "To manage Customer Groups, click here" }, { "doctype": "DocField", "fieldname": "default_territory", "fieldtype": "Link", "label": "Default Territory", - "options": "Territory", - "read_only": 0 + "options": "Territory" }, { "doctype": "DocField", "fieldname": "territoryhelp", "fieldtype": "HTML", "label": "TerritoryHelp", - "options": "To manage Territory, click here", - "read_only": 0 + "options": "To manage Territory, click here" }, { "doctype": "DocField", "fieldname": "column_break5", "fieldtype": "Column Break", - "read_only": 0, "width": "50%" }, { @@ -392,16 +194,14 @@ "fieldname": "default_price_list", "fieldtype": "Link", "label": "Default Price List", - "options": "Price List", - "read_only": 0 + "options": "Price List" }, { "doctype": "DocField", "fieldname": "default_price_list_currency", "fieldtype": "Link", "label": "Default Price List Currency", - "options": "Currency", - "read_only": 0 + "options": "Currency" }, { "default": "No", @@ -409,8 +209,7 @@ "fieldname": "so_required", "fieldtype": "Select", "label": "Sales Order Required", - "options": "No\nYes", - "read_only": 0 + "options": "No\nYes" }, { "default": "No", @@ -418,31 +217,27 @@ "fieldname": "dn_required", "fieldtype": "Select", "label": "Delivery Note Required", - "options": "No\nYes", - "read_only": 0 + "options": "No\nYes" }, { "description": "If disable, 'Rounded Total' field will not be visible in any transaction", "doctype": "DocField", "fieldname": "disable_rounded_total", "fieldtype": "Check", - "label": "Disable Rounded Total", - "read_only": 0 + "label": "Disable Rounded Total" }, { "doctype": "DocField", "fieldname": "buying", "fieldtype": "Section Break", - "label": "Buying", - "read_only": 0 + "label": "Buying" }, { "doctype": "DocField", "fieldname": "default_supplier_type", "fieldtype": "Link", "label": "Default Supplier Type", - "options": "Supplier Type", - "read_only": 0 + "options": "Supplier Type" }, { "default": "Supplier Name", @@ -450,14 +245,12 @@ "fieldname": "supp_master_name", "fieldtype": "Select", "label": "Supplier Master created by ", - "options": "Supplier Name\nNaming Series", - "read_only": 0 + "options": "Supplier Name\nNaming Series" }, { "doctype": "DocField", "fieldname": "column_break6", "fieldtype": "Column Break", - "read_only": 0, "width": "50%" }, { @@ -466,8 +259,7 @@ "fieldname": "po_required", "fieldtype": "Select", "label": "Purchase Order Required", - "options": "No\nYes", - "read_only": 0 + "options": "No\nYes" }, { "default": "No", @@ -475,23 +267,20 @@ "fieldname": "pr_required", "fieldtype": "Select", "label": "Purchase Receipt Required", - "options": "No\nYes", - "read_only": 0 + "options": "No\nYes" }, { "doctype": "DocField", "fieldname": "maintain_same_rate", "fieldtype": "Check", - "label": "Maintain same rate throughout purchase cycle", - "read_only": 0 + "label": "Maintain same rate throughout purchase cycle" }, { "doctype": "DocField", "fieldname": "hr", "fieldtype": "Section Break", "label": "HR", - "options": "
HR
", - "read_only": 0 + "options": "
HR
" }, { "description": "Employee record is created using selected field. ", @@ -499,27 +288,19 @@ "fieldname": "emp_created_by", "fieldtype": "Select", "label": "Employee Records to be created by ", - "options": "Naming Series\nEmployee Number", - "read_only": 0 + "options": "Naming Series\nEmployee Number" }, { "doctype": "DocField", "fieldname": "system", "fieldtype": "Section Break", - "label": "System", - "read_only": 0 + "label": "System" }, { "doctype": "DocField", "fieldname": "sms_sender_name", "fieldtype": "Data", - "label": "SMS Sender Name", - "read_only": 0 - }, - { - "amend": 0, - "cancel": 0, - "doctype": "DocPerm" + "label": "SMS Sender Name" }, { "doctype": "DocPerm" diff --git a/setup/doctype/price_list/test_price_list.py b/setup/doctype/price_list/test_price_list.py index f776972898..68d9a35521 100644 --- a/setup/doctype/price_list/test_price_list.py +++ b/setup/doctype/price_list/test_price_list.py @@ -3,8 +3,6 @@ test_records = [ "doctype": "Price List", "price_list_name": "_Test Price List", "currency": "INR", - "valid_for_all_countries": 1, - "buying_or_selling": "Selling", - "conversion_rate": 1.0 + "buying_or_selling": "Selling" }] ] \ 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 098417f34a..ebb528f70a 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -69,7 +69,6 @@ class DocType: 'current_fiscal_year':curr_fiscal_year, 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), - 'default_valuation_method':'FIFO', 'default_stock_uom':'Nos', 'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"), @@ -85,6 +84,16 @@ class DocType: # Set self.set_defaults(def_args) + webnotes.conn.set_value("Accounts Settings", None, "auto_inventory_accounting", 1) + webnotes.conn.set_default("auto_inventory_accounting", 1) + + stock_settings = webnotes.bean("Stock Settings") + stock_settings.doc.item_naming_by = "Item Code" + stock_settings.doc.valuation_method = "FIFO" + stock_settings.doc.stock_uom = "Nos" + stock_settings.doc.auto_indent = 1 + stock_settings.save() + cp_args = {} for k in ['industry', 'country', 'timezone', 'company_name']: cp_args[k] = args[k] diff --git a/stock/doctype/stock_entry/test_stock_entry.py b/stock/doctype/stock_entry/test_stock_entry.py index 11811ba17f..345e73c87e 100644 --- a/stock/doctype/stock_entry/test_stock_entry.py +++ b/stock/doctype/stock_entry/test_stock_entry.py @@ -11,7 +11,7 @@ class TestStockEntry(unittest.TestCase): webnotes.conn.sql("""delete from `tabMaterial Request`""") self._clear_stock() - webnotes.conn.set_value("Global Defaults", None, "auto_indent", True) + webnotes.conn.set_value("Stock Settings", None, "auto_indent", True) st1 = webnotes.bean(copy=test_records[0]) st1.insert() diff --git a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py index 42621130d5..3cde2e20c9 100644 --- a/stock/doctype/stock_ledger_entry/stock_ledger_entry.py +++ b/stock/doctype/stock_ledger_entry/stock_ledger_entry.py @@ -110,9 +110,9 @@ class DocType(DocListController): # Nobody can do SL Entries where posting date is before freezing date except authorized person #---------------------------------------------------------------------------------------------- def check_stock_frozen_date(self): - stock_frozen_upto = webnotes.conn.get_value('Global Defaults', None, 'stock_frozen_upto') or '' + stock_frozen_upto = webnotes.conn.get_value('Stock Settings', None, 'stock_frozen_upto') or '' if stock_frozen_upto: - stock_auth_role = webnotes.conn.get_value('Global Defaults', None,'stock_auth_role') + stock_auth_role = webnotes.conn.get_value('Stock Settings', None,'stock_auth_role') if getdate(self.doc.posting_date) <= getdate(stock_frozen_upto) and not stock_auth_role in webnotes.user.get_roles(): msgprint("You are not authorized to do / modify back dated stock entries before %s" % getdate(stock_frozen_upto).strftime('%d-%m-%Y'), raise_exception=1) diff --git a/stock/doctype/stock_settings/__init__.py b/stock/doctype/stock_settings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/stock/doctype/stock_settings/stock_settings.py b/stock/doctype/stock_settings/stock_settings.py new file mode 100644 index 0000000000..f19c8fc6a3 --- /dev/null +++ b/stock/doctype/stock_settings/stock_settings.py @@ -0,0 +1,13 @@ +# For license information, please see license.txt + +from __future__ import unicode_literals +import webnotes + +class DocType: + def __init__(self, d, dl): + self.doc, self.doclist = d, dl + + def validate(self): + for key in ["item_naming_by", "item_group", "stock_uom", + "allow_negative_stock"]: + webnotes.conn.set_default(key, self.doc.fields.get(key, "")) diff --git a/stock/doctype/stock_settings/stock_settings.txt b/stock/doctype/stock_settings/stock_settings.txt new file mode 100644 index 0000000000..36b298a465 --- /dev/null +++ b/stock/doctype/stock_settings/stock_settings.txt @@ -0,0 +1,127 @@ +[ + { + "creation": "2013-06-24 16:37:54", + "docstatus": 0, + "modified": "2013-06-24 17:41:02", + "modified_by": "Administrator", + "owner": "Administrator" + }, + { + "description": "Settings", + "doctype": "DocType", + "issingle": 1, + "module": "Stock", + "name": "__common__" + }, + { + "doctype": "DocField", + "name": "__common__", + "parent": "Stock Settings", + "parentfield": "fields", + "parenttype": "DocType", + "permlevel": 0 + }, + { + "create": 1, + "doctype": "DocPerm", + "name": "__common__", + "parent": "Stock Settings", + "parentfield": "permissions", + "parenttype": "DocType", + "permlevel": 0, + "read": 1, + "role": "Material Manager", + "write": 1 + }, + { + "doctype": "DocType", + "name": "Stock Settings" + }, + { + "doctype": "DocField", + "fieldname": "item_naming_by", + "fieldtype": "Select", + "label": "Item Naming By", + "options": "Item Code\nNaming Series" + }, + { + "description": "Manage Item Groups", + "doctype": "DocField", + "fieldname": "item_group", + "fieldtype": "Link", + "label": "Default Item Group", + "options": "Item Group" + }, + { + "doctype": "DocField", + "fieldname": "stock_uom", + "fieldtype": "Link", + "label": "Default Stock UOM", + "options": "UOM" + }, + { + "doctype": "DocField", + "fieldname": "column_break_4", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "fieldname": "allow_negative_stock", + "fieldtype": "Check", + "label": "Allow Negative Stock" + }, + { + "doctype": "DocField", + "fieldname": "valuation_method", + "fieldtype": "Select", + "label": "Default Valuation Method", + "options": "FIFO\nMoving Average" + }, + { + "description": "Percentage you are allowed to receive or deliver more against the quantity ordered. For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units.", + "doctype": "DocField", + "fieldname": "tolerance", + "fieldtype": "Float", + "label": "Allowance Percent" + }, + { + "doctype": "DocField", + "fieldname": "auto_material_request", + "fieldtype": "Section Break", + "label": "Auto Material Request" + }, + { + "doctype": "DocField", + "fieldname": "auto_indent", + "fieldtype": "Check", + "label": "Raise Material Request when stock reaches re-order level" + }, + { + "doctype": "DocField", + "fieldname": "reorder_email_notify", + "fieldtype": "Check", + "label": "Notify by Email on creation of automatic Material Request" + }, + { + "doctype": "DocField", + "fieldname": "freeze_stock_entries", + "fieldtype": "Section Break", + "label": "Freeze Stock Entries" + }, + { + "doctype": "DocField", + "fieldname": "stock_frozen_upto", + "fieldtype": "Date", + "label": "Stock Frozen Upto" + }, + { + "doctype": "DocField", + "fieldname": "stock_auth_role", + "fieldtype": "Link", + "label": "Role Allowed to edit frozen stock", + "options": "Role" + }, + { + "doctype": "DocPerm" + } +] \ No newline at end of file diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index 1c0acd42b5..3b6af0364c 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -101,6 +101,12 @@ wn.module_page["Stock"] = [ title: wn._("Setup"), icon: "icon-cog", items: [ + { + "label": wn._("Stock Settings"), + "route": "Form/Stock Settings", + "doctype":"Stock Settings", + "description": "Settings for Stock" + }, { "route":"Sales Browser/Item Group", "label": wn._("Item Group"), diff --git a/stock/utils.py b/stock/utils.py index 53ad69b157..942c200f52 100644 --- a/stock/utils.py +++ b/stock/utils.py @@ -201,7 +201,7 @@ def _get_buying_amount(voucher_type, voucher_no, item_row, item_code, warehouse, def reorder_item(): """ Reorder item if stock reaches reorder level""" if not hasattr(webnotes, "auto_indent"): - webnotes.auto_indent = webnotes.conn.get_value('Global Defaults', None, 'auto_indent') + webnotes.auto_indent = webnotes.conn.get_value('Stock Settings', None, 'auto_indent') if webnotes.auto_indent: material_requests = {} @@ -297,7 +297,7 @@ def create_material_request(material_requests): if mr_list: if not hasattr(webnotes, "reorder_email_notify"): - webnotes.reorder_email_notify = webnotes.conn.get_value('Global Defaults', None, + webnotes.reorder_email_notify = webnotes.conn.get_value('Stock Settings', None, 'reorder_email_notify') if(webnotes.reorder_email_notify):