[patch] breakup global defaults

This commit is contained in:
Rushabh Mehta 2013-06-25 11:46:07 +05:30
parent 7a93d5de30
commit d242a8babd
13 changed files with 125 additions and 225 deletions

View File

@ -330,16 +330,14 @@ class DocType(BuyingController):
self.doc.against_expense_account = ",".join(against_accounts) self.doc.against_expense_account = ",".join(against_accounts)
def po_required(self): def po_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'po_required'") if webnotes.conn.get_single_value("Buying Settings", "po_required") == 'Yes':
if res and res[0][0] == 'Yes':
for d in getlist(self.doclist,'entries'): for d in getlist(self.doclist,'entries'):
if not d.purchase_order: if not d.purchase_order:
msgprint("Purchse Order No. required against item %s"%d.item_code) msgprint("Purchse Order No. required against item %s"%d.item_code)
raise Exception raise Exception
def pr_required(self): def pr_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'pr_required'") if webnotes.conn.get_single_value("Buying Settings", "pr_required") == 'Yes':
if res and res[0][0] == 'Yes':
for d in getlist(self.doclist,'entries'): for d in getlist(self.doclist,'entries'):
if not d.purchase_receipt: if not d.purchase_receipt:
msgprint("Purchase Receipt No. required against item %s"%d.item_code) msgprint("Purchase Receipt No. required against item %s"%d.item_code)

View File

@ -460,7 +460,7 @@ class DocType(SellingController):
"""check in manage account if sales order / delivery note required or not.""" """check in manage account if sales order / delivery note required or not."""
dic = {'Sales Order':'so_required','Delivery Note':'dn_required'} dic = {'Sales Order':'so_required','Delivery Note':'dn_required'}
for i in dic: for i in dic:
if webnotes.conn.get_value('Global Defaults', 'Global Defaults', dic[i]) == 'Yes': if webnotes.conn.get_single_value('Selling Settings', dic[i]) == 'Yes':
for d in getlist(self.doclist,'entries'): for d in getlist(self.doclist,'entries'):
if webnotes.conn.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \ if webnotes.conn.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \
and not d.fields[i.lower().replace(' ','_')]: and not d.fields[i.lower().replace(' ','_')]:

View File

@ -53,6 +53,12 @@ wn.module_page["Buying"] = [
title: wn._("Setup"), title: wn._("Setup"),
icon: "icon-cog", icon: "icon-cog",
items: [ items: [
{
"label": wn._("Buying Settings"),
"route": "Form/Buying Settings",
"doctype":"Buying Settings",
"description": "Settings for Buying Module"
},
{ {
"label": wn._("Purchase Taxes and Charges Master"), "label": wn._("Purchase Taxes and Charges Master"),
"doctype":"Purchase Taxes and Charges Master", "doctype":"Purchase Taxes and Charges Master",

View File

@ -10,7 +10,11 @@ def execute():
"reorder_email_notify": "Stock Settings", "reorder_email_notify": "Stock Settings",
"tolerance": "Stock Settings", "tolerance": "Stock Settings",
"stock_frozen_upto": "Stock Settings", "stock_frozen_upto": "Stock Settings",
"stock_auth_role": "Stock Settings" "stock_auth_role": "Stock Settings",
"so_required": "Selling Settings",
"dn_required": "Selling Settings",
"po_required": "Selling Settings",
"pr_required": "Selling Settings"
} }
from_defaults = { from_defaults = {
@ -18,7 +22,14 @@ def execute():
"item_naming_by": "Stock Settings", "item_naming_by": "Stock Settings",
"stock_uom": "Stock Settings", "stock_uom": "Stock Settings",
"valuation_method": "Stock Settings", "valuation_method": "Stock Settings",
"allow_negative_stock": "Stock Settings" "allow_negative_stock": "Stock Settings",
"cust_master_name": "Selling Settings",
"customer_group": "Selling Settings",
"territory": "Selling Settings",
"price_list_name": "Selling Settings",
"supplier_type": "Buying Settings",
"supp_master_name": "Buying Settings",
"maintain_same_rate": "Buying Settings"
} }
for key in from_global_defaults: for key in from_global_defaults:

View File

@ -246,4 +246,5 @@ patch_list = [
"patches.june_2013.p06_drop_unused_tables", "patches.june_2013.p06_drop_unused_tables",
"patches.june_2013.p08_shopping_cart_settings", "patches.june_2013.p08_shopping_cart_settings",
"patches.june_2013.p05_remove_search_criteria_reports", "patches.june_2013.p05_remove_search_criteria_reports",
"patches.june_2013.p09_update_global_defaults",
] ]

View File

@ -58,6 +58,12 @@ wn.module_page["Selling"] = [
title: wn._("Setup"), title: wn._("Setup"),
icon: "icon-cog", icon: "icon-cog",
items: [ items: [
{
"label": wn._("Selling Settings"),
"route": "Form/Selling Settings",
"doctype":"Selling Settings",
"description": "Settings for Selling Module"
},
{ {
label: wn._("Sales Taxes and Charges Master"), label: wn._("Sales Taxes and Charges Master"),
description: wn._("Sales taxes template."), description: wn._("Sales taxes template."),

View File

@ -19,12 +19,4 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){
sys_defaults = r.message; sys_defaults = r.message;
}); });
}
cur_frm.fields_dict['default_territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';
}
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';
} }

View File

@ -27,18 +27,10 @@ keydict = {
'company': 'default_company', 'company': 'default_company',
'currency': 'default_currency', 'currency': 'default_currency',
'hide_currency_symbol':'hide_currency_symbol', 'hide_currency_symbol':'hide_currency_symbol',
'price_list_name': 'default_price_list',
'price_list_currency': 'default_price_list_currency',
'customer_group': 'default_customer_group',
'cust_master_name': 'cust_master_name',
'supplier_type': 'default_supplier_type',
'supp_master_name': 'supp_master_name',
'territory': 'default_territory',
'date_format': 'date_format', 'date_format': 'date_format',
'number_format': 'number_format', 'number_format': 'number_format',
'float_precision': 'float_precision', 'float_precision': 'float_precision',
'account_url':'account_url', 'account_url':'account_url',
'maintain_same_rate' : 'maintain_same_rate',
'session_expiry': 'session_expiry', 'session_expiry': 'session_expiry',
'disable_rounded_total': 'disable_rounded_total' 'disable_rounded_total': 'disable_rounded_total'
} }

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-02 17:53:24", "creation": "2013-05-02 17:53:24",
"docstatus": 0, "docstatus": 0,
"modified": "2013-06-24 17:07:55", "modified": "2013-06-25 11:20:40",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -24,8 +24,7 @@
"parent": "Global Defaults", "parent": "Global Defaults",
"parentfield": "fields", "parentfield": "fields",
"parenttype": "DocType", "parenttype": "DocType",
"permlevel": 0, "permlevel": 0
"read_only": 0
}, },
{ {
"amend": 0, "amend": 0,
@ -49,72 +48,49 @@
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "general", "fieldname": "date_and_number_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "General" "label": "Date and Number Settings"
},
{
"description": "Session Expiry in Hours e.g. 06:00",
"doctype": "DocField",
"fieldname": "session_expiry",
"fieldtype": "Data",
"label": "Session Expiry"
},
{
"doctype": "DocField",
"fieldname": "column_break_3",
"fieldtype": "Column Break"
},
{
"description": "For Server Side Print Formats",
"doctype": "DocField",
"fieldname": "print_style",
"fieldtype": "Select",
"label": "Print Format Style",
"options": "Standard\nClassic\nModern\nSpartan"
},
{
"doctype": "DocField",
"fieldname": "company",
"fieldtype": "Section Break",
"label": "Company"
},
{
"doctype": "DocField",
"fieldname": "default_company",
"fieldtype": "Link",
"label": "Default Company",
"options": "Company",
"reqd": 0
},
{
"doctype": "DocField",
"fieldname": "current_fiscal_year",
"fieldtype": "Link",
"label": "Current Fiscal Year",
"options": "Fiscal Year",
"reqd": 1
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "date_format", "fieldname": "date_format",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Date Format", "label": "Date Format",
"options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy" "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy",
"read_only": 0
}, },
{ {
"default": "This is the default number format. For currencies, please set the number format in the currency master.",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "column_break1", "fieldname": "number_format",
"fieldtype": "Column Break",
"width": "50%"
},
{
"description": "Do not show any symbol like $ etc next to currencies.",
"doctype": "DocField",
"fieldname": "hide_currency_symbol",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Hide Currency Symbol", "label": "Number Format",
"options": "\nNo\nYes" "options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###",
"read_only": 0
},
{
"description": "Precision for Float fields (quantities, discounts, percentages etc) only for display. Floats will still be calculated up to 6 decimals.",
"doctype": "DocField",
"fieldname": "float_precision",
"fieldtype": "Select",
"label": "Float Precision",
"options": "\n2\n3\n4\n5\n6",
"read_only": 0
},
{
"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
},
{
"doctype": "DocField",
"fieldname": "currency_settings",
"fieldtype": "Section Break",
"label": "Currency Settings"
}, },
{ {
"default": "INR", "default": "INR",
@ -123,164 +99,87 @@
"fieldtype": "Link", "fieldtype": "Link",
"label": "Default Currency", "label": "Default Currency",
"options": "Currency", "options": "Currency",
"read_only": 0,
"reqd": 1 "reqd": 1
}, },
{ {
"default": "This is the default number format. For currencies, please set the number format in the currency master.", "description": "Do not show any symbol like $ etc next to currencies.",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "number_format", "fieldname": "hide_currency_symbol",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Number Format", "label": "Hide Currency Symbol",
"options": "\n#,###.##\n#.###,##\n# ###.##\n#,###.###\n#,##,###.##\n#.###\n#,###" "options": "\nNo\nYes",
}, "read_only": 0
{
"description": "Precision for Float fields (quantities, discounts, percentages etc) only for display. Floats will still be calculated up to 6 decimals.",
"doctype": "DocField",
"fieldname": "float_precision",
"fieldtype": "Select",
"label": "Float Precision",
"options": "\n2\n3\n4\n5\n6"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "selling", "fieldname": "company",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Selling" "label": "Company Settings",
}, "read_only": 0
{
"default": "Customer Name",
"doctype": "DocField",
"fieldname": "cust_master_name",
"fieldtype": "Select",
"label": "Customer Master created by ",
"options": "Customer Name\nNaming Series"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "default_customer_group", "fieldname": "default_company",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Default Customer Group", "label": "Default Company",
"options": "Customer Group" "options": "Company",
"read_only": 0,
"reqd": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "cghelp", "fieldname": "current_fiscal_year",
"fieldtype": "HTML",
"label": "CGHelp",
"options": "<a href=\"#!Sales Browser/Customer Group\">To manage Customer Groups, click here</a>"
},
{
"doctype": "DocField",
"fieldname": "default_territory",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Default Territory", "label": "Current Fiscal Year",
"options": "Territory" "options": "Fiscal Year",
"read_only": 0,
"reqd": 1
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "territoryhelp", "fieldname": "system",
"fieldtype": "HTML",
"label": "TerritoryHelp",
"options": "<a href=\"#!Sales Browser/Territory\">To manage Territory, click here</a>"
},
{
"doctype": "DocField",
"fieldname": "column_break5",
"fieldtype": "Column Break",
"width": "50%"
},
{
"doctype": "DocField",
"fieldname": "default_price_list",
"fieldtype": "Link",
"label": "Default Price List",
"options": "Price List"
},
{
"doctype": "DocField",
"fieldname": "default_price_list_currency",
"fieldtype": "Link",
"label": "Default Price List Currency",
"options": "Currency"
},
{
"default": "No",
"doctype": "DocField",
"fieldname": "so_required",
"fieldtype": "Select",
"label": "Sales Order Required",
"options": "No\nYes"
},
{
"default": "No",
"doctype": "DocField",
"fieldname": "dn_required",
"fieldtype": "Select",
"label": "Delivery Note Required",
"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"
},
{
"doctype": "DocField",
"fieldname": "buying",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "Buying" "label": "System Settings",
"read_only": 0
},
{
"description": "Session Expiry in Hours e.g. 06:00",
"doctype": "DocField",
"fieldname": "session_expiry",
"fieldtype": "Data",
"label": "Session Expiry",
"read_only": 0
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "default_supplier_type", "fieldname": "sms_sender_name",
"fieldtype": "Link", "fieldtype": "Data",
"label": "Default Supplier Type", "label": "SMS Sender Name",
"options": "Supplier Type" "read_only": 0
},
{
"default": "Supplier Name",
"doctype": "DocField",
"fieldname": "supp_master_name",
"fieldtype": "Select",
"label": "Supplier Master created by ",
"options": "Supplier Name\nNaming Series"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "column_break6", "fieldname": "column_break_3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"width": "50%" "read_only": 0
}, },
{ {
"default": "No", "description": "For Server Side Print Formats",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "po_required", "fieldname": "print_style",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Purchase Order Required", "label": "Print Format Style",
"options": "No\nYes" "options": "Standard\nClassic\nModern\nSpartan",
}, "read_only": 0
{
"default": "No",
"doctype": "DocField",
"fieldname": "pr_required",
"fieldtype": "Select",
"label": "Purchase Receipt Required",
"options": "No\nYes"
},
{
"doctype": "DocField",
"fieldname": "maintain_same_rate",
"fieldtype": "Check",
"label": "Maintain same rate throughout purchase cycle"
}, },
{ {
"doctype": "DocField", "doctype": "DocField",
"fieldname": "hr", "fieldname": "hr",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"label": "HR", "label": "HR",
"options": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>" "options": "<div style=\"padding-top: 8px;\" class=\"columnHeading\">HR</div>",
"read_only": 0
}, },
{ {
"description": "Employee record is created using selected field. ", "description": "Employee record is created using selected field. ",
@ -288,19 +187,8 @@
"fieldname": "emp_created_by", "fieldname": "emp_created_by",
"fieldtype": "Select", "fieldtype": "Select",
"label": "Employee Records to be created by ", "label": "Employee Records to be created by ",
"options": "Naming Series\nEmployee Number" "options": "Naming Series\nEmployee Number",
}, "read_only": 0
{
"doctype": "DocField",
"fieldname": "system",
"fieldtype": "Section Break",
"label": "System"
},
{
"doctype": "DocField",
"fieldname": "sms_sender_name",
"fieldtype": "Data",
"label": "SMS Sender Name"
}, },
{ {
"doctype": "DocPerm" "doctype": "DocPerm"

View File

@ -69,16 +69,10 @@ class DocType:
'current_fiscal_year':curr_fiscal_year, 'current_fiscal_year':curr_fiscal_year,
'default_currency': args.get('currency'), 'default_currency': args.get('currency'),
'default_company':args.get('company_name'), 'default_company':args.get('company_name'),
'default_stock_uom':'Nos',
'date_format': webnotes.conn.get_value("Country", 'date_format': webnotes.conn.get_value("Country",
args.get("country"), "date_format"), args.get("country"), "date_format"),
'so_required':'No',
'dn_required':'No',
'po_required':'No',
'pr_required':'No',
'emp_created_by':'Naming Series', 'emp_created_by':'Naming Series',
'cust_master_name':'Customer Name', "float_precision": 4
'supp_master_name':'Supplier Name'
} }
# Set # Set
@ -94,6 +88,19 @@ class DocType:
stock_settings.doc.auto_indent = 1 stock_settings.doc.auto_indent = 1
stock_settings.save() stock_settings.save()
selling_settings = webnotes.bean("Selling Settings")
selling_settings.cust_master_name = "Customer Name"
selling_settings.doc.so_required = "No"
selling_settings.doc.dn_required = "No"
selling_settings.save()
buying_settings = webnotes.bean("Buying Settings")
buying_settings.doc.supp_master_name = "Supplier Name"
buying_settings.doc.po_required = "No"
buying_settings.doc.pr_required = "No"
buying_settings.doc.maintain_same_rate = 1
buying_settings.save()
cp_args = {} cp_args = {}
for k in ['industry', 'country', 'timezone', 'company_name']: for k in ['industry', 'country', 'timezone', 'company_name']:
cp_args[k] = args[k] cp_args[k] = args[k]

View File

@ -104,7 +104,7 @@ class DocType(SellingController):
def so_required(self): def so_required(self):
"""check in manage account if sales order required or not""" """check in manage account if sales order required or not"""
if webnotes.conn.get_value('Global Defaults', 'Global Defaults', 'so_required') == 'Yes': if webnotes.conn.get_single_value("Selling Settings", 'so_required') == 'Yes':
for d in getlist(self.doclist,'delivery_note_details'): for d in getlist(self.doclist,'delivery_note_details'):
if not d.prevdoc_docname: if not d.prevdoc_docname:
msgprint("Sales Order No. required against item %s"%d.item_code) msgprint("Sales Order No. required against item %s"%d.item_code)

View File

@ -95,8 +95,7 @@ class DocType(BuyingController):
Please enter a valid Challan No.", raise_exception=1) Please enter a valid Challan No.", raise_exception=1)
def po_required(self): def po_required(self):
res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'po_required'") if webnotes.conn.get_single_value("Buying Settings", "po_required") == 'Yes':
if res and res[0][0]== 'Yes':
for d in getlist(self.doclist,'purchase_receipt_details'): for d in getlist(self.doclist,'purchase_receipt_details'):
if not d.prevdoc_docname: if not d.prevdoc_docname:
msgprint("Purchse Order No. required against item %s"%d.item_code) msgprint("Purchse Order No. required against item %s"%d.item_code)

View File

@ -105,7 +105,7 @@ wn.module_page["Stock"] = [
"label": wn._("Stock Settings"), "label": wn._("Stock Settings"),
"route": "Form/Stock Settings", "route": "Form/Stock Settings",
"doctype":"Stock Settings", "doctype":"Stock Settings",
"description": "Settings for Stock" "description": "Settings for Stock Module"
}, },
{ {
"route":"Sales Browser/Item Group", "route":"Sales Browser/Item Group",