From d242a8babd44f9cf21d9381895467120d1432ff0 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 25 Jun 2013 11:46:07 +0530 Subject: [PATCH] [patch] breakup global defaults --- .../purchase_invoice/purchase_invoice.py | 6 +- .../doctype/sales_invoice/sales_invoice.py | 2 +- buying/page/buying_home/buying_home.js | 6 + .../june_2013/p09_update_global_defaults.py | 15 +- patches/patch_list.py | 1 + selling/page/selling_home/selling_home.js | 6 + .../global_defaults/global_defaults.js | 8 - .../global_defaults/global_defaults.py | 8 - .../global_defaults/global_defaults.txt | 270 +++++------------- setup/doctype/setup_control/setup_control.py | 21 +- stock/doctype/delivery_note/delivery_note.py | 2 +- .../purchase_receipt/purchase_receipt.py | 3 +- stock/page/stock_home/stock_home.js | 2 +- 13 files changed, 125 insertions(+), 225 deletions(-) diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 56d6075f5b..980d4e817c 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -330,16 +330,14 @@ class DocType(BuyingController): self.doc.against_expense_account = ",".join(against_accounts) def po_required(self): - res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'po_required'") - if res and res[0][0] == 'Yes': + if webnotes.conn.get_single_value("Buying Settings", "po_required") == 'Yes': for d in getlist(self.doclist,'entries'): if not d.purchase_order: msgprint("Purchse Order No. required against item %s"%d.item_code) raise Exception def pr_required(self): - res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'pr_required'") - if res and res[0][0] == 'Yes': + if webnotes.conn.get_single_value("Buying Settings", "pr_required") == 'Yes': for d in getlist(self.doclist,'entries'): if not d.purchase_receipt: msgprint("Purchase Receipt No. required against item %s"%d.item_code) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index 2d4de498ad..59c84d4927 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -460,7 +460,7 @@ class DocType(SellingController): """check in manage account if sales order / delivery note required or not.""" dic = {'Sales Order':'so_required','Delivery Note':'dn_required'} 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'): if webnotes.conn.get_value('Item', d.item_code, 'is_stock_item') == 'Yes' \ and not d.fields[i.lower().replace(' ','_')]: diff --git a/buying/page/buying_home/buying_home.js b/buying/page/buying_home/buying_home.js index e996c04c83..0151a60c87 100644 --- a/buying/page/buying_home/buying_home.js +++ b/buying/page/buying_home/buying_home.js @@ -53,6 +53,12 @@ wn.module_page["Buying"] = [ title: wn._("Setup"), icon: "icon-cog", items: [ + { + "label": wn._("Buying Settings"), + "route": "Form/Buying Settings", + "doctype":"Buying Settings", + "description": "Settings for Buying Module" + }, { "label": wn._("Purchase Taxes and Charges Master"), "doctype":"Purchase Taxes and Charges Master", diff --git a/patches/june_2013/p09_update_global_defaults.py b/patches/june_2013/p09_update_global_defaults.py index d2aebb1a90..0148b673cf 100644 --- a/patches/june_2013/p09_update_global_defaults.py +++ b/patches/june_2013/p09_update_global_defaults.py @@ -10,7 +10,11 @@ def execute(): "reorder_email_notify": "Stock Settings", "tolerance": "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 = { @@ -18,7 +22,14 @@ def execute(): "item_naming_by": "Stock Settings", "stock_uom": "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: diff --git a/patches/patch_list.py b/patches/patch_list.py index dc489f6273..805c3b51a6 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -246,4 +246,5 @@ patch_list = [ "patches.june_2013.p06_drop_unused_tables", "patches.june_2013.p08_shopping_cart_settings", "patches.june_2013.p05_remove_search_criteria_reports", + "patches.june_2013.p09_update_global_defaults", ] \ No newline at end of file diff --git a/selling/page/selling_home/selling_home.js b/selling/page/selling_home/selling_home.js index 73cc7185c8..ef419c5ed1 100644 --- a/selling/page/selling_home/selling_home.js +++ b/selling/page/selling_home/selling_home.js @@ -58,6 +58,12 @@ wn.module_page["Selling"] = [ title: wn._("Setup"), icon: "icon-cog", items: [ + { + "label": wn._("Selling Settings"), + "route": "Form/Selling Settings", + "doctype":"Selling Settings", + "description": "Settings for Selling Module" + }, { label: wn._("Sales Taxes and Charges Master"), description: wn._("Sales taxes template."), diff --git a/setup/doctype/global_defaults/global_defaults.js b/setup/doctype/global_defaults/global_defaults.js index 246bacf49e..fa80025037 100644 --- a/setup/doctype/global_defaults/global_defaults.js +++ b/setup/doctype/global_defaults/global_defaults.js @@ -19,12 +19,4 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) { $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ 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'; } \ 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 349bba5d45..52a291fdac 100644 --- a/setup/doctype/global_defaults/global_defaults.py +++ b/setup/doctype/global_defaults/global_defaults.py @@ -27,18 +27,10 @@ keydict = { 'company': 'default_company', 'currency': 'default_currency', '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', 'number_format': 'number_format', 'float_precision': 'float_precision', 'account_url':'account_url', - 'maintain_same_rate' : 'maintain_same_rate', 'session_expiry': 'session_expiry', 'disable_rounded_total': 'disable_rounded_total' } diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 7f17f16dcc..98a428c311 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-06-24 17:07:55", + "modified": "2013-06-25 11:20:40", "modified_by": "Administrator", "owner": "Administrator" }, @@ -24,8 +24,7 @@ "parent": "Global Defaults", "parentfield": "fields", "parenttype": "DocType", - "permlevel": 0, - "read_only": 0 + "permlevel": 0 }, { "amend": 0, @@ -49,72 +48,49 @@ }, { "doctype": "DocField", - "fieldname": "general", + "fieldname": "date_and_number_settings", "fieldtype": "Section Break", - "label": "General" - }, - { - "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 + "label": "Date and Number Settings" }, { "doctype": "DocField", "fieldname": "date_format", "fieldtype": "Select", "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", - "fieldname": "column_break1", - "fieldtype": "Column Break", - "width": "50%" - }, - { - "description": "Do not show any symbol like $ etc next to currencies.", - "doctype": "DocField", - "fieldname": "hide_currency_symbol", + "fieldname": "number_format", "fieldtype": "Select", - "label": "Hide Currency Symbol", - "options": "\nNo\nYes" + "label": "Number Format", + "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", @@ -123,164 +99,87 @@ "fieldtype": "Link", "label": "Default Currency", "options": "Currency", + "read_only": 0, "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", - "fieldname": "number_format", + "fieldname": "hide_currency_symbol", "fieldtype": "Select", - "label": "Number Format", - "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.", - "doctype": "DocField", - "fieldname": "float_precision", - "fieldtype": "Select", - "label": "Float Precision", - "options": "\n2\n3\n4\n5\n6" + "label": "Hide Currency Symbol", + "options": "\nNo\nYes", + "read_only": 0 }, { "doctype": "DocField", - "fieldname": "selling", + "fieldname": "company", "fieldtype": "Section Break", - "label": "Selling" - }, - { - "default": "Customer Name", - "doctype": "DocField", - "fieldname": "cust_master_name", - "fieldtype": "Select", - "label": "Customer Master created by ", - "options": "Customer Name\nNaming Series" + "label": "Company Settings", + "read_only": 0 }, { "doctype": "DocField", - "fieldname": "default_customer_group", + "fieldname": "default_company", "fieldtype": "Link", - "label": "Default Customer Group", - "options": "Customer Group" + "label": "Default Company", + "options": "Company", + "read_only": 0, + "reqd": 0 }, { "doctype": "DocField", - "fieldname": "cghelp", - "fieldtype": "HTML", - "label": "CGHelp", - "options": "To manage Customer Groups, click here" - }, - { - "doctype": "DocField", - "fieldname": "default_territory", + "fieldname": "current_fiscal_year", "fieldtype": "Link", - "label": "Default Territory", - "options": "Territory" + "label": "Current Fiscal Year", + "options": "Fiscal Year", + "read_only": 0, + "reqd": 1 }, { "doctype": "DocField", - "fieldname": "territoryhelp", - "fieldtype": "HTML", - "label": "TerritoryHelp", - "options": "To manage Territory, click here" - }, - { - "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", + "fieldname": "system", "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", - "fieldname": "default_supplier_type", - "fieldtype": "Link", - "label": "Default Supplier Type", - "options": "Supplier Type" - }, - { - "default": "Supplier Name", - "doctype": "DocField", - "fieldname": "supp_master_name", - "fieldtype": "Select", - "label": "Supplier Master created by ", - "options": "Supplier Name\nNaming Series" + "fieldname": "sms_sender_name", + "fieldtype": "Data", + "label": "SMS Sender Name", + "read_only": 0 }, { "doctype": "DocField", - "fieldname": "column_break6", + "fieldname": "column_break_3", "fieldtype": "Column Break", - "width": "50%" + "read_only": 0 }, { - "default": "No", + "description": "For Server Side Print Formats", "doctype": "DocField", - "fieldname": "po_required", + "fieldname": "print_style", "fieldtype": "Select", - "label": "Purchase Order Required", - "options": "No\nYes" - }, - { - "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" + "label": "Print Format Style", + "options": "Standard\nClassic\nModern\nSpartan", + "read_only": 0 }, { "doctype": "DocField", "fieldname": "hr", "fieldtype": "Section Break", "label": "HR", - "options": "
HR
" + "options": "
HR
", + "read_only": 0 }, { "description": "Employee record is created using selected field. ", @@ -288,19 +187,8 @@ "fieldname": "emp_created_by", "fieldtype": "Select", "label": "Employee Records to be created by ", - "options": "Naming Series\nEmployee Number" - }, - { - "doctype": "DocField", - "fieldname": "system", - "fieldtype": "Section Break", - "label": "System" - }, - { - "doctype": "DocField", - "fieldname": "sms_sender_name", - "fieldtype": "Data", - "label": "SMS Sender Name" + "options": "Naming Series\nEmployee Number", + "read_only": 0 }, { "doctype": "DocPerm" diff --git a/setup/doctype/setup_control/setup_control.py b/setup/doctype/setup_control/setup_control.py index ebb528f70a..0f4f6a1e70 100644 --- a/setup/doctype/setup_control/setup_control.py +++ b/setup/doctype/setup_control/setup_control.py @@ -69,16 +69,10 @@ class DocType: 'current_fiscal_year':curr_fiscal_year, 'default_currency': args.get('currency'), 'default_company':args.get('company_name'), - 'default_stock_uom':'Nos', 'date_format': webnotes.conn.get_value("Country", args.get("country"), "date_format"), - 'so_required':'No', - 'dn_required':'No', - 'po_required':'No', - 'pr_required':'No', 'emp_created_by':'Naming Series', - 'cust_master_name':'Customer Name', - 'supp_master_name':'Supplier Name' + "float_precision": 4 } # Set @@ -94,6 +88,19 @@ class DocType: stock_settings.doc.auto_indent = 1 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 = {} for k in ['industry', 'country', 'timezone', 'company_name']: cp_args[k] = args[k] diff --git a/stock/doctype/delivery_note/delivery_note.py b/stock/doctype/delivery_note/delivery_note.py index fd74976ce6..30647a1b7a 100644 --- a/stock/doctype/delivery_note/delivery_note.py +++ b/stock/doctype/delivery_note/delivery_note.py @@ -104,7 +104,7 @@ class DocType(SellingController): def so_required(self): """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'): if not d.prevdoc_docname: msgprint("Sales Order No. required against item %s"%d.item_code) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.py b/stock/doctype/purchase_receipt/purchase_receipt.py index 83322c18a5..49b9bd05ad 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.py +++ b/stock/doctype/purchase_receipt/purchase_receipt.py @@ -95,8 +95,7 @@ class DocType(BuyingController): Please enter a valid Challan No.", raise_exception=1) def po_required(self): - res = sql("select value from `tabSingles` where doctype = 'Global Defaults' and field = 'po_required'") - if res and res[0][0]== 'Yes': + if webnotes.conn.get_single_value("Buying Settings", "po_required") == 'Yes': for d in getlist(self.doclist,'purchase_receipt_details'): if not d.prevdoc_docname: msgprint("Purchse Order No. required against item %s"%d.item_code) diff --git a/stock/page/stock_home/stock_home.js b/stock/page/stock_home/stock_home.js index 3b6af0364c..c92c6fe5f9 100644 --- a/stock/page/stock_home/stock_home.js +++ b/stock/page/stock_home/stock_home.js @@ -105,7 +105,7 @@ wn.module_page["Stock"] = [ "label": wn._("Stock Settings"), "route": "Form/Stock Settings", "doctype":"Stock Settings", - "description": "Settings for Stock" + "description": "Settings for Stock Module" }, { "route":"Sales Browser/Item Group",