[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

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