[bug fixes] [global defaults] [cleanup]

This commit is contained in:
Rushabh Mehta 2013-06-24 18:18:46 +05:30
parent 7925bd7079
commit 7a93d5de30
23 changed files with 339 additions and 291 deletions

View File

@ -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

View File

@ -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, ''))

View File

@ -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"
}
]

View File

@ -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"
}],

View File

@ -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 ") +

View File

@ -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",

View File

@ -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)

View File

@ -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))

View File

@ -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

View File

@ -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()

View File

@ -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'
}
}

View File

@ -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()

View File

@ -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": "<a href=\"#!Sales Browser/Item Group\">To manage Item Groups, click here</a>",
"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. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>",
"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": "<div class=\"help-box\">For more accounting defaults, Open <a href=\"#!List/Company\">Company</a></div>",
"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": "<a href=\"#!Sales Browser/Customer Group\">To manage Customer Groups, click here</a>",
"read_only": 0
"options": "<a href=\"#!Sales Browser/Customer Group\">To manage Customer Groups, click here</a>"
},
{
"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": "<a href=\"#!Sales Browser/Territory\">To manage Territory, click here</a>",
"read_only": 0
"options": "<a href=\"#!Sales Browser/Territory\">To manage Territory, click here</a>"
},
{
"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": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>",
"read_only": 0
"options": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>"
},
{
"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"

View File

@ -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"
}]
]

View File

@ -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]

View File

@ -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()

View File

@ -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)

View File

View File

@ -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, ""))

View File

@ -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": "<a href=\"#Sales Browser/Item Group\">Manage Item Groups</a>",
"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"
}
]

View File

@ -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"),

View File

@ -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):