From b5171539cca75f5b552a2b49b29b9483a49bf925 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 12 Dec 2012 11:03:16 +0530 Subject: [PATCH 01/20] Expense Claim option removed from authorization rule --- hr/doctype/expense_claim/expense_claim.py | 8 +- .../authorization_control.py | 2 +- .../authorization_rule/authorization_rule.js | 18 +- .../authorization_rule/authorization_rule.py | 136 ++++--- .../authorization_rule/authorization_rule.txt | 371 ++++++++---------- 5 files changed, 245 insertions(+), 290 deletions(-) diff --git a/hr/doctype/expense_claim/expense_claim.py b/hr/doctype/expense_claim/expense_claim.py index 9fdb2335bb..9e476e5595 100644 --- a/hr/doctype/expense_claim/expense_claim.py +++ b/hr/doctype/expense_claim/expense_claim.py @@ -20,6 +20,7 @@ import webnotes from webnotes.utils import add_days from webnotes.model.wrapper import getlist from webnotes import form, msgprint +from webnotes.model.code import get_obj sql = webnotes.conn.sql @@ -36,8 +37,8 @@ class DocType: def on_submit(self): if self.doc.approval_status=="Draft": - webnotes.msgprint("""Please set Approval Status to 'Approved' or 'Rejected' before submitting""", - raise_exception=1) + webnotes.msgprint("""Please set Approval Status to 'Approved' or \ + 'Rejected' before submitting""", raise_exception=1) def validate_fiscal_year(self): fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year) @@ -57,5 +58,6 @@ def get_approver_list(): roles = [r[0] for r in webnotes.conn.sql("""select distinct parent from `tabUserRole` where role='Expense Approver'""")] if not roles: - webnotes.msgprint("No Expense Approvers. Please assign 'Expense Approver' Role to atleast one user.") + webnotes.msgprint("No Expense Approvers. Please assign 'Expense Approver' \ + Role to atleast one user.") return roles diff --git a/setup/doctype/authorization_control/authorization_control.py b/setup/doctype/authorization_control/authorization_control.py index 9e0d979f30..9455f8a874 100644 --- a/setup/doctype/authorization_control/authorization_control.py +++ b/setup/doctype/authorization_control/authorization_control.py @@ -60,7 +60,7 @@ class DocType(TransactionBase): if appr_users: add_msg = "Users : "+cstr(appr_users) if appr_roles: add_msg = "Roles : "+cstr(appr_roles) if appr_users and appr_roles: add_msg = "Users : "+cstr(appr_users)+" or "+"Roles : "+cstr(appr_roles) - msgprint("You do not have an authority to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg)) + msgprint("You are not authorize to submit this %s %s. Please send for approval to %s" % (doctype_name, msg, add_msg)) raise Exception diff --git a/setup/doctype/authorization_rule/authorization_rule.js b/setup/doctype/authorization_rule/authorization_rule.js index b29d88915e..184c761b9d 100644 --- a/setup/doctype/authorization_rule/authorization_rule.js +++ b/setup/doctype/authorization_rule/authorization_rule.js @@ -26,13 +26,13 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { cur_frm.cscript.refresh = function(doc,cdt,cdn){ - if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable') hide_field('master_name'); + if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable') hide_field('master_name'); else unhide_field('master_name'); if(doc.based_on == 'Not Applicable') hide_field('value'); else unhide_field('value'); - if(doc.transaction == 'Expense Claim' || doc.transaction == 'Appraisal'){ + if(doc.transaction == 'Appraisal'){ hide_field(['master_name','system_role', 'system_user']); unhide_field(['to_emp','to_designation']); if(doc.transaction == 'Appraisal') hide_field('value'); @@ -45,7 +45,7 @@ cur_frm.cscript.refresh = function(doc,cdt,cdn){ } cur_frm.cscript.based_on = function(doc){ - if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Total Claimed Amount' || doc.based_on == 'Not Applicable'){ + if(doc.based_on == 'Grand Total' || doc.based_on == 'Average Discount' || doc.based_on == 'Not Applicable'){ doc.master_name = ''; refresh_field('master_name'); hide_field('master_name'); @@ -63,24 +63,20 @@ cur_frm.cscript.based_on = function(doc){ } cur_frm.cscript.transaction = function(doc,cdt,cdn){ - if(doc.transaction == 'Expense Claim' || doc.transaction == 'Appraisal'){ + if (doc.transaction == 'Appraisal'){ doc.master_name = doc.system_role = doc.system_user = ''; refresh_many(['master_name','system_role', 'system_user']); hide_field(['master_name','system_role', 'system_user']); unhide_field(['to_emp','to_designation']); - if(doc.transaction == 'Appraisal') { - doc.value =0; - refresh_many('value'); - hide_field('value'); - } - else unhide_field('value'); + doc.value =0; + refresh_many('value'); + hide_field('value'); } else { unhide_field(['master_name','system_role', 'system_user','value']); hide_field(['to_emp','to_designation']); } - if(doc.transaction == 'Expense Claim') doc.based_on = 'Total Claimed Amount'; if(doc.transaction == 'Appraisal') doc.based_on == 'Not Applicable'; } diff --git a/setup/doctype/authorization_rule/authorization_rule.py b/setup/doctype/authorization_rule/authorization_rule.py index a3646c06ae..be6c0aee33 100644 --- a/setup/doctype/authorization_rule/authorization_rule.py +++ b/setup/doctype/authorization_rule/authorization_rule.py @@ -8,11 +8,11 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . from __future__ import unicode_literals import webnotes @@ -27,74 +27,80 @@ sql = webnotes.conn.sql class DocType: - def __init__(self, d, dl): - self.doc, self.doclist = d, dl + def __init__(self, d, dl): + self.doc, self.doclist = d, dl - # Duplicate Entry - # ---------------- - def check_duplicate_entry(self): - exists = sql("select name, docstatus from `tabAuthorization Rule` where transaction = %s and based_on = %s and system_user = %s and system_role = %s and approving_user = %s and approving_role = %s and to_emp =%s and to_designation=%s and name != %s", (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user), cstr(self.doc.system_role), cstr(self.doc.approving_user), cstr(self.doc.approving_role), cstr(self.doc.to_emp), cstr(self.doc.to_designation), self.doc.name)) - auth_exists = exists and exists[0][0] or '' - if auth_exists: - if cint(exists[0][1]) == 2: - msgprint("Duplicate Entry. Please remove from trash Authorization Rule : %s." %(auth_exists)) - raise Exception - else: - msgprint("Duplicate Entry. Please check Authorization Rule : %s." % (auth_exists)) - raise Exception + def check_duplicate_entry(self): + exists = sql("""select name, docstatus from `tabAuthorization Rule` + where transaction = %s and based_on = %s and system_user = %s + and system_role = %s and approving_user = %s and approving_role = %s + and to_emp =%s and to_designation=%s and name != %s""", + (self.doc.transaction, self.doc.based_on, cstr(self.doc.system_user), + cstr(self.doc.system_role), cstr(self.doc.approving_user), + cstr(self.doc.approving_role), cstr(self.doc.to_emp), + cstr(self.doc.to_designation), self.doc.name)) + auth_exists = exists and exists[0][0] or '' + if auth_exists: + if cint(exists[0][1]) == 2: + msgprint("""Duplicate Entry. Please untrash Authorization Rule : %s \ + from Recycle Bin""" % (auth_exists), raise_exception=1) + else: + msgprint("Duplicate Entry. Please check Authorization Rule : %s" % + (auth_exists), raise_exception=1) - # Validate Master Name - # --------------------- - def validate_master_name(self): - if self.doc.based_on == 'Customerwise Discount' and not sql("select name from tabCustomer where name = '%s' and docstatus != 2" % (self.doc.master_name)): - msgprint("Please select valid Customer Name for Customerwise Discount.") - raise Exception - elif self.doc.based_on == 'Itemwise Discount' and not sql("select name from tabItem where name = '%s' and docstatus != 2" % (self.doc.master_name)): - msgprint("Please select valid Item Name for Itemwise Discount.") - raise Exception - elif (self.doc.based_on == 'Grand Total' or self.doc.based_on == 'Average Discount') and self.doc.master_name: - msgprint("Please remove Customer / Item Name for %s." % (self.doc.based_on)) - raise Exception + def validate_master_name(self): + if self.doc.based_on == 'Customerwise Discount' and \ + not sql("select name from tabCustomer where name = '%s' and docstatus != 2" % \ + (self.doc.master_name)): + msgprint("Please select valid Customer Name for Customerwise Discount", + raise_exception=1) + elif self.doc.based_on == 'Itemwise Discount' and \ + not sql("select name from tabItem where name = '%s' and docstatus != 2" % \ + (self.doc.master_name)): + msgprint("Please select valid Item Name for Itemwise Discount", raise_exception=1) + elif (self.doc.based_on == 'Grand Total' or \ + self.doc.based_on == 'Average Discount') and self.doc.master_name: + msgprint("Please remove Customer/Item Name for %s." % + self.doc.based_on, raise_exception=1) - # Validate Rule - # -------------- - def validate_rule(self): - if not self.doc.transaction == 'Expense Claim' and not self.doc.transaction == 'Appraisal': - if not self.doc.approving_role and not self.doc.approving_user: - msgprint("Please enter Approving Role or Approving User") - raise Exception - elif self.doc.system_user and self.doc.system_user == self.doc.approving_user: - msgprint("Approving User cannot be same as user the rule is Applicable To (User).") - raise Exception - elif self.doc.system_role and self.doc.system_role == self.doc.approving_role: - msgprint("Approving Role cannot be same as user the rule is Applicable To (Role).") - raise Exception - elif self.doc.system_user and self.doc.approving_role and has_common([self.doc.approving_role],[x[0] for x in sql("select role from `tabUserRole` where parent = '%s'" % (self.doc.system_user))]): - msgprint("System User : %s is assigned role : %s. So rule does not make sense." % (self.doc.system_user,self.doc.approving_role)) - raise Exception - elif (self.doc.transaction == 'Purchase Order' or self.doc.transaction == 'Purchase Receipt' or self.doc.transaction == 'Purchase Invoice' or self.doc.transaction == 'Stock Entry') and (self.doc.based_on == 'Average Discount' or self.doc.based_on == 'Customerwise Discount' or self.doc.based_on == 'Itemwise Discount'): - msgprint("You cannot set authorization on basis of Discount for %s." % (self.doc.transaction)) - raise Exception - elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00: - msgprint("Discount cannot given for more than 100 %s." % ('%')) - raise Exception - elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name: - msgprint("Please enter Customer Name for 'Customerwise Discount'") - raise Exception - else: - if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable': - msgprint("Based on is 'Not Applicable' while setting authorization rule for 'Appraisal'") - raise Exception - if self.doc.transaction == 'Expense Claim' and self.doc.based_on != 'Total Claimed Amount': - msgprint("Authorization rule should be based on 'Total Calimed Amount' while setting authorization rule for 'Expense Claim'") - raise Exception + def validate_rule(self): + if self.doc.transaction != 'Appraisal': + if not self.doc.approving_role and not self.doc.approving_user: + msgprint("Please enter Approving Role or Approving User", raise_exception=1) + elif self.doc.system_user and self.doc.system_user == self.doc.approving_user: + msgprint("Approving User cannot be same as user the rule is Applicable To (User)", + raise_exception=1) + elif self.doc.system_role and self.doc.system_role == self.doc.approving_role: + msgprint("Approving Role cannot be same as user the rule is \ + Applicable To (Role).", raise_exception=1) + elif self.doc.system_user and self.doc.approving_role and \ + has_common([self.doc.approving_role], [x[0] for x in \ + sql("select role from `tabUserRole` where parent = '%s'" % \ + (self.doc.system_user))]): + msgprint("System User : %s is assigned role : %s. So rule does not make sense" % + (self.doc.system_user,self.doc.approving_role), raise_exception=1) + elif self.doc.transaction in ['Purchase Order', 'Purchase Receipt', \ + 'Purchase Invoice', 'Stock Entry'] and self.doc.based_on \ + in ['Average Discount', 'Customerwise Discount', 'Itemwise Discount']: + msgprint("You cannot set authorization on basis of Discount for %s" % + self.doc.transaction, raise_exception=1) + elif self.doc.based_on == 'Average Discount' and flt(self.doc.value) > 100.00: + msgprint("Discount cannot given for more than 100%", raise_exception=1) + elif self.doc.based_on == 'Customerwise Discount' and not self.doc.master_name: + msgprint("Please enter Customer Name for 'Customerwise Discount'", + raise_exception=1) + else: + if self.doc.transaction == 'Appraisal' and self.doc.based_on != 'Not Applicable': + msgprint("Based on should be 'Not Applicable' while setting authorization rule\ + for 'Appraisal'", raise_exception=1) - def validate(self): - self.check_duplicate_entry() - self.validate_rule() - self.validate_master_name() - if not self.doc.value: self.doc.value = flt(0) \ No newline at end of file + + def validate(self): + self.check_duplicate_entry() + self.validate_rule() + self.validate_master_name() + if not self.doc.value: self.doc.value = 0.0 \ No newline at end of file diff --git a/setup/doctype/authorization_rule/authorization_rule.txt b/setup/doctype/authorization_rule/authorization_rule.txt index e358544982..7061da37b1 100644 --- a/setup/doctype/authorization_rule/authorization_rule.txt +++ b/setup/doctype/authorization_rule/authorization_rule.txt @@ -1,212 +1,163 @@ -# DocType, Authorization Rule [ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:36:18', - 'docstatus': 0, - 'modified': '2012-03-27 14:36:18', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': u'1308741898', - 'allow_trash': 1, - 'autoname': u'AR.####', - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'document_type': u'Master', - 'module': u'Setup', - 'name': '__common__', - 'search_fields': u'transaction,based_on,system_user,system_role,approving_user,approving_role', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 58 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'name': '__common__', - 'parent': u'Authorization Rule', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Authorization Rule', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'role': u'System Manager', - 'write': 1 - }, - - # DocType, Authorization Rule - { - 'doctype': 'DocType', - 'name': u'Authorization Rule' - }, - - # DocPerm - { - 'doctype': u'DocPerm' - }, - - # DocPerm - { - 'doctype': u'DocPerm' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'company', - 'fieldtype': u'Link', - 'label': u'Company', - 'oldfieldname': u'company', - 'oldfieldtype': u'Link', - 'options': u'Company', - 'reqd': 0, - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'transaction', - 'fieldtype': u'Select', - 'label': u'Transaction', - 'oldfieldname': u'transaction', - 'oldfieldtype': u'Select', - 'options': u'\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nExpense Claim\nAppraisal', - 'reqd': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'based_on', - 'fieldtype': u'Select', - 'label': u'Based On', - 'oldfieldname': u'based_on', - 'oldfieldtype': u'Select', - 'options': u'\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nTotal Claimed Amount\nNot Applicable', - 'reqd': 1, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'master_name', - 'fieldtype': u'Link', - 'label': u'Customer / Item Name', - 'oldfieldname': u'master_name', - 'oldfieldtype': u'Link', - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'system_role', - 'fieldtype': u'Link', - 'label': u'Applicable To (Role)', - 'oldfieldname': u'system_role', - 'oldfieldtype': u'Link', - 'options': u'Role' - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'system_user', - 'fieldtype': u'Link', - 'label': u'Applicable To (User)', - 'oldfieldname': u'system_user', - 'oldfieldtype': u'Link', - 'options': u'Profile' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'This will be used for setting rule in HR module', - 'doctype': u'DocField', - 'fieldname': u'to_emp', - 'fieldtype': u'Link', - 'label': u'Applicable To (Employee)', - 'oldfieldname': u'to_emp', - 'oldfieldtype': u'Link', - 'options': u'Employee', - 'search_index': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'This will be used for setting rule in HR module', - 'doctype': u'DocField', - 'fieldname': u'to_designation', - 'fieldtype': u'Link', - 'label': u'Applicable To (Designation)', - 'oldfieldname': u'to_designation', - 'oldfieldtype': u'Link', - 'options': u'Designation', - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'approving_role', - 'fieldtype': u'Link', - 'label': u'Approving Role', - 'oldfieldname': u'approving_role', - 'oldfieldtype': u'Link', - 'options': u'Role' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'approving_user', - 'fieldtype': u'Link', - 'label': u'Approving User', - 'oldfieldname': u'approving_user', - 'oldfieldtype': u'Link', - 'options': u'Profile' - }, - - # DocField - { - 'default': u'0.00', - 'doctype': u'DocField', - 'fieldname': u'value', - 'fieldtype': u'Currency', - 'label': u'Above Value', - 'oldfieldname': u'value', - 'oldfieldtype': u'Currency' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'trash_reason', - 'fieldtype': u'Small Text', - 'label': u'Trash Reason', - 'oldfieldname': u'trash_reason', - 'oldfieldtype': u'Small Text' - } + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-07-03 13:30:00", + "modified_by": "Administrator", + "modified": "2012-12-12 10:42:42" + }, + { + "autoname": "AR.####", + "name": "__common__", + "search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role", + "module": "Setup", + "doctype": "DocType", + "document_type": "Master" + }, + { + "name": "__common__", + "parent": "Authorization Rule", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "name": "__common__", + "parent": "Authorization Rule", + "read": 1, + "create": 1, + "doctype": "DocPerm", + "write": 1, + "cancel": 1, + "parenttype": "DocType", + "role": "System Manager", + "permlevel": 0, + "parentfield": "permissions" + }, + { + "name": "Authorization Rule", + "doctype": "DocType" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Company", + "oldfieldname": "company", + "fieldname": "company", + "fieldtype": "Link", + "search_index": 0, + "reqd": 0, + "options": "Company" + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Transaction", + "oldfieldname": "transaction", + "fieldname": "transaction", + "fieldtype": "Select", + "reqd": 1, + "options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nAppraisal" + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Based On", + "oldfieldname": "based_on", + "fieldname": "based_on", + "fieldtype": "Select", + "reqd": 1, + "options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Customer / Item Name", + "oldfieldname": "master_name", + "fieldname": "master_name", + "fieldtype": "Link", + "options": "[Select]" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Applicable To (Role)", + "oldfieldname": "system_role", + "fieldname": "system_role", + "fieldtype": "Link", + "options": "Role" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Applicable To (User)", + "oldfieldname": "system_user", + "fieldname": "system_user", + "fieldtype": "Link", + "options": "Profile" + }, + { + "description": "This will be used for setting rule in HR module", + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Applicable To (Employee)", + "oldfieldname": "to_emp", + "fieldname": "to_emp", + "fieldtype": "Link", + "search_index": 0, + "options": "Employee" + }, + { + "description": "This will be used for setting rule in HR module", + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Applicable To (Designation)", + "oldfieldname": "to_designation", + "fieldname": "to_designation", + "fieldtype": "Link", + "search_index": 0, + "options": "Designation" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Approving Role", + "oldfieldname": "approving_role", + "fieldname": "approving_role", + "fieldtype": "Link", + "options": "Role" + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Approving User", + "oldfieldname": "approving_user", + "fieldname": "approving_user", + "fieldtype": "Link", + "options": "Profile" + }, + { + "default": "0.00", + "oldfieldtype": "Currency", + "doctype": "DocField", + "label": "Above Value", + "oldfieldname": "value", + "fieldname": "value", + "fieldtype": "Currency" + }, + { + "oldfieldtype": "Small Text", + "doctype": "DocField", + "label": "Trash Reason", + "oldfieldname": "trash_reason", + "fieldname": "trash_reason", + "fieldtype": "Small Text" + }, + { + "doctype": "DocPerm" + }, + { + "doctype": "DocPerm" + } ] \ No newline at end of file From 34f89e4760feeb8a099eebbcc8214896ee12628d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 12 Dec 2012 13:13:13 +0530 Subject: [PATCH 02/20] Update selling/page/selling_home/selling_home.html --- selling/page/selling_home/selling_home.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selling/page/selling_home/selling_home.html b/selling/page/selling_home/selling_home.html index 54f2e386f9..3009cebe3b 100644 --- a/selling/page/selling_home/selling_home.html +++ b/selling/page/selling_home/selling_home.html @@ -14,8 +14,8 @@
Sales Order

Confirmed orders from Customers


-
Communication
-

Confirmed orders from Customers

+
Communication
+

All communication records

Customer
From 20b75e372f449214c447dce24a70e6476b2a11c3 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Dec 2012 14:33:02 +0530 Subject: [PATCH 03/20] added session expiry in global defaults --- .../global_defaults/global_defaults.py | 16 +- .../global_defaults/global_defaults.txt | 977 ++++++++---------- 2 files changed, 440 insertions(+), 553 deletions(-) diff --git a/setup/doctype/global_defaults/global_defaults.py b/setup/doctype/global_defaults/global_defaults.py index 13a42ed766..5aa2c9acfc 100644 --- a/setup/doctype/global_defaults/global_defaults.py +++ b/setup/doctype/global_defaults/global_defaults.py @@ -37,7 +37,8 @@ keydict = { 'currency_format':'default_currency_format', 'account_url':'account_url', 'allow_negative_stock' : 'allow_negative_stock', - 'maintain_same_rate' : 'maintain_same_rate' + 'maintain_same_rate' : 'maintain_same_rate', + 'session_expiry': 'session_expiry' } class DocType: @@ -47,6 +48,8 @@ class DocType: def on_update(self): """update defaults""" + self.validate_session_expiry() + for key in keydict: webnotes.conn.set_default(key, self.doc.fields.get(keydict[key], '')) @@ -60,6 +63,15 @@ class DocType: webnotes.conn.set_default('year_start_date', ysd.strftime('%Y-%m-%d')) webnotes.conn.set_default('year_end_date', \ get_last_day(get_first_day(ysd,0,11)).strftime('%Y-%m-%d')) - + + def validate_session_expiry(self): + if self.doc.session_expiry: + from datetime import datetime + try: + datetime.strptime(self.doc.session_expiry, "%H:%M") + except ValueError: + webnotes.msgprint("""Session Expiry must be in format hh:mm""", + raise_exception=1) + def get_defaults(self): return webnotes.conn.get_defaults() diff --git a/setup/doctype/global_defaults/global_defaults.txt b/setup/doctype/global_defaults/global_defaults.txt index 2a4c74cc43..e4b36a9abc 100644 --- a/setup/doctype/global_defaults/global_defaults.txt +++ b/setup/doctype/global_defaults/global_defaults.txt @@ -1,553 +1,428 @@ -# DocType, Global Defaults [ - - # These values are common in all dictionaries - { - u'creation': '2012-07-03 13:30:02', - u'docstatus': 0, - u'modified': '2012-10-26 16:42:29', - u'modified_by': u'Administrator', - u'owner': u'Administrator' - }, - - # These values are common for all DocType - { - '_last_update': u'1323855502', - 'allow_copy': 1, - 'allow_email': 1, - 'allow_print': 1, - 'colour': u'White:FFF', - u'doctype': u'DocType', - 'hide_toolbar': 0, - 'in_create': 1, - 'issingle': 1, - 'module': u'Setup', - u'name': u'__common__', - 'read_only': 1, - 'section_style': u'Tabbed', - 'server_code_error': u' ', - 'show_in_menu': 1, - 'version': 1 - }, - - # These values are common for all DocField - { - u'doctype': u'DocField', - u'name': u'__common__', - 'parent': u'Global Defaults', - 'parentfield': u'fields', - 'parenttype': u'DocType', - 'permlevel': 0 - }, - - # These values are common for all DocPerm - { - u'doctype': u'DocPerm', - u'name': u'__common__', - 'parent': u'Global Defaults', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'read': 1 - }, - - # DocType, Global Defaults - { - u'doctype': u'DocType', - u'name': u'Global Defaults' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'company', - 'fieldtype': u'Section Break', - 'label': u'Company' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_company', - 'fieldtype': u'Link', - 'label': u'Default Company', - 'options': u'Company', - 'reqd': 0 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'current_fiscal_year', - 'fieldtype': u'Link', - 'label': u'Current Fiscal Year', - 'options': u'Fiscal Year', - 'reqd': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'date_format', - 'fieldtype': u'Select', - 'label': u'Date Format', - 'options': u'yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break1', - 'fieldtype': u'Column Break', - 'width': u'50%' - }, - - # DocField - { - 'default': u'INR', - u'doctype': u'DocField', - 'fieldname': u'default_currency', - 'fieldtype': u'Select', - 'label': u'Default Currency', - 'options': u'link:Currency', - 'reqd': 1 - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_currency_format', - 'fieldtype': u'Select', - 'label': u'Default Currency Format', - 'options': u'Lacs\nMillions' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_currency_fraction', - 'fieldtype': u'Data', - 'label': u'Default Currency Fraction' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'stock', - 'fieldtype': u'Section Break', - 'label': u'Stock' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break2', - 'fieldtype': u'Column Break', - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_item_group', - 'fieldtype': u'Link', - 'label': u'Default Item Group', - 'options': u'Item Group' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'ighelp', - 'fieldtype': u'HTML', - 'label': u'IGHelp', - 'options': u'To manage Item Groups, click here' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_stock_uom', - 'fieldtype': u'Link', - 'label': u'Default Stock UOM', - 'options': u'UOM' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_valuation_method', - 'fieldtype': u'Select', - 'label': u'Default Valuation Method', - 'options': u'FIFO\nMoving Average' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Applicable only if valuation method is moving average', - u'doctype': u'DocField', - 'fieldname': u'allow_negative_stock', - 'fieldtype': u'Check', - 'label': u'Allow Negative Stock' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_warehouse_type', - 'fieldtype': u'Link', - 'label': u'Default Warehouse Type', - 'options': u'Warehouse Type' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'auto_indent', - 'fieldtype': u'Check', - 'label': u'Raise Purchase Request when stock reaches re-order level' - }, - - # DocField - { - 'default': u'1', - u'doctype': u'DocField', - 'fieldname': u'column_break3', - 'fieldtype': u'Column Break', - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'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

', - u'doctype': u'DocField', - 'fieldname': u'tolerance', - 'fieldtype': u'Currency', - 'label': u'Allowance Percent' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Stock level frozen up to this date, nobody can do / modify entry except authorized person', - u'doctype': u'DocField', - 'fieldname': u'stock_frozen_upto', - 'fieldtype': u'Date', - 'label': u'Stock Frozen Upto' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Users with this role are allowed to do / modify stock entry before frozen date', - u'doctype': u'DocField', - 'fieldname': u'stock_auth_role', - 'fieldtype': u'Link', - 'label': u'Authorized Role (Frozen Entry)', - 'options': u'Role' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'accounts', - 'fieldtype': u'Section Break', - 'label': u'Accounts' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Accounting entry frozen up to this date, nobody can do / modify entry except authorized person', - u'doctype': u'DocField', - 'fieldname': u'acc_frozen_upto', - 'fieldtype': u'Date', - 'label': u'Accounts Frozen Upto' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Users with this role are allowed to do / modify accounting entry before frozen date', - u'doctype': u'DocField', - 'fieldname': u'bde_auth_role', - 'fieldtype': u'Link', - 'label': u'Authourized Role (Frozen Entry)', - 'options': u'Role' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'credit_controller', - 'fieldtype': u'Link', - 'label': u'Credit Controller', - 'options': u'Role' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break4', - 'fieldtype': u'Column Break' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'account_info', - 'fieldtype': u'HTML', - 'label': u'Account Info', - 'options': u'
For more accounting defaults, Open Company
' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'selling', - 'fieldtype': u'Section Break', - 'label': u'Selling' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'Customer Name', - u'doctype': u'DocField', - 'fieldname': u'cust_master_name', - 'fieldtype': u'Select', - 'label': u'Customer Master created by ', - 'options': u'Customer Name\nNaming Series' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_customer_group', - 'fieldtype': u'Link', - 'label': u'Default Customer Group', - 'options': u'Customer Group' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'cghelp', - 'fieldtype': u'HTML', - 'label': u'CGHelp', - 'options': u'To manage Customer Groups, click here' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_territory', - 'fieldtype': u'Link', - 'label': u'Default Territory', - 'options': u'Territory' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'territoryhelp', - 'fieldtype': u'HTML', - 'label': u'TerritoryHelp', - 'options': u'To manage Territory, click here' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break5', - 'fieldtype': u'Column Break', - 'width': u'50%' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_price_list', - 'fieldtype': u'Link', - 'label': u'Default Price List', - 'options': u'Price List' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_price_list_currency', - 'fieldtype': u'Link', - 'label': u'Default Price List Currency', - 'options': u'Currency' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'No', - u'doctype': u'DocField', - 'fieldname': u'so_required', - 'fieldtype': u'Select', - 'label': u'Sales Order Required', - 'options': u'No\nYes' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'No', - u'doctype': u'DocField', - 'fieldname': u'dn_required', - 'fieldtype': u'Select', - 'label': u'Delivery Note Required', - 'options': u'No\nYes' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'buying', - 'fieldtype': u'Section Break', - 'label': u'Buying' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'default_supplier_type', - 'fieldtype': u'Link', - 'label': u'Default Supplier Type', - 'options': u'Supplier Type' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'Supplier Name', - u'doctype': u'DocField', - 'fieldname': u'supp_master_name', - 'fieldtype': u'Select', - 'label': u'Supplier Master created by ', - 'options': u'Supplier Name\nNaming Series' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'column_break6', - 'fieldtype': u'Column Break', - 'width': u'50%' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'No', - u'doctype': u'DocField', - 'fieldname': u'po_required', - 'fieldtype': u'Select', - 'label': u'Purchase Order Required', - 'options': u'No\nYes' - }, - - # DocField - { - 'colour': u'White:FFF', - 'default': u'No', - u'doctype': u'DocField', - 'fieldname': u'pr_required', - 'fieldtype': u'Select', - 'label': u'Purchase Receipt Required', - 'options': u'No\nYes' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'maintain_same_rate', - 'fieldtype': u'Check', - 'label': u'Maintain same rate throughout purchase cycle' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'hr', - 'fieldtype': u'Section Break', - 'label': u'HR', - 'options': u'
HR
' - }, - - # DocField - { - 'colour': u'White:FFF', - 'description': u'Employee record is created using selected field. ', - u'doctype': u'DocField', - 'fieldname': u'emp_created_by', - 'fieldtype': u'Select', - 'label': u'Employee Records to be created by ', - 'options': u'\nNaming Series\nEmployee Number' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'system', - 'fieldtype': u'Section Break', - 'label': u'System' - }, - - # DocField - { - u'doctype': u'DocField', - 'fieldname': u'sms_sender_name', - 'fieldtype': u'Data', - 'label': u'SMS Sender Name' - }, - - # DocPerm - { - 'amend': 0, - 'cancel': 0, - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager', - 'submit': 0, - 'write': 1 - }, - - # DocPerm - { - 'create': 1, - u'doctype': u'DocPerm', - 'permlevel': 0, - 'role': u'System Manager', - 'write': 1 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'All' - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 1, - 'role': u'System Manager', - 'write': 1 - }, - - # DocPerm - { - u'doctype': u'DocPerm', - 'permlevel': 2, - 'role': u'System Manager', - 'write': 1 - } + { + "owner": "Administrator", + "docstatus": 0, + "creation": "2012-10-26 16:49:40", + "modified_by": "Administrator", + "modified": "2012-12-12 14:13:31" + }, + { + "in_create": 1, + "allow_print": 1, + "module": "Setup", + "read_only": 1, + "allow_email": 1, + "issingle": 1, + "name": "__common__", + "doctype": "DocType", + "hide_toolbar": 0, + "allow_copy": 1 + }, + { + "name": "__common__", + "parent": "Global Defaults", + "doctype": "DocField", + "parenttype": "DocType", + "permlevel": 0, + "parentfield": "fields" + }, + { + "name": "__common__", + "parent": "Global Defaults", + "read": 1, + "doctype": "DocPerm", + "parenttype": "DocType", + "parentfield": "permissions" + }, + { + "name": "Global Defaults", + "doctype": "DocType" + }, + { + "doctype": "DocField", + "label": "General", + "fieldname": "general", + "fieldtype": "Section Break" + }, + { + "description": "Session Expiry in Hours e.g. 06:00", + "doctype": "DocField", + "label": "Session Expiry", + "fieldname": "session_expiry", + "fieldtype": "Data" + }, + { + "doctype": "DocField", + "label": "Company", + "fieldname": "company", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "label": "Default Company", + "fieldname": "default_company", + "fieldtype": "Link", + "reqd": 0, + "options": "Company" + }, + { + "doctype": "DocField", + "label": "Current Fiscal Year", + "fieldname": "current_fiscal_year", + "fieldtype": "Link", + "reqd": 1, + "options": "Fiscal Year" + }, + { + "doctype": "DocField", + "label": "Date Format", + "fieldname": "date_format", + "fieldtype": "Select", + "options": "yyyy-mm-dd\ndd-mm-yyyy\ndd/mm/yyyy\nmm/dd/yyyy\nmm-dd-yyyy" + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break1", + "fieldtype": "Column Break" + }, + { + "default": "INR", + "doctype": "DocField", + "label": "Default Currency", + "fieldname": "default_currency", + "fieldtype": "Select", + "reqd": 1, + "options": "link:Currency" + }, + { + "doctype": "DocField", + "label": "Default Currency Format", + "fieldname": "default_currency_format", + "fieldtype": "Select", + "options": "Lacs\nMillions" + }, + { + "doctype": "DocField", + "label": "Default Currency Fraction", + "fieldname": "default_currency_fraction", + "fieldtype": "Data" + }, + { + "doctype": "DocField", + "label": "Stock", + "fieldname": "stock", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break2", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "label": "Default Item Group", + "fieldname": "default_item_group", + "fieldtype": "Link", + "options": "Item Group" + }, + { + "doctype": "DocField", + "label": "IGHelp", + "fieldname": "ighelp", + "fieldtype": "HTML", + "options": "To manage Item Groups, click here" + }, + { + "doctype": "DocField", + "label": "Default Stock UOM", + "fieldname": "default_stock_uom", + "fieldtype": "Link", + "options": "UOM" + }, + { + "doctype": "DocField", + "label": "Default Valuation Method", + "fieldname": "default_valuation_method", + "fieldtype": "Select", + "options": "FIFO\nMoving Average" + }, + { + "description": "Applicable only if valuation method is moving average", + "doctype": "DocField", + "label": "Allow Negative Stock", + "fieldname": "allow_negative_stock", + "fieldtype": "Check" + }, + { + "doctype": "DocField", + "label": "Default Warehouse Type", + "fieldname": "default_warehouse_type", + "fieldtype": "Link", + "options": "Warehouse Type" + }, + { + "doctype": "DocField", + "label": "Raise Purchase Request when stock reaches re-order level", + "fieldname": "auto_indent", + "fieldtype": "Check" + }, + { + "default": "1", + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break3", + "fieldtype": "Column Break" + }, + { + "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", + "label": "Allowance Percent", + "fieldname": "tolerance", + "fieldtype": "Currency" + }, + { + "description": "Stock level frozen up to this date, nobody can do / modify entry except authorized person", + "doctype": "DocField", + "label": "Stock Frozen Upto", + "fieldname": "stock_frozen_upto", + "fieldtype": "Date" + }, + { + "description": "Users with this role are allowed to do / modify stock entry before frozen date", + "doctype": "DocField", + "label": "Authorized Role (Frozen Entry)", + "fieldname": "stock_auth_role", + "fieldtype": "Link", + "options": "Role" + }, + { + "doctype": "DocField", + "label": "Accounts", + "fieldname": "accounts", + "fieldtype": "Section Break" + }, + { + "description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person", + "doctype": "DocField", + "label": "Accounts Frozen Upto", + "fieldname": "acc_frozen_upto", + "fieldtype": "Date" + }, + { + "description": "Users with this role are allowed to do / modify accounting entry before frozen date", + "doctype": "DocField", + "label": "Authourized Role (Frozen Entry)", + "fieldname": "bde_auth_role", + "fieldtype": "Link", + "options": "Role" + }, + { + "doctype": "DocField", + "label": "Credit Controller", + "fieldname": "credit_controller", + "fieldtype": "Link", + "options": "Role" + }, + { + "doctype": "DocField", + "fieldname": "column_break4", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "label": "Account Info", + "fieldname": "account_info", + "fieldtype": "HTML", + "options": "
For more accounting defaults, Open Company
" + }, + { + "doctype": "DocField", + "label": "Selling", + "fieldname": "selling", + "fieldtype": "Section Break" + }, + { + "default": "Customer Name", + "doctype": "DocField", + "label": "Customer Master created by ", + "fieldname": "cust_master_name", + "fieldtype": "Select", + "options": "Customer Name\nNaming Series" + }, + { + "doctype": "DocField", + "label": "Default Customer Group", + "fieldname": "default_customer_group", + "fieldtype": "Link", + "options": "Customer Group" + }, + { + "doctype": "DocField", + "label": "CGHelp", + "fieldname": "cghelp", + "fieldtype": "HTML", + "options": "To manage Customer Groups, click here" + }, + { + "doctype": "DocField", + "label": "Default Territory", + "fieldname": "default_territory", + "fieldtype": "Link", + "options": "Territory" + }, + { + "doctype": "DocField", + "label": "TerritoryHelp", + "fieldname": "territoryhelp", + "fieldtype": "HTML", + "options": "To manage Territory, click here" + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break5", + "fieldtype": "Column Break" + }, + { + "doctype": "DocField", + "label": "Default Price List", + "fieldname": "default_price_list", + "fieldtype": "Link", + "options": "Price List" + }, + { + "doctype": "DocField", + "label": "Default Price List Currency", + "fieldname": "default_price_list_currency", + "fieldtype": "Link", + "options": "Currency" + }, + { + "default": "No", + "doctype": "DocField", + "label": "Sales Order Required", + "fieldname": "so_required", + "fieldtype": "Select", + "options": "No\nYes" + }, + { + "default": "No", + "doctype": "DocField", + "label": "Delivery Note Required", + "fieldname": "dn_required", + "fieldtype": "Select", + "options": "No\nYes" + }, + { + "doctype": "DocField", + "label": "Buying", + "fieldname": "buying", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "label": "Default Supplier Type", + "fieldname": "default_supplier_type", + "fieldtype": "Link", + "options": "Supplier Type" + }, + { + "default": "Supplier Name", + "doctype": "DocField", + "label": "Supplier Master created by ", + "fieldname": "supp_master_name", + "fieldtype": "Select", + "options": "Supplier Name\nNaming Series" + }, + { + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break6", + "fieldtype": "Column Break" + }, + { + "default": "No", + "doctype": "DocField", + "label": "Purchase Order Required", + "fieldname": "po_required", + "fieldtype": "Select", + "options": "No\nYes" + }, + { + "default": "No", + "doctype": "DocField", + "label": "Purchase Receipt Required", + "fieldname": "pr_required", + "fieldtype": "Select", + "options": "No\nYes" + }, + { + "doctype": "DocField", + "label": "Maintain same rate throughout purchase cycle", + "fieldname": "maintain_same_rate", + "fieldtype": "Check" + }, + { + "doctype": "DocField", + "label": "HR", + "fieldname": "hr", + "fieldtype": "Section Break", + "options": "
HR
" + }, + { + "description": "Employee record is created using selected field. ", + "doctype": "DocField", + "label": "Employee Records to be created by ", + "fieldname": "emp_created_by", + "fieldtype": "Select", + "options": "\nNaming Series\nEmployee Number" + }, + { + "doctype": "DocField", + "label": "System", + "fieldname": "system", + "fieldtype": "Section Break" + }, + { + "doctype": "DocField", + "label": "SMS Sender Name", + "fieldname": "sms_sender_name", + "fieldtype": "Data" + }, + { + "amend": 0, + "create": 1, + "doctype": "DocPerm", + "submit": 0, + "write": 1, + "role": "System Manager", + "cancel": 0, + "permlevel": 0 + }, + { + "create": 1, + "doctype": "DocPerm", + "write": 1, + "role": "System Manager", + "permlevel": 0 + }, + { + "doctype": "DocPerm", + "write": 1, + "role": "System Manager", + "permlevel": 1 + }, + { + "doctype": "DocPerm", + "role": "All", + "permlevel": 1 + }, + { + "doctype": "DocPerm", + "write": 1, + "role": "System Manager", + "permlevel": 2 + } ] \ No newline at end of file From 73ccac4ccb3cf1153218840d828250057191b9a4 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Dec 2012 14:42:17 +0530 Subject: [PATCH 04/20] moved recent to memcache --- patches/december_2012/move_recent_to_memcache.py | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 patches/december_2012/move_recent_to_memcache.py diff --git a/patches/december_2012/move_recent_to_memcache.py b/patches/december_2012/move_recent_to_memcache.py new file mode 100644 index 0000000000..ee94121977 --- /dev/null +++ b/patches/december_2012/move_recent_to_memcache.py @@ -0,0 +1,7 @@ +import webnotes, json + +def execute(): + for p in webnotes.conn.sql("""select name, recent_documents from + tabProfile where ifnull(recent_documents,'')!=''"""): + if not '~~~' in p[1]: + webnotes.cache().set_value("recent:" + p[0], json.loads(p[1])) \ No newline at end of file From 686022f777139021597b666647d519a284cafdda Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Dec 2012 15:25:51 +0530 Subject: [PATCH 05/20] fixes to recent patch and removed company_control, home_control, webforms, wip_monitor --- home/doctype/company_control/__init__.py | 1 - .../company_control/company_control.py | 100 ----- .../company_control/company_control.txt | 30 -- home/doctype/home_control/__init__.py | 1 - home/doctype/home_control/home_control.py | 365 ------------------ home/doctype/home_control/home_control.txt | 56 --- home/page/latest_updates/latest_updates.js | 1 + .../december_2012/move_recent_to_memcache.py | 4 +- setup/page/webforms/__init__.py | 1 - setup/page/webforms/webforms.html | 13 - setup/page/webforms/webforms.js | 42 -- setup/page/webforms/webforms.txt | 51 --- setup/page/webforms/webforms_static.html | 1 - startup/event_handlers.py | 12 +- utilities/page/wip_monitor/__init__.py | 1 - utilities/page/wip_monitor/wip_monitor.html | 2 - utilities/page/wip_monitor/wip_monitor.js | 104 ----- utilities/page/wip_monitor/wip_monitor.txt | 28 -- 18 files changed, 8 insertions(+), 805 deletions(-) delete mode 100644 home/doctype/company_control/__init__.py delete mode 100644 home/doctype/company_control/company_control.py delete mode 100644 home/doctype/company_control/company_control.txt delete mode 100644 home/doctype/home_control/__init__.py delete mode 100644 home/doctype/home_control/home_control.py delete mode 100644 home/doctype/home_control/home_control.txt delete mode 100644 setup/page/webforms/__init__.py delete mode 100644 setup/page/webforms/webforms.html delete mode 100644 setup/page/webforms/webforms.js delete mode 100644 setup/page/webforms/webforms.txt delete mode 100644 setup/page/webforms/webforms_static.html delete mode 100644 utilities/page/wip_monitor/__init__.py delete mode 100644 utilities/page/wip_monitor/wip_monitor.html delete mode 100644 utilities/page/wip_monitor/wip_monitor.js delete mode 100644 utilities/page/wip_monitor/wip_monitor.txt diff --git a/home/doctype/company_control/__init__.py b/home/doctype/company_control/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/home/doctype/company_control/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/home/doctype/company_control/company_control.py b/home/doctype/company_control/company_control.py deleted file mode 100644 index c18610b7e4..0000000000 --- a/home/doctype/company_control/company_control.py +++ /dev/null @@ -1,100 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes - -from webnotes.utils import cint, cstr -from webnotes.model import db_exists -from webnotes.model.doc import Document -from webnotes.model.wrapper import copy_doclist -from webnotes import session - -sql = webnotes.conn.sql - - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl - - # All roles of Role Master - def get_all_roles(self): - r_list=sql("select name from `tabRole` where name not in ('All','Guest','Administrator','Customer','Supplier') and docstatus != 2") - if r_list[0][0]: - r_list = [x[0] for x in r_list] - return r_list - - # Get all permissions for given role - def get_permission(self,role): - perm = sql("select distinct t1.`parent`, t1.`read`, t1.`write`, t1.`create`, t1.`submit`,t1.`cancel`,t1.`amend` from `tabDocPerm` t1, `tabDocType` t2 where t1.`role` ='%s' and t1.docstatus !=2 and ifnull(t1.permlevel, 0) = 0 and t1.`read` = 1 and t2.module != 'Recycle Bin' and t1.parent=t2.name " % role) - return perm or '' - - # Get roles for given user - def get_user_roles(self,usr): - r_list=sql("select role from `tabUserRole` where parent=%s and role not in ('All','Guest')",usr) - if r_list: - return [r[0] for r in r_list] - else: - return '' - - # Update roles of given user - def update_roles(self,arg): - arg = eval(arg) - sql("delete from `tabUserRole` where parenttype='Profile' and parent ='%s'" % (cstr(arg['usr']))) - role_list = arg['role_list'].split(',') - for r in role_list: - pr=Document('UserRole') - pr.parent = arg['usr'] - pr.parenttype = 'Profile' - pr.role = r - pr.parentfield = 'userroles' - pr.save(1) - - # Update Membership Type at Gateway - from webnotes.utils import cint - - webnotes.clear_cache(cstr(arg['usr'])) - - # Save profile - def save_profile(self,arg): - arg = eval(arg) - p = Document('Profile', session['user']) - for k in arg: - p.fields[k] = arg[k] - p.save() - - def get_login_url(self): - return session['data']['login_from'] - - def get_user_info(self): - - usr = sql("select count(name) from tabProfile where docstatus != 2 and name not in ('Guest','Administrator')") - usr = usr and usr[0][0] or 0 - - ol = sql("select count(distinct t1.name) from tabProfile t1, tabSessions t2 where t1.name = t2.user and t1.name not in('Guest','Administrator') and TIMESTAMPDIFF(HOUR,t2.lastupdate,NOW()) <= 1 and t1.docstatus != 2 and t1.enabled=1") - ol = ol and ol[0][0] or 0 - - ac = sql("select count(name) from tabProfile where enabled=1 and docstatus != 2 and name not in ('Guest', 'Administrator')") - ac = ac and ac[0][0] or 0 - - inac = sql("select count(name) from tabProfile where (enabled=0 or enabled is null or enabled = '') and docstatus != 2 and name not in ('Guest','Administrator')") - inac = inac and inac[0][0] or 0 - - return usr, ol, ac, inac - - def get_sm_count(self) : - return sql("select count(t1.parent) from tabUserRole t1, tabProfile t2 where t1.role='System Manager' and t1.parent = t2.name and t2.enabled=1")[0][0] or 0 diff --git a/home/doctype/company_control/company_control.txt b/home/doctype/company_control/company_control.txt deleted file mode 100644 index 90952d1eeb..0000000000 --- a/home/doctype/company_control/company_control.txt +++ /dev/null @@ -1,30 +0,0 @@ -# DocType, Company Control -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:35:52', - 'docstatus': 0, - 'modified': '2012-03-27 14:35:52', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'issingle': 1, - 'module': u'Home', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'version': 13 - }, - - # DocType, Company Control - { - 'doctype': 'DocType', - 'name': u'Company Control' - } -] \ No newline at end of file diff --git a/home/doctype/home_control/__init__.py b/home/doctype/home_control/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/home/doctype/home_control/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/home/doctype/home_control/home_control.py b/home/doctype/home_control/home_control.py deleted file mode 100644 index 75ab2222ce..0000000000 --- a/home/doctype/home_control/home_control.py +++ /dev/null @@ -1,365 +0,0 @@ -# ERPNext - web based ERP (http://erpnext.com) -# Copyright (C) 2012 Web Notes Technologies Pvt Ltd -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from __future__ import unicode_literals -import webnotes - -from webnotes.utils import add_days, cint, cstr, getdate, now, nowdate -from webnotes.model.doc import Document -from webnotes import session, msgprint - -sql = webnotes.conn.sql - -try: import json -except: import simplejson as json - - - -class DocType: - def __init__(self,d,dl): - self.doc, self.doclist = d,dl ---------------- -# ------------------------------------- Home page module details ----------------------------------------- - - def delete_cache(self): - com = sql("select abbr, name from tabCompany") - for d in com: - sql("update `tabCompany` set receivables_group = '%s' where (receivables_group = '%s' or receivables_group = '' or receivables_group is null) and name = '%s'" % ('Accounts Receivable - '+cstr(d[0]), 'Accounts Receivables - '+cstr(d[0]), d[1])) - sql("update `tabCompany` set payables_group = '%s' where (payables_group = '%s' or payables_group = '' or payables_group is null) and name = '%s'" % ('Accounts Payable - '+cstr(d[0]), 'Accounts Payables - '+cstr(d[0]), d[1])) - - def get_modules(self): - rl = webnotes.user.get_roles() - ml = sql("select distinct t1.name, t1.module_icon, t1.module_label, t1.module_desc, t1.module_page from `tabModule Def` t1, `tabModule Def Role` t2 where t2.role in ('%s') and t1.disabled !='Yes' and ifnull(t1.is_hidden, 'No') != 'Yes' and t1.name = t2.parent order by t1.module_seq asc" % "','".join(rl), as_dict=1) - webnotes.response['login_url'] = session['data'].get('login_from', '') - - return ml - - def get_module_details(self,m): - ret = {} - ret['il'] = sql('select doc_type, doc_name, display_name, icon, description, fields, click_function, idx from `tabModule Def Item` where parent=%s and ifnull(`hide`,0)=0 order by idx asc', m, as_dict=1) - ret['wl'] = sql('select widget_code from `tabModule Def` where name =%s', m)[0][0] or '' - ret['custom_reports'] = sql(''' - SELECT DISTINCT t1.criteria_name AS `display_name`, t1.description, t1.doc_type AS `doc_name`, 'Custom Reports' AS `doc_type` - FROM `tabSearch Criteria` t1, `tabDocPerm` t2 - WHERE t1.module = "%s" - AND IFNULL(t1.disabled,0) = 0 - AND (t1.doc_type=t2.parent OR t1.parent_doc_type = t2.parent) - AND t2.permlevel = 0 - AND t2.read=1 - AND t2.role IN ("%s") - AND ifnull(standard,"No")="No"''' % (m, '", "'.join(webnotes.user.get_roles())), as_dict=1) - - return ret - - # ---------------------------------------------------------------------------------------------------------------- - # ----------------------------------------------- Home page updates ---------------------------------------------- - - def get_events_list(self): - import webnotes, webnotes.utils - from webnotes.widgets.event import get_cal_events - - dl = get_cal_events(nowdate(), add_days(nowdate(), 7)) - el = [] - for d in dl: - #el.append([d.name, d.event_date, d.event_hour, d.event_name, d.description or '', d.ref_type or '', d.ref_name or '', d.owner]) - dict = { - 'name': d.name, - 'event_date': d.event_date, - 'event_hour': d.event_hour, - 'event_name': d.event_name, - 'description': d.description, - 'notes': d.notes, - 'event_type': d.event_type, - 'ref_type': d.ref_type, - 'ref_name': d.ref_name, - 'owner' : d.owner - } - - el.append(dict) - return el - - - def get_activity_list(self): - out = {} - import webnotes - rt = webnotes.user.can_read - - dt_list = [d[0] for d in sql("select distinct t2.name from tabDocField t1, tabDocType t2 where t1.fieldname='status' and t1.docstatus=0 and (t2.istable is null or t2.istable = 0) and t1.parent = t2.name")] - if not dt_list: - return out - - # get list of activity dt - for dt in dt_list: - if dt in rt: - out[dt] = {} - # get status list - sl = sql("select distinct status from `tab%s`" % dt) - - for s in sl: - if s[0]: - # get count - cnt = sql("select count(*) from `tab%s` where status = '%s' and modified > '%s'" % (dt, s[0], add_days(nowdate(), -7)))[0][0] - out[dt][s[0]] = cint(cnt) - return out - - def get_dt_help(self,dt): - return sql("select description from tabDocType where name=%s",dt)[0][0] or '' - - def get_wip_counts(self): - #dtl = ['Lead', 'Enquiries', 'Sales Order', 'Invoices', 'Purchase Request', 'Purchase Order', 'Bills', 'Tasks', 'Delivery Note', 'Maintenance'] - can_read_dt = ['Lead', 'Opportunity', 'Sales Order', 'Sales Invoice', 'Purchase Request', 'Purchase Order', 'Purchase Invoice', 'Delivery Note', 'Task', 'Serial No'] - dt = {} - for d in can_read_dt: - args = {} - - # if Lead - if d=='Lead': - args = {'To follow up':sql("select count(name) from tabLead where status!='Converted' and status!='Lead Lost' and status!='Not Interested'")} - - # if Opportunity - elif d=='Opportunity': - args['Quotations to be sent'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabOpportunity`t2 where t1.enq_no!=t2.name and t2.docstatus=1") - args['To follow up'] = sql("select count(distinct(t2.name)) from `tabQuotation`t1, `tabOpportunity`t2 where t1.enq_no=t2.name and t2.docstatus=1 and t1.docstatus=1") - - # if Sales Order - elif d=='Sales Order': - args['To be delivered'] = sql("select count(name) from `tabSales Order` where ifnull(per_delivered,0)<100 and delivery_date>now() and docstatus=1") - args['To be billed'] = sql("select count(name) from `tabSales Order` where ifnull(per_billed,0)<100 and docstatus=1") - args['Overdue'] = sql("select count(name) from `tabSales Order` where ifnull(per_delivered,0)<100 and delivery_datenow() and outstanding_amount!=0") - args['Overdue'] = sql("select count(name) from `tabSales Invoice` where docstatus=1 and due_date= CURDATE() and ifnull(amc_expiry_date, '0000-00-00') !='0000-00-00' and ifnull(maintenance_status, '') !='Under AMC'") - if chk_for_under_amc: - lst3 = [x3[0] for x3 in chk_for_under_amc] - self.update_serial_status(lst3, 'Under AMC') - - # chk to set serial no status as 'under warranty' - def set_for_under_warranty(self): - chk_for_under_wrnty = sql("select name from `tabSerial No` where ifnull(warranty_expiry_date, '2200-12-12') >= CURDATE() and ifnull(warranty_expiry_date, '0000-00-00') != '0000-00-00' and ifnull(amc_expiry_date, '0000-00-00') ='0000-00-00' and ifnull(maintenance_status, '') != 'Under Warranty'") - if chk_for_under_wrnty: - lst4 = [x4[0] for x4 in chk_for_under_wrnty] - self.update_serial_status(lst4, 'Under Warranty') - - # check maintenance status for all serial nos only for 1st login each day - def set_serial_no_status(self): - - chk_serial_no_update_date = webnotes.conn.get_global('maintenance_status_update_date') - - # check status only for 1st login each day.... if maintenance date already updated means it is checked - if getdate(chk_serial_no_update_date) != nowdate(): - # chk to set serial no status as 'Out of warranty' - self.set_for_out_of_warranty() - - # chk to set serial no status as 'Out of amc' - self.set_for_out_of_amc() - - # chk to set serial no status as 'under amc' - self.set_for_under_amc() - - # chk to set serial no status as 'under warranty' - self.set_for_under_warranty() - - #set maintenance_status_update_date - webnotes.conn.set_global('maintenance_status_update_date', nowdate()) - - # get user fullname - def get_user_fullname(self,usr): - return sql("select concat_ws(' ',first_name, last_name) from tabProfile where name=%s", usr)[0][0] or '' diff --git a/home/doctype/home_control/home_control.txt b/home/doctype/home_control/home_control.txt deleted file mode 100644 index 1d9098ed7f..0000000000 --- a/home/doctype/home_control/home_control.txt +++ /dev/null @@ -1,56 +0,0 @@ -# DocType, Home Control -[ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:35:53', - 'docstatus': 0, - 'modified': '2012-03-27 14:35:53', - 'modified_by': u'Administrator', - 'owner': u'Administrator' - }, - - # These values are common for all DocType - { - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'issingle': 1, - 'module': u'Home', - 'name': '__common__', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'show_in_menu': 0, - 'version': 6 - }, - - # These values are common for all DocPerm - { - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Home Control', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'write': 1 - }, - - # DocType, Home Control - { - 'doctype': 'DocType', - 'name': u'Home Control' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'System Manager' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'Guest' - } -] \ No newline at end of file diff --git a/home/page/latest_updates/latest_updates.js b/home/page/latest_updates/latest_updates.js index 04d366adbc..f41c547962 100644 --- a/home/page/latest_updates/latest_updates.js +++ b/home/page/latest_updates/latest_updates.js @@ -1,6 +1,7 @@ erpnext.updates = [ ["12th December 2012", [ "Attachments: Attachments can be set as URLs or File Uploads. This will help if people want to share documents from Google Docs, Dropbox and other such services (esp for the Product listings on websites).", + "Global Defaults: Session Expiry can now be set in Global Defaults.", ]], ["6th December 2012", [ "Rename: Cost Center, Item Group, Customer Group, Supplier Type, Territory, Sales Person can now be renamed.", diff --git a/patches/december_2012/move_recent_to_memcache.py b/patches/december_2012/move_recent_to_memcache.py index ee94121977..c92c487fd0 100644 --- a/patches/december_2012/move_recent_to_memcache.py +++ b/patches/december_2012/move_recent_to_memcache.py @@ -1,7 +1,9 @@ +from __future__ import unicode_literals + import webnotes, json def execute(): for p in webnotes.conn.sql("""select name, recent_documents from tabProfile where ifnull(recent_documents,'')!=''"""): - if not '~~~' in p[1]: + if not '~~~' in p[1] and p[1][0]=='[': webnotes.cache().set_value("recent:" + p[0], json.loads(p[1])) \ No newline at end of file diff --git a/setup/page/webforms/__init__.py b/setup/page/webforms/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/setup/page/webforms/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/setup/page/webforms/webforms.html b/setup/page/webforms/webforms.html deleted file mode 100644 index e1717dce2a..0000000000 --- a/setup/page/webforms/webforms.html +++ /dev/null @@ -1,13 +0,0 @@ -
-
-

Note : Copy and paste code provided below in your website wherever you want to show the form to capture details

-

 

-

Lead

-
-

Customer Issue

-
-

Job Application

-
-

Ticket

-
-
\ No newline at end of file diff --git a/setup/page/webforms/webforms.js b/setup/page/webforms/webforms.js deleted file mode 100644 index 85caadf46f..0000000000 --- a/setup/page/webforms/webforms.js +++ /dev/null @@ -1,42 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pscript.onload_Webforms = function(){ - - $c_obj('Home Control','get_acc_id','', function(r,rt) { - if(r.message) { - var acc_id = r.message; - var parent = $i('webform_div'); - new PageHeader(parent,'Web Forms',''); - - var lead_dv = $a('lead_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'90%'}); - var cust_issue_dv = $a('cust_issue_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'}); - var job_dv = $a('job_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'}); - var ticket_dv = $a('ticket_div','div', '', {border:'1px solid #AAA', padding:'8px', width:'95%'}); - - // url - if(window.location.href.indexOf('?')!=-1) - var url = window.location.href.split('?')[0]; - else - var url = window.location.href.split('#')[0]; - - lead_dv.innerHTML = '<iframe src ="'+url+'?ac_name='+acc_id+'&embed=Lead" width ="400" height="800" frameborder="0"></iframe>'; - cust_issue_dv.innerHTML = '<iframe src ="'+url+'?ac_name='+acc_id+'&embed=Customer Issue" width ="400" height="500" frameborder="0"></iframe>'; - job_dv.innerHTML = '<iframe src ="'+url+'?ac_name='+acc_id+'&embed=Job Application" width ="400" height="800" frameborder="0""></iframe>'; - ticket_dv.innerHTML = '<iframe src ="'+url+'?ac_name='+acc_id+'&embed=Support Ticket" width ="400" height="800" frameborder="0""></iframe>'; - } - }); -} diff --git a/setup/page/webforms/webforms.txt b/setup/page/webforms/webforms.txt deleted file mode 100644 index 8e2970bf41..0000000000 --- a/setup/page/webforms/webforms.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Page, Webforms -[ - - # These values are common in all dictionaries - { - 'creation': '2010-10-14 11:15:59', - 'docstatus': 0, - 'modified': '2011-01-04 13:19:54', - 'modified_by': 'Administrator', - 'owner': 'ashwini@webnotestech.com' - }, - - # These values are common for all Page - { - 'doctype': 'Page', - 'module': 'Setup', - 'name': '__common__', - 'page_name': 'Webforms', - 'show_in_menu': 1, - 'standard': 'Yes' - }, - - # These values are common for all Page Role - { - 'doctype': 'Page Role', - 'name': '__common__', - 'parent': 'Webforms', - 'parentfield': 'roles', - 'parenttype': 'Page' - }, - - # Page, Webforms - { - 'doctype': 'Page', - 'name': 'Webforms' - }, - - # Page Role - { - 'doctype': 'Page Role', - 'idx': 1, - 'role': 'Administrator' - }, - - # Page Role - { - 'doctype': 'Page Role', - 'idx': 2, - 'role': 'System Manager' - } -] \ No newline at end of file diff --git a/setup/page/webforms/webforms_static.html b/setup/page/webforms/webforms_static.html deleted file mode 100644 index 3488a17b82..0000000000 --- a/setup/page/webforms/webforms_static.html +++ /dev/null @@ -1 +0,0 @@ -webforms \ No newline at end of file diff --git a/startup/event_handlers.py b/startup/event_handlers.py index 9cd1af94d4..f526c73fc0 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -25,14 +25,10 @@ def on_login_post_session(login_manager): update login_from and delete parallel sessions """ # Clear previous sessions i.e. logout previous log-in attempts - exception_list = ['demo@erpnext.com', 'Administrator', 'Guest'] - if webnotes.session['user'] not in exception_list: - sid_list = webnotes.conn.sql(""" - DELETE FROM `tabSessions` - WHERE - user=%s AND - sid!=%s""", \ - (webnotes.session['user'], webnotes.session['sid']), as_list=1) + allow_multiple_sessions = ['demo@erpnext.com', 'Administrator', 'Guest'] + if webnotes.session['user'] not in allow_multiple_sessions: + from webnotes.sessions import clear_sessions + clear_sessions(webnotes.session.user, keep_current=True) # check if account is expired check_if_expired() diff --git a/utilities/page/wip_monitor/__init__.py b/utilities/page/wip_monitor/__init__.py deleted file mode 100644 index baffc48825..0000000000 --- a/utilities/page/wip_monitor/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from __future__ import unicode_literals diff --git a/utilities/page/wip_monitor/wip_monitor.html b/utilities/page/wip_monitor/wip_monitor.html deleted file mode 100644 index b7eb59e261..0000000000 --- a/utilities/page/wip_monitor/wip_monitor.html +++ /dev/null @@ -1,2 +0,0 @@ -
-
\ No newline at end of file diff --git a/utilities/page/wip_monitor/wip_monitor.js b/utilities/page/wip_monitor/wip_monitor.js deleted file mode 100644 index fcfc96face..0000000000 --- a/utilities/page/wip_monitor/wip_monitor.js +++ /dev/null @@ -1,104 +0,0 @@ -// ERPNext - web based ERP (http://erpnext.com) -// Copyright (C) 2012 Web Notes Technologies Pvt Ltd -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -pscript['onload_WIP Monitor'] = function(){ - wip = new WIP_Monitor(); - - var h = new PageHeader('wip_head','Work in Progress Monitor','A quick glance at your work in progress and pipeline'); - h.add_button('Refresh', function(){ wip = new WIP_Monitor();}, 1, 'ui-icon-refresh'); - -} - -// Work In Progress Monitor -// ========================================================================================================================================================= -WIP_Monitor = function(){ - var me = this; - this.row_index = 0; - $c_obj('Home Control','get_wip_counts','',function(r,rt){ - me.make_wip_dashboard(r.message); - }); -} - - -// Make wip dashboard -// ------------------ -WIP_Monitor.prototype.make_wip_dashboard = function(wip_dict) -{ - var me = this; - // list of doctypes which user can read - var can_read_dt = ['Lead', 'Opportunity', 'Sales Order', 'Sales Invoice', 'Purchase Request', 'Purchase Order', 'Purchase Invoice', 'Delivery Note', 'Task', 'Serial No']; - - $i('wip_body').innerHTML = ''; - this.tab = make_table('wip_body',1,0,'100%',[],{padding:'4px'}); - - for(var k=0; k Date: Wed, 12 Dec 2012 15:58:46 +0530 Subject: [PATCH 06/20] webnotes.user.roles deprecated to webnotes.user.get_roles() --- accounts/page/accounts_browser/accounts_browser.py | 5 +++-- startup/event_handlers.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/accounts/page/accounts_browser/accounts_browser.py b/accounts/page/accounts_browser/accounts_browser.py index 8b24394f36..7c8116c77c 100644 --- a/accounts/page/accounts_browser/accounts_browser.py +++ b/accounts/page/accounts_browser/accounts_browser.py @@ -10,9 +10,10 @@ def get_companies(): # check if match permission exists res = webnotes.conn.sql("""select role, `match` from `tabDocPerm` where parent='Account' and permlevel=0 and `read`=1""", as_dict=1) - + + roles = webnotes.user.get_roles() match = any((r["match"] for r in res - if r["role"] in webnotes.user.roles and r["match"]=="company")) + if r["role"] in roles and r["match"]=="company")) # if match == company is specified and companies are specified in user defaults if match and webnotes.user.get_defaults().get("company"): diff --git a/startup/event_handlers.py b/startup/event_handlers.py index f526c73fc0..4808298368 100644 --- a/startup/event_handlers.py +++ b/startup/event_handlers.py @@ -115,7 +115,7 @@ def check_if_expired(): from webnotes.utils import formatdate msg = """Oops! Your subscription expired on %s.
""" % formatdate(conf.expires_on) - if 'System Manager' in webnotes.user.roles: + if 'System Manager' in webnotes.user.get_roles(): msg += """Just drop in a mail at support@erpnext.com and we will guide you to get your account re-activated.""" else: From 9e12af4b7c13acfc8d1bb042f37ef9aa79cb6a2f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Dec 2012 16:13:29 +0530 Subject: [PATCH 07/20] updated recipients email in communication --- selling/doctype/lead/lead.js | 2 +- selling/doctype/opportunity/opportunity.js | 2 +- selling/doctype/quotation/quotation.js | 2 +- startup/startup.py | 2 +- utilities/doctype/contact/contact.js | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index 0c5bf87cdb..e4b3a7db58 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -71,7 +71,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { list: wn.model.get("Communication", {"lead": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, - email: doc.email_id + recipients: doc.email_id }) } diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 2bb41b21b5..2b530ff4a5 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -51,7 +51,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) { list: wn.model.get("Communication", {"opportunity": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, - email: doc.contact_email + recipients: doc.contact_email }); } diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 1b03781b5b..7199132d61 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -107,7 +107,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { list: wn.model.get("Communication", {"quotation": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, - email: doc.contact_email + recipients: doc.contact_email }); } } diff --git a/startup/startup.py b/startup/startup.py index 828239ee15..15ea491b13 100644 --- a/startup/startup.py +++ b/startup/startup.py @@ -48,7 +48,7 @@ def get_things_todo(): incomplete_todos = webnotes.conn.sql("""\ SELECT COUNT(*) FROM `tabToDo` WHERE IFNULL(checked, 0) = 0 - AND owner = %s""", webnotes.session.get('user')) + AND (owner = %s or assigned_by=%s)""", (webnotes.session.user, webnotes.session.user)) return incomplete_todos and cint(incomplete_todos[0][0]) or 0 def get_todays_events(): diff --git a/utilities/doctype/contact/contact.js b/utilities/doctype/contact/contact.js index 3876ca20ae..97fd8a6a10 100644 --- a/utilities/doctype/contact/contact.js +++ b/utilities/doctype/contact/contact.js @@ -27,7 +27,7 @@ cur_frm.cscript.refresh = function() { list: wn.model.get("Communication", {"contact": doc.name}), parent: cur_frm.fields_dict.communication_html.wrapper, doc: doc, - email: doc.email_id + recipients: doc.email_id }) } From 06cbd3427f4f378c28ccb2e927c0a743499aba14 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 12 Dec 2012 16:26:39 +0530 Subject: [PATCH 08/20] dynamic query for root in sales browser, validation for tree structure document --- accounts/doctype/account/account.js | 3 +-- accounts/doctype/cost_center/cost_center.js | 2 +- selling/page/sales_browser/sales_browser.js | 22 +++++++-------- selling/page/sales_browser/sales_browser.py | 5 +++- .../doctype/customer_group/customer_group.js | 2 +- .../doctype/customer_group/customer_group.py | 27 ++++++++++++------- setup/doctype/item_group/item_group.js | 15 +++++++++++ setup/doctype/sales_person/sales_person.js | 2 +- setup/doctype/sales_person/sales_person.py | 3 +++ setup/doctype/territory/territory.js | 8 +----- setup/doctype/territory/territory.py | 3 +++ 11 files changed, 59 insertions(+), 33 deletions(-) diff --git a/accounts/doctype/account/account.js b/accounts/doctype/account/account.js index d35d6ceb85..14e35d3094 100644 --- a/accounts/doctype/account/account.js +++ b/accounts/doctype/account/account.js @@ -39,8 +39,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { 'is_pl_account', 'company'], false); // read-only for root accounts - root_acc = doc.parent ? false : true; - if(in_list(root_acc, doc.account_name)) { + if(!doc.parent_account) { cur_frm.perm = [[1,0,0], [1,0,0]]; cur_frm.set_intro("This is a root account and cannot be edited."); } else { diff --git a/accounts/doctype/cost_center/cost_center.js b/accounts/doctype/cost_center/cost_center.js index 08253837e7..3dde661b92 100644 --- a/accounts/doctype/cost_center/cost_center.js +++ b/accounts/doctype/cost_center/cost_center.js @@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.toggle_enable(['group_or_ledger', 'company_name'], doc.__islocal); if(!doc.__islocal && doc.group_or_ledger=='Group') { - intro_txt += '

Note: This is Cost Center is a Group, \ + intro_txt += '

Note: This Cost Center is a Group, \ Accounting Entries are not allowed against groups.

'; } diff --git a/selling/page/sales_browser/sales_browser.js b/selling/page/sales_browser/sales_browser.js index ce495dbebd..be43e67783 100644 --- a/selling/page/sales_browser/sales_browser.js +++ b/selling/page/sales_browser/sales_browser.js @@ -24,7 +24,14 @@ pscript['onload_Sales Browser'] = function(wrapper){ wrapper.make_tree = function() { var ctype = wn.get_route()[1] || 'Territory'; - erpnext.sales_chart = new erpnext.SalesChart(ctype, wrapper); + wn.call({ + method: 'selling.page.sales_browser.sales_browser.get_children', + args: {ctype: ctype}, + callback: function(r) { + var root = r.message[0]["value"]; + erpnext.sales_chart = new erpnext.SalesChart(ctype, root, wrapper); + } + }); } wrapper.make_tree(); @@ -42,20 +49,13 @@ pscript['onshow_Sales Browser'] = function(wrapper){ }; erpnext.SalesChart = Class.extend({ - init: function(ctype, wrapper) { - var root_nodes = { - 'Territory': 'All Territories', - 'Item Group': 'All Item Groups', - 'Customer Group': 'All Customer Groups', - 'Sales Person': 'All Sales Persons' - } - + init: function(ctype, root, wrapper) { $(wrapper).find('.tree-area').empty(); var me = this; me.ctype = ctype; this.tree = new wn.ui.Tree({ parent: $(wrapper).find('.tree-area'), - label: root_nodes[ctype], + label: root, args: {ctype: ctype}, method: 'selling.page.sales_browser.sales_browser.get_children', click: function(link) { @@ -72,7 +72,7 @@ erpnext.SalesChart = Class.extend({ } }); this.tree.rootnode.$a - .data('node-data', {value: root_nodes[ctype], expandable:1}) + .data('node-data', {value: root, expandable:1}) .click(); }, make_link_toolbar: function(link) { diff --git a/selling/page/sales_browser/sales_browser.py b/selling/page/sales_browser/sales_browser.py index 92c75e0fcd..49a05ff578 100644 --- a/selling/page/sales_browser/sales_browser.py +++ b/selling/page/sales_browser/sales_browser.py @@ -1,11 +1,14 @@ from __future__ import unicode_literals import webnotes + @webnotes.whitelist() def get_children(): ctype = webnotes.form_dict.get('ctype') webnotes.form_dict['parent_field'] = 'parent_' + ctype.lower().replace(' ', '_') - + if not webnotes.form_dict.get('parent'): + webnotes.form_dict['parent'] = '' + return webnotes.conn.sql("""select name as value, if(is_group='Yes', 1, 0) as expandable from `tab%(ctype)s` diff --git a/setup/doctype/customer_group/customer_group.js b/setup/doctype/customer_group/customer_group.js index 2b24c11efe..af0c6f0b44 100644 --- a/setup/doctype/customer_group/customer_group.js +++ b/setup/doctype/customer_group/customer_group.js @@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly = function(doc) { // read-only for root customer group - if(doc.name==='All Customer Groups') { + if(!doc.parent_customer_group) { cur_frm.perm = [[1,0,0], [1,0,0]]; cur_frm.set_intro("This is a root customer group and cannot be edited."); } else { diff --git a/setup/doctype/customer_group/customer_group.py b/setup/doctype/customer_group/customer_group.py index 0f68521198..cf126b8c07 100644 --- a/setup/doctype/customer_group/customer_group.py +++ b/setup/doctype/customer_group/customer_group.py @@ -31,20 +31,29 @@ class DocType(DocTypeNestedSet): self.nsm_parent_field = 'parent_customer_group'; def validate(self): - if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", (self.doc.customer_group_name)): + if sql("select name from `tabCustomer Group` where name = %s and docstatus = 2", + (self.doc.customer_group_name)): msgprint("""Another %s record is trashed. - To untrash please go to Setup & click on Trash."""%(self.doc.customer_group_name), raise_exception = 1) - self.validate_root_details("All Customer Groups", "parent_customer_group") + To untrash please go to Setup -> Recycle Bin.""" % + (self.doc.customer_group_name), raise_exception = 1) + + super(DocType, self).validate() + def on_trash(self): - cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", self.doc.name) + cust = sql("select name from `tabCustomer` where ifnull(customer_group, '') = %s", + self.doc.name) cust = [d[0] for d in cust] if cust: - msgprint("""Customer Group: %s can not be trashed/deleted because it is used in customer: %s. - To trash/delete this, remove/change customer group in customer master""" % (self.doc.name, cust or ''), raise_exception=1) + msgprint("""Customer Group: %s can not be trashed/deleted \ + because it is used in customer: %s. + To trash/delete this, remove/change customer group in customer master""" % + (self.doc.name, cust or ''), raise_exception=1) - if sql("select name from `tabCustomer Group` where parent_customer_group = %s and docstatus != 2", self.doc.name): - msgprint("Child customer group exists for this customer group. You can not trash/cancel/delete this customer group.", raise_exception=1) + if sql("select name from `tabCustomer Group` where parent_customer_group = %s \ + and docstatus != 2", self.doc.name): + msgprint("Child customer group exists for this customer group. \ + You can not trash/cancel/delete this customer group.", raise_exception=1) # rebuild tree - super(DocType, self).on_trash() + super(DocType, self).on_trash() \ No newline at end of file diff --git a/setup/doctype/item_group/item_group.js b/setup/doctype/item_group/item_group.js index 3869eec00b..db894fa9d6 100644 --- a/setup/doctype/item_group/item_group.js +++ b/setup/doctype/item_group/item_group.js @@ -14,6 +14,21 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . + +cur_frm.cscript.refresh = function(doc, cdt, cdn) { + cur_frm.cscript.set_root_readonly(doc); +} + +cur_frm.cscript.set_root_readonly = function(doc) { + // read-only for root item group + if(!doc.parent_item_group) { + cur_frm.perm = [[1,0,0], [1,0,0]]; + cur_frm.set_intro("This is a root item group and cannot be edited."); + } else { + cur_frm.set_intro(null); + } +} + //get query select item group cur_frm.fields_dict['parent_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` = "Yes" AND `tabItem Group`.`docstatus`!= 2 AND `tabItem Group`.`name` !="'+doc.item_group_name+'" AND `tabItem Group`.%(key)s LIKE "%s" ORDER BY `tabItem Group`.`name` ASC LIMIT 50'; diff --git a/setup/doctype/sales_person/sales_person.js b/setup/doctype/sales_person/sales_person.js index ba1a339ad2..c52948803f 100644 --- a/setup/doctype/sales_person/sales_person.js +++ b/setup/doctype/sales_person/sales_person.js @@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly = function(doc) { // read-only for root - if(doc.name==='All Sales Persons') { + if(!doc.parent_sales_person) { cur_frm.perm = [[1,0,0], [1,0,0]]; cur_frm.set_intro("This is a root sales person and cannot be edited."); } else { diff --git a/setup/doctype/sales_person/sales_person.py b/setup/doctype/sales_person/sales_person.py index 41d5042945..943e724c9b 100644 --- a/setup/doctype/sales_person/sales_person.py +++ b/setup/doctype/sales_person/sales_person.py @@ -33,3 +33,6 @@ class DocType(DocTypeNestedSet): if not flt(d.target_qty) and not flt(d.target_amount): webnotes.msgprint("Either target qty or target amount is mandatory.") raise Exception + + super(DocType, self).validate() + \ No newline at end of file diff --git a/setup/doctype/territory/territory.js b/setup/doctype/territory/territory.js index a04bea384f..2932006013 100644 --- a/setup/doctype/territory/territory.js +++ b/setup/doctype/territory/territory.js @@ -20,7 +20,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) { cur_frm.cscript.set_root_readonly = function(doc) { // read-only for root territory - if(doc.name==='All Territories') { + if(!doc.parent_territory) { cur_frm.perm = [[1,0,0], [1,0,0]]; cur_frm.set_intro("This is a root territory and cannot be edited."); } else { @@ -28,12 +28,6 @@ cur_frm.cscript.set_root_readonly = function(doc) { } } - -cur_frm.cscript.onload = function(){ - -} - - //get query select territory cur_frm.fields_dict['parent_territory'].get_query = function(doc,cdt,cdn) { return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "Yes" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.`name` !="'+doc.territory_name+'" AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50'; diff --git a/setup/doctype/territory/territory.py b/setup/doctype/territory/territory.py index 59c0b3a5d4..4b6468e663 100644 --- a/setup/doctype/territory/territory.py +++ b/setup/doctype/territory/territory.py @@ -33,3 +33,6 @@ class DocType(DocTypeNestedSet): if not flt(d.target_qty) and not flt(d.target_amount): msgprint("Either target qty or target amount is mandatory.") raise Exception + + super(DocType, self).validate() + \ No newline at end of file From 4b8f90c5b475caf0116848bcda7d141c6fff4339 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 12 Dec 2012 16:28:21 +0530 Subject: [PATCH 09/20] permission, user_default fix --- setup/page/permission_engine/permission_engine.html | 2 ++ stock/doctype/purchase_receipt/purchase_receipt.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/setup/page/permission_engine/permission_engine.html b/setup/page/permission_engine/permission_engine.html index 7831447a6a..8d989586c3 100644 --- a/setup/page/permission_engine/permission_engine.html +++ b/setup/page/permission_engine/permission_engine.html @@ -5,4 +5,6 @@ One of the Roles has Submit permission. You will have to Cancel and then Amend a submitted Document for making changes.
+
+
Note: A document is not accessible to a user if Permission at level 0 is not given.
diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index d26636e253..9ed587b37f 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -150,7 +150,7 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) cur_frm.cscript.received_qty = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; ret = { - 'qty' : 0, + 'qty' : d.qty ? d.qty : d.received_qty, 'stock_qty': 0, 'rejected_qty' : 0 } From 561be839c55e1e8874cae339e0674c683185f086 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 12 Dec 2012 16:35:31 +0530 Subject: [PATCH 10/20] voucher import tool message --- accounts/page/voucher_import_tool/voucher_import_tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accounts/page/voucher_import_tool/voucher_import_tool.py b/accounts/page/voucher_import_tool/voucher_import_tool.py index ab81801c53..0d3a7f70cd 100644 --- a/accounts/page/voucher_import_tool/voucher_import_tool.py +++ b/accounts/page/voucher_import_tool/voucher_import_tool.py @@ -230,7 +230,7 @@ def get_data(rows, company_abbr): accounts = [c for c in rows[i+1] if c.endswith(" - " + company_abbr)] if accounts and (len(columns) != rows[i+1].index(accounts[0])): - raise Exception, """A non-account column cannot be after an account \ - column. Please rectify it in the file and try again.""" + raise Exception, """All account columns should be after standard columns and \ + on the right. Please rectify it in the file and try again.""" return data, start_row_idx \ No newline at end of file From d8e5dcc6f8ab0c5160579bfbdc79944ce064f089 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 12 Dec 2012 16:52:23 +0530 Subject: [PATCH 11/20] accepted qty = received qty, if not accepted qty --- stock/doctype/purchase_receipt/purchase_receipt.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stock/doctype/purchase_receipt/purchase_receipt.js b/stock/doctype/purchase_receipt/purchase_receipt.js index 9ed587b37f..a15573fa80 100644 --- a/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/stock/doctype/purchase_receipt/purchase_receipt.js @@ -150,9 +150,10 @@ cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) cur_frm.cscript.received_qty = function(doc, cdt, cdn) { var d = locals[cdt][cdn]; ret = { - 'qty' : d.qty ? d.qty : d.received_qty, + 'qty' : (flt(d.qty) && flt(d.qty) < flt(d.received_qty)) + ? flt(d.qty) : flt(d.received_qty), 'stock_qty': 0, - 'rejected_qty' : 0 + 'rejected_qty' : 0, } set_multiple('Purchase Receipt Item', cdn, ret, 'purchase_receipt_details'); cur_frm.cscript.calc_amount(doc, 2); From 291449b6fbe01013699e89cdb757ab66a98b7f8b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 13 Dec 2012 12:53:21 +0530 Subject: [PATCH 12/20] refactored javascript models --- .../budget_distribution.js | 2 +- .../journal_voucher/journal_voucher.js | 6 ++-- .../purchase_invoice/purchase_invoice.js | 6 ++-- .../doctype/sales_invoice/sales_invoice.js | 12 ++++---- .../purchase_common/purchase_common.js | 4 +-- .../doctype/purchase_order/purchase_order.js | 12 ++++---- .../purchase_request/purchase_request.js | 12 ++++---- buying/doctype/supplier/supplier.js | 2 +- .../supplier_quotation/supplier_quotation.js | 4 +-- home/page/activity/activity.js | 2 +- hr/doctype/employee/employee.js | 2 +- .../leave_control_panel.js | 2 +- hr/doctype/salary_manager/salary_manager.js | 10 +++---- .../salary_structure/salary_structure.js | 4 +-- .../production_order/production_order.js | 2 +- public/js/gantt_task.js | 2 +- public/js/modules.js | 4 +-- selling/doctype/customer/customer.js | 4 +-- selling/doctype/lead/lead.js | 12 ++++---- selling/doctype/opportunity/opportunity.js | 4 +-- selling/doctype/quotation/quotation.js | 4 +-- selling/doctype/sales_common/sales_common.js | 4 +-- selling/doctype/sales_order/sales_order.js | 28 +++++++++---------- .../contact_control/contact_control.js | 2 +- setup/doctype/sales_partner/sales_partner.js | 2 +- setup/doctype/workflow_rule/workflow_rule.js | 6 ++-- stock/doctype/delivery_note/delivery_note.js | 14 +++++----- .../purchase_receipt/purchase_receipt.js | 8 +++--- .../sales_and_purchase_return_tool.js | 10 +++---- .../doctype/customer_issue/customer_issue.js | 4 +-- .../maintenance_schedule.js | 2 +- .../doctype/support_ticket/support_ticket.js | 6 ---- utilities/page/calendar/calendar.js | 15 +++++----- 33 files changed, 104 insertions(+), 109 deletions(-) diff --git a/accounts/doctype/budget_distribution/budget_distribution.js b/accounts/doctype/budget_distribution/budget_distribution.js index c8bfe11525..5abd525999 100644 --- a/accounts/doctype/budget_distribution/budget_distribution.js +++ b/accounts/doctype/budget_distribution/budget_distribution.js @@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ } $c('runserverobj',args={'method' : 'get_months', 'docs' : - compress_doclist(make_doclist(doc.doctype, doc.name))},callback1); + wn.model.compress(make_doclist(doc.doctype, doc.name))},callback1); } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 784a134e5b..8c60838376 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -33,14 +33,14 @@ cur_frm.cscript.load_defaults = function(doc, cdt, cdn) { if(!cur_frm.doc.__islocal || !cur_frm.doc.company) { return; } doc = locals[doc.doctype][doc.name]; - var fields_to_refresh = LocalDB.set_default_values(doc); + var fields_to_refresh = wn.model.set_default_values(doc); if(fields_to_refresh) { refresh_many(fields_to_refresh); } fields_to_refresh = null; var children = getchildren('Journal Voucher Detail', doc.name, 'entries'); if(!children) { return; } for(var i=0; i\ Create a new Task').click(function() { wn.model.with_doctype('Task', function() { - var new_name = LocalDB.create('Task'); + var new_name = wn.model.make_new_doc_and_get_name('Task'); if(project) locals.Task[new_name].project = project; wn.set_route('Form', 'Task', new_name); diff --git a/public/js/modules.js b/public/js/modules.js index 9fa7f30cb1..7dc8038589 100644 --- a/public/js/modules.js +++ b/public/js/modules.js @@ -111,7 +111,7 @@ erpnext.module_page.hide_links = function(wrapper) { $(wrapper).find('[href*="List/"]').each(function() { var href = $(this).attr('href'); var dt = href.split('/')[1]; - if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { + if(wn.boot.profile.all_read.indexOf(dt)==-1) { replace_link(this); } }); @@ -128,7 +128,7 @@ erpnext.module_page.hide_links = function(wrapper) { $(wrapper).find('[href*="Form/"]').each(function() { var href = $(this).attr('href'); var dt = href.split('/')[1]; - if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { + if(wn.boot.profile.all_read.indexOf(dt)==-1) { replace_link(this); } }); diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js index d20b0c927d..845f543467 100644 --- a/selling/doctype/customer/customer.js +++ b/selling/doctype/customer/customer.js @@ -35,7 +35,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) { doc = locals[doc.doctype][doc.name]; if(!(doc.__islocal && doc.lead_name)) { return; } - var fields_to_refresh = LocalDB.set_default_values(doc); + var fields_to_refresh = wn.model.set_default_values(doc); if(fields_to_refresh) { refresh_many(fields_to_refresh); } } @@ -89,7 +89,7 @@ cur_frm.cscript.make_contact = function() { parent: cur_frm.fields_dict['contact_html'].wrapper, page_length: 2, custom_new_doc: function(doctype) { - var contact = LocalDB.create('Contact'); + var contact = wn.model.make_new_doc_and_get_name('Contact'); contact = locals['Contact'][contact]; contact.customer = cur_frm.doc.name; contact.customer_name = cur_frm.doc.customer_name; diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index e4b3a7db58..9dd64de25d 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -83,15 +83,15 @@ cur_frm.cscript.status = function(doc, cdt, cdn){ cur_frm.cscript['Create Customer'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, + $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is already converted to customer"); } else{ - n = createLocal("Customer"); + n = wn.model.make_new_doc_and_get_name("Customer"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Customer"][n]]), + 'docs':wn.model.compress([locals["Customer"][n]]), 'from_doctype':'Lead', 'to_doctype':'Customer', 'from_docname':doc.name, @@ -110,15 +110,15 @@ cur_frm.cscript['Create Customer'] = function(){ // =============================================================== cur_frm.cscript['Create Opportunity'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, + $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer"); } else{ - n = createLocal("Opportunity"); + n = wn.model.make_new_doc_and_get_name("Opportunity"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Opportunity"][n]]), + 'docs':wn.model.compress([locals["Opportunity"][n]]), 'from_doctype':'Lead', 'to_doctype':'Opportunity', 'from_docname':doc.name, diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 2b530ff4a5..70924835d8 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -156,9 +156,9 @@ cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = f // Create New Quotation cur_frm.cscript['Create Quotation'] = function(){ - n = createLocal("Quotation"); + n = wn.model.make_new_doc_and_get_name("Quotation"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Quotation"][n]]), + 'docs':wn.model.compress([locals["Quotation"][n]]), 'from_doctype':'Opportunity', 'to_doctype':'Quotation', 'from_docname':cur_frm.docname, diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 7199132d61..40e15186e7 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -180,9 +180,9 @@ cur_frm.cscript['Make Sales Order'] = function() { var doc = cur_frm.doc; if (doc.docstatus == 1) { - var n = createLocal("Sales Order"); + var n = wn.model.make_new_doc_and_get_name("Sales Order"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Sales Order"][n]]), + 'docs':wn.model.compress([locals["Sales Order"][n]]), 'from_doctype':'Quotation', 'to_doctype':'Sales Order', 'from_docname':doc.name, diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index c5eed98f71..de56a6c113 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -46,14 +46,14 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) { if(!cur_frm.doc.__islocal) { return; } doc = locals[doc.doctype][doc.name]; - var fields_to_refresh = LocalDB.set_default_values(doc); + var fields_to_refresh = wn.model.set_default_values(doc); if(fields_to_refresh) { refresh_many(fields_to_refresh); } fields_to_refresh = null; var children = getchildren(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname); if(!children) { return; } for(var i=0; i Date: Thu, 13 Dec 2012 14:24:15 +0530 Subject: [PATCH 13/20] doctype, attendance, sandbox fix --- hr/doctype/attendance/attendance.txt | 425 ++++++++++++--------------- 1 file changed, 187 insertions(+), 238 deletions(-) diff --git a/hr/doctype/attendance/attendance.txt b/hr/doctype/attendance/attendance.txt index 85ebb04280..2ef65aced6 100644 --- a/hr/doctype/attendance/attendance.txt +++ b/hr/doctype/attendance/attendance.txt @@ -1,240 +1,189 @@ -# DocType, Attendance [ - - # These values are common in all dictionaries - { - 'creation': '2012-03-27 14:35:53', - 'docstatus': 0, - 'modified': '2012-03-27 14:45:46', - 'modified_by': u'Administrator', - 'owner': u'ashwini@webnotestech.com' - }, - - # These values are common for all DocType - { - '_last_update': u'1317365120', - 'colour': u'White:FFF', - 'doctype': 'DocType', - 'document_type': u'Master', - 'is_submittable': 1, - 'module': u'HR', - 'name': '__common__', - 'search_fields': u'employee, employee_name, att_date, status', - 'section_style': u'Simple', - 'server_code_error': u' ', - 'show_in_menu': 0, - 'version': 75 - }, - - # These values are common for all DocField - { - 'doctype': u'DocField', - 'name': '__common__', - 'parent': u'Attendance', - 'parentfield': u'fields', - 'parenttype': u'DocType' - }, - - # These values are common for all DocPerm - { - 'amend': 0, - 'cancel': 1, - 'create': 1, - 'doctype': u'DocPerm', - 'name': '__common__', - 'parent': u'Attendance', - 'parentfield': u'permissions', - 'parenttype': u'DocType', - 'permlevel': 0, - 'read': 1, - 'submit': 1, - 'write': 1 - }, - - # DocType, Attendance - { - 'doctype': 'DocType', - 'name': u'Attendance' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'System Manager' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'HR User' - }, - - # DocPerm - { - 'doctype': u'DocPerm', - 'role': u'HR Manager' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'attendance_details', - 'fieldtype': u'Section Break', - 'label': u'Attendance Details', - 'oldfieldtype': u'Section Break', - 'options': u'Simple', - 'permlevel': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'naming_series', - 'fieldtype': u'Select', - 'label': u'Naming Series', - 'no_copy': 1, - 'oldfieldname': u'naming_series', - 'oldfieldtype': u'Select', - 'options': u'ATT', - 'permlevel': 0, - 'reqd': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'employee', - 'fieldtype': u'Link', - 'in_filter': 1, - 'label': u'Employee', - 'oldfieldname': u'employee', - 'oldfieldtype': u'Link', - 'options': u'Employee', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 1, - 'trigger': u'Client' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'employee_name', - 'fieldtype': u'Data', - 'label': u'Employee Name', - 'oldfieldname': u'employee_name', - 'oldfieldtype': u'Data', - 'permlevel': 0 - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'status', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Status', - 'no_copy': 1, - 'oldfieldname': u'status', - 'oldfieldtype': u'Select', - 'options': u'\nPresent\nAbsent\nHalf Day', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 1 - }, - - # DocField - { - 'colour': u'White:FFF', - 'doctype': u'DocField', - 'fieldname': u'leave_type', - 'fieldtype': u'Link', - 'hidden': 1, - 'label': u'Leave Type', - 'oldfieldname': u'leave_type', - 'oldfieldtype': u'Link', - 'options': u'Leave Type', - 'permlevel': 0, - 'print_hide': 1, - 'report_hide': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'column_break0', - 'fieldtype': u'Column Break', - 'oldfieldtype': u'Column Break', - 'permlevel': 0, - 'width': u'50%' - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'att_date', - 'fieldtype': u'Date', - 'in_filter': 1, - 'label': u'Attendance Date', - 'oldfieldname': u'att_date', - 'oldfieldtype': u'Date', - 'permlevel': 0, - 'reqd': 1, - 'search_index': 0 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'fiscal_year', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Fiscal Year', - 'oldfieldname': u'fiscal_year', - 'oldfieldtype': u'Select', - 'options': u'link:Fiscal Year', - 'permlevel': 0, - 'reqd': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'company', - 'fieldtype': u'Select', - 'in_filter': 1, - 'label': u'Company', - 'oldfieldname': u'company', - 'oldfieldtype': u'Link', - 'options': u'link:Company', - 'permlevel': 0, - 'reqd': 1 - }, - - # DocField - { - 'depends_on': u'eval:doc.amended_from', - 'description': u'The date at which current entry is corrected in the system.', - 'doctype': u'DocField', - 'fieldname': u'amendment_date', - 'fieldtype': u'Date', - 'label': u'Amendment Date', - 'no_copy': 1, - 'permlevel': 0, - 'print_hide': 1 - }, - - # DocField - { - 'doctype': u'DocField', - 'fieldname': u'amended_from', - 'fieldtype': u'Link', - 'label': u'Amended From', - 'no_copy': 1, - 'options': u'Sales Invoice', - 'permlevel': 1, - 'print_hide': 1 - } + { + "owner": "ashwini@webnotestech.com", + "docstatus": 0, + "creation": "2012-07-03 13:30:41", + "modified_by": "Administrator", + "modified": "2012-12-13 14:23:24" + }, + { + "is_submittable": 1, + "autoname": "naming_series:", + "name": "__common__", + "search_fields": "employee, employee_name, att_date, status", + "module": "HR", + "doctype": "DocType", + "document_type": "Master" + }, + { + "name": "__common__", + "parent": "Attendance", + "doctype": "DocField", + "parenttype": "DocType", + "parentfield": "fields" + }, + { + "name": "__common__", + "parent": "Attendance", + "read": 1, + "create": 1, + "submit": 1, + "doctype": "DocPerm", + "write": 1, + "parenttype": "DocType", + "cancel": 1, + "permlevel": 0, + "parentfield": "permissions" + }, + { + "name": "Attendance", + "doctype": "DocType" + }, + { + "oldfieldtype": "Section Break", + "doctype": "DocField", + "label": "Attendance Details", + "options": "Simple", + "fieldname": "attendance_details", + "fieldtype": "Section Break", + "permlevel": 0 + }, + { + "no_copy": 1, + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Naming Series", + "oldfieldname": "naming_series", + "options": "ATT", + "fieldname": "naming_series", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0 + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Employee", + "oldfieldname": "employee", + "options": "Employee", + "fieldname": "employee", + "fieldtype": "Link", + "search_index": 1, + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Data", + "doctype": "DocField", + "label": "Employee Name", + "oldfieldname": "employee_name", + "fieldname": "employee_name", + "fieldtype": "Data", + "permlevel": 0 + }, + { + "no_copy": 1, + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Status", + "oldfieldname": "status", + "permlevel": 0, + "fieldname": "status", + "fieldtype": "Select", + "search_index": 1, + "reqd": 1, + "options": "\nPresent\nAbsent\nHalf Day", + "in_filter": 1 + }, + { + "print_hide": 1, + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Leave Type", + "oldfieldname": "leave_type", + "options": "Leave Type", + "fieldname": "leave_type", + "fieldtype": "Link", + "hidden": 1, + "permlevel": 0, + "report_hide": 1 + }, + { + "oldfieldtype": "Column Break", + "doctype": "DocField", + "width": "50%", + "fieldname": "column_break0", + "fieldtype": "Column Break", + "permlevel": 0 + }, + { + "oldfieldtype": "Date", + "doctype": "DocField", + "label": "Attendance Date", + "oldfieldname": "att_date", + "fieldname": "att_date", + "fieldtype": "Date", + "search_index": 0, + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Select", + "doctype": "DocField", + "label": "Fiscal Year", + "oldfieldname": "fiscal_year", + "options": "\n2012\n2013", + "fieldname": "fiscal_year", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "oldfieldtype": "Link", + "doctype": "DocField", + "label": "Company", + "oldfieldname": "company", + "options": "\nAlpha\nBeta\nDemo Company", + "fieldname": "company", + "fieldtype": "Select", + "reqd": 1, + "permlevel": 0, + "in_filter": 1 + }, + { + "print_hide": 1, + "description": "The date at which current entry is corrected in the system.", + "no_copy": 1, + "depends_on": "eval:doc.amended_from", + "doctype": "DocField", + "label": "Amendment Date", + "fieldname": "amendment_date", + "fieldtype": "Date", + "permlevel": 0 + }, + { + "print_hide": 1, + "no_copy": 1, + "doctype": "DocField", + "label": "Amended From", + "options": "Attendance", + "fieldname": "amended_from", + "fieldtype": "Link", + "permlevel": 1 + }, + { + "role": "HR User", + "doctype": "DocPerm" + }, + { + "role": "HR Manager", + "doctype": "DocPerm" + }, + { + "role": "System Manager", + "doctype": "DocPerm" + } ] \ No newline at end of file From 221f03be01b9098c3d0f4ce5b731eada648c95c4 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Dec 2012 15:04:18 +0530 Subject: [PATCH 14/20] minor fixes --- selling/doctype/opportunity/opportunity.js | 1 + selling/doctype/quotation/quotation.js | 1 + setup/doctype/contact_control/contact_control.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 70924835d8..cfc546c956 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -207,6 +207,7 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){ if(r.message == 'true'){ $i('update_enquiry_dialog_response').innerHTML = 'Done'; e_lost_dialog.hide(); + cur_frm.refresh(); } } if(arg) { diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 40e15186e7..1b0a7748a9 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -250,6 +250,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){ if(r.message == 'true'){ $i('update_quotation_dialog_response').innerHTML = 'Done'; qtn_lost_dialog.hide(); + cur_frm.refresh(); } } if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back); diff --git a/setup/doctype/contact_control/contact_control.js b/setup/doctype/contact_control/contact_control.js index fe3c041caa..fd08062a0e 100755 --- a/setup/doctype/contact_control/contact_control.js +++ b/setup/doctype/contact_control/contact_control.js @@ -156,7 +156,7 @@ cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) { $wrapper.append(repl("\

%(fullname)s%(primary)s

\
\ - %(description)s\ +

%(description)s

\

delete this %(doctype)s

\
", data)); From 22c3f63edd20d81d10a0e166c2e275763ae24f3b Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 13 Dec 2012 15:09:42 +0530 Subject: [PATCH 15/20] small fixes: sms, quotation messages etc --- .../doctype/sales_invoice/sales_invoice.py | 22 +++++++++++-------- selling/doctype/sales_order/sales_order.js | 2 +- selling/doctype/sales_order/sales_order.py | 15 ++++++------- utilities/doctype/sms_control/sms_control.js | 2 -- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index b728475831..a146e932ef 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -174,16 +174,20 @@ class DocType(TransactionBase): def get_customer_account(self): """Get Account Head to which amount needs to be Debited based on Customer""" if not self.doc.company: - msgprint("Please select company first and re-select the customer after doing so", raise_exception=1) + msgprint("Please select company first and re-select the customer after doing so", + raise_exception=1) + if self.doc.customer: + acc_head = webnotes.conn.sql("""select name from `tabAccount` + where (name = %s or (master_name = %s and master_type = 'customer')) + and docstatus != 2""", + (cstr(self.doc.customer) + " - " + self.get_company_abbr(), self.doc.customer)) - acc_head = webnotes.conn.sql("""select name from `tabAccount` - where (name = %s or (master_name = %s and master_type = 'customer')) and docstatus != 2""", - (cstr(self.doc.customer) + " - " + self.get_company_abbr(),self.doc.customer)) - - if acc_head and acc_head[0][0]: - return acc_head[0][0] - else: - msgprint("%s does not have an Account Head in %s. You must first create it from the Customer Master" % (self.doc.customer, self.doc.company)) + if acc_head and acc_head[0][0]: + return acc_head[0][0] + else: + msgprint("%s does not have an Account Head in %s. \ + You must first create it from the Customer Master" % + (self.doc.customer, self.doc.company)) def get_debit_to(self): acc_head = self.get_customer_account() diff --git a/selling/doctype/sales_order/sales_order.js b/selling/doctype/sales_order/sales_order.js index f232a37fe5..17c8d097b3 100644 --- a/selling/doctype/sales_order/sales_order.js +++ b/selling/doctype/sales_order/sales_order.js @@ -147,7 +147,7 @@ cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) { cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) { var callback = function(r,rt){ var doc = locals[cur_frm.doctype][cur_frm.docname]; - if(r.message){ + if(!r.exc){ doc.quotation_no = r.message; if(doc.quotation_no) { unhide_field(['quotation_date', 'customer_address', 'contact_person', 'territory', 'customer_group']); diff --git a/selling/doctype/sales_order/sales_order.py b/selling/doctype/sales_order/sales_order.py index 0a73cacd40..9d23565d87 100644 --- a/selling/doctype/sales_order/sales_order.py +++ b/selling/doctype/sales_order/sales_order.py @@ -194,11 +194,11 @@ class DocType(TransactionBase): # Validations of Details Table # ----------------------------- def validate_for_items(self): - check_list,flag = [],0 + check_list, flag = [], 0 chk_dupl_itm = [] # Sales Order Items Validations for d in getlist(self.doclist, 'sales_order_details'): - if cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname): + if self.doc.quotation_no and cstr(self.doc.quotation_no) == cstr(d.prevdoc_docname): flag = 1 if d.prevdoc_docname: if self.doc.quotation_date and getdate(self.doc.quotation_date) > getdate(self.doc.transaction_date): @@ -229,14 +229,13 @@ class DocType(TransactionBase): # used for production plan d.transaction_date = self.doc.transaction_date - - # gets total projected qty of item in warehouse selected (this case arises when warehouse is selected b4 item) - tot_avail_qty = sql("select projected_qty from `tabBin` where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse)) + + tot_avail_qty = sql("select projected_qty from `tabBin` \ + where item_code = '%s' and warehouse = '%s'" % (d.item_code,d.reserved_warehouse)) d.projected_qty = tot_avail_qty and flt(tot_avail_qty[0][0]) or 0 - if flag == 0: - msgprint("There are no items of the quotation selected.") - raise Exception + if getlist(self.doclist, 'sales_order_details') and self.doc.quotation_no and flag == 0: + msgprint("There are no items of the quotation selected", raise_exception=1) # validate sales/ maintenance quotation against order type #------------------------------------------------------------------ diff --git a/utilities/doctype/sms_control/sms_control.js b/utilities/doctype/sms_control/sms_control.js index 9cc152fe06..4af96b3619 100644 --- a/utilities/doctype/sms_control/sms_control.js +++ b/utilities/doctype/sms_control/sms_control.js @@ -31,7 +31,6 @@ function SMSManager() { this.show = function(contact, key, value, mobile_nos, message) { this.message = message; if (mobile_nos) { - me.number = mobile_nos; me.show_dialog(); } else if (contact){ @@ -59,7 +58,6 @@ function SMSManager() { {fieldname:'send', fieldtype:'Button', label:'Send'} ] }) - d.make(); d.fields_dict.send.input.onclick = function() { var btn = d.fields_dict.send.input; var v = me.dialog.get_values(); From 62b5c7fc1fbad7b700f4ae940b9e1630bde56285 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Dec 2012 15:14:58 +0530 Subject: [PATCH 16/20] fix in task_list --- projects/doctype/task/task_list.js | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/doctype/task/task_list.js b/projects/doctype/task/task_list.js index 724505cae4..536168631f 100644 --- a/projects/doctype/task/task_list.js +++ b/projects/doctype/task/task_list.js @@ -5,7 +5,6 @@ wn.doclistviews['Task'] = wn.views.ListView.extend({ this.fields = this.fields.concat([ '`tabTask`.subject', '`tabTask`.project', - '`tabTask`.modified', '`tabTask`.status', '`tabTask`.opening_date', '`tabTask`.priority', From 8a4ceb98c2f2cde832be407a58c1d1f1025f3302 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 13 Dec 2012 15:24:33 +0530 Subject: [PATCH 17/20] remove hyphen from file_list --- patches/december_2012/file_list_rename.py | 10 ++++++++++ patches/patch_list.py | 4 ++++ 2 files changed, 14 insertions(+) create mode 100644 patches/december_2012/file_list_rename.py diff --git a/patches/december_2012/file_list_rename.py b/patches/december_2012/file_list_rename.py new file mode 100644 index 0000000000..52657ac2d6 --- /dev/null +++ b/patches/december_2012/file_list_rename.py @@ -0,0 +1,10 @@ +import webnotes + +def execute(): + for dt in webnotes.conn.sql("""select distinct parent from tabDocField + where fieldname='file_list'"""): + try: + webnotes.conn.sql("""update `tab%s` set file_list = + replace(file_list, "-", "")""" % dt[0]) + except Exception, e: + if e.args[0]!=1146: raise e \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 0b079b8db8..645f18ce4d 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -733,4 +733,8 @@ patch_list = [ 'patch_module': 'patches.december_2012', 'patch_file': 'fix_default_print_format', }, + { + 'patch_module': 'patches.december_2012', + 'patch_file': 'file_list_rename', + }, ] \ No newline at end of file From 9db3b6dc71947d0d65878b2a5f2531f93db75828 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 13 Dec 2012 18:36:49 +0530 Subject: [PATCH 18/20] replace createlocal --- patches/december_2012/replace_createlocal.py | 4 ++++ patches/patch_list.py | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 patches/december_2012/replace_createlocal.py diff --git a/patches/december_2012/replace_createlocal.py b/patches/december_2012/replace_createlocal.py new file mode 100644 index 0000000000..b37ba6bf17 --- /dev/null +++ b/patches/december_2012/replace_createlocal.py @@ -0,0 +1,4 @@ +def execute(): + import webnotes + webnotes.conn.sql("""update `tabCustom Script` + set script = replace(script, 'createLocal', 'wn.model.make_new_doc_and_get_name')""") \ No newline at end of file diff --git a/patches/patch_list.py b/patches/patch_list.py index 0b079b8db8..9e46f91bc0 100644 --- a/patches/patch_list.py +++ b/patches/patch_list.py @@ -733,4 +733,8 @@ patch_list = [ 'patch_module': 'patches.december_2012', 'patch_file': 'fix_default_print_format', }, + { + 'patch_module': 'patches.december_2012', + 'patch_file': 'replace_createlocal', + }, ] \ No newline at end of file From 94850557c279d57c75c08672131313eb10d8f619 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Dec 2012 18:53:31 +0530 Subject: [PATCH 19/20] fix in support ticket attachment --- support/doctype/support_ticket/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/doctype/support_ticket/__init__.py b/support/doctype/support_ticket/__init__.py index b477b96450..a53c76b939 100644 --- a/support/doctype/support_ticket/__init__.py +++ b/support/doctype/support_ticket/__init__.py @@ -135,7 +135,7 @@ class SupportMailbox(POP3Mailbox): from webnotes.utils.file_manager import save_file, add_file_list for attachment in attachment_list: fid = save_file(attachment['filename'], attachment['content'], 'Support') - status = add_file_list('Support Ticket', doc.name, attachment['filename'], fid) + status = add_file_list('Support Ticket', doc.name, fid, fid) if not status: doc.description = doc.description \ + "\nCould not attach: " + cstr(attachment['filename']) From 72d2a627f5c2fd510b64f25d0a607e009e7fad55 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Thu, 13 Dec 2012 19:35:32 +0530 Subject: [PATCH 20/20] replace createLocal in Client script only --- patches/december_2012/replace_createlocal.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patches/december_2012/replace_createlocal.py b/patches/december_2012/replace_createlocal.py index b37ba6bf17..c6f4bae4ae 100644 --- a/patches/december_2012/replace_createlocal.py +++ b/patches/december_2012/replace_createlocal.py @@ -1,4 +1,5 @@ def execute(): import webnotes webnotes.conn.sql("""update `tabCustom Script` - set script = replace(script, 'createLocal', 'wn.model.make_new_doc_and_get_name')""") \ No newline at end of file + set script = replace(script, 'createLocal', 'wn.model.make_new_doc_and_get_name') + where script_type='Client'""") \ No newline at end of file