merged with master

This commit is contained in:
Nabin Hait
2012-12-14 10:43:56 +05:30
67 changed files with 447 additions and 401 deletions

View File

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

View File

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

View File

@@ -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 <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
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)
def validate(self):
self.check_duplicate_entry()
self.validate_rule()
self.validate_master_name()
if not self.doc.value: self.doc.value = 0.0

View File

@@ -2,23 +2,17 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-03-27 14:36:18",
"creation": "2012-07-03 13:30:00",
"modified_by": "Administrator",
"modified": "2012-03-27 14:36:18"
"modified": "2012-12-12 10:42:42"
},
{
"section_style": "Simple",
"autoname": "AR.####",
"name": "__common__",
"search_fields": "transaction,based_on,system_user,system_role,approving_user,approving_role",
"module": "Setup",
"doctype": "DocType",
"allow_trash": 1,
"document_type": "Master",
"autoname": "AR.####",
"name": "__common__",
"colour": "White:FFF",
"_last_update": "1308741898",
"server_code_error": " ",
"version": 58
"document_type": "Master"
},
{
"name": "__common__",
@@ -46,19 +40,13 @@
"doctype": "DocType"
},
{
"doctype": "DocPerm"
},
{
"doctype": "DocPerm"
},
{
"search_index": 0,
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Company",
"oldfieldname": "company",
"fieldname": "company",
"fieldtype": "Link",
"oldfieldtype": "Link",
"search_index": 0,
"reqd": 0,
"options": "Company"
},
@@ -70,27 +58,26 @@
"fieldname": "transaction",
"fieldtype": "Select",
"reqd": 1,
"options": "\nDelivery Note\nPurchase Invoice\nPurchase Order\nPurchase Receipt\nQuotation\nSales Invoice\nSales Order\nStock Entry\nExpense Claim\nAppraisal"
"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",
"trigger": "Client",
"fieldname": "based_on",
"fieldtype": "Select",
"reqd": 1,
"options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nTotal Claimed Amount\nNot Applicable"
"options": "\nGrand Total\nAverage Discount\nCustomerwise Discount\nItemwise Discount\nNot Applicable"
},
{
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Customer / Item Name",
"oldfieldname": "master_name",
"trigger": "Client",
"fieldname": "master_name",
"fieldtype": "Link"
"fieldtype": "Link",
"options": "[Select]"
},
{
"oldfieldtype": "Link",
@@ -103,7 +90,6 @@
},
{
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Applicable To (User)",
"oldfieldname": "system_user",
@@ -113,26 +99,24 @@
},
{
"description": "This will be used for setting rule in HR module",
"search_index": 0,
"colour": "White:FFF",
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Applicable To (Employee)",
"oldfieldname": "to_emp",
"fieldname": "to_emp",
"fieldtype": "Link",
"oldfieldtype": "Link",
"search_index": 0,
"options": "Employee"
},
{
"description": "This will be used for setting rule in HR module",
"search_index": 0,
"colour": "White:FFF",
"oldfieldtype": "Link",
"doctype": "DocField",
"label": "Applicable To (Designation)",
"oldfieldname": "to_designation",
"fieldname": "to_designation",
"fieldtype": "Link",
"oldfieldtype": "Link",
"search_index": 0,
"options": "Designation"
},
{
@@ -169,5 +153,11 @@
"oldfieldname": "trash_reason",
"fieldname": "trash_reason",
"fieldtype": "Small Text"
},
{
"doctype": "DocPerm"
},
{
"doctype": "DocPerm"
}
]

View File

@@ -55,7 +55,7 @@ cur_frm.cscript.make_history_list = function(parent,doc){
// get sates on country trigger
// -----------------------------
cur_frm.cscript.get_states=function(doc,dt,dn){
$c('runserverobj', args={'method':'check_state', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
$c('runserverobj', args={'method':'check_state', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
function(r,rt){
if(r.message) {
set_field_options('state', r.message);
@@ -156,7 +156,7 @@ cur_frm.cscript.render_row_in_wrapper = function(wrapper, data, doctype) {
$wrapper.append(repl("\
<h4><a class='link_type'>%(fullname)s</a>%(primary)s</h4>\
<div class='description'>\
%(description)s\
<p>%(description)s</p>\
<p><a class='delete link_type'>delete this %(doctype)s</a></p>\
</div>", data));

View File

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

View File

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

View File

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

View File

@@ -2,25 +2,19 @@
{
"owner": "Administrator",
"docstatus": 0,
"creation": "2012-07-03 13:30:02",
"creation": "2012-10-26 16:49:40",
"modified_by": "Administrator",
"modified": "2012-10-26 16:42:29"
"modified": "2012-12-12 14:13:31"
},
{
"section_style": "Tabbed",
"in_create": 1,
"allow_print": 1,
"module": "Setup",
"doctype": "DocType",
"server_code_error": " ",
"read_only": 1,
"allow_email": 1,
"issingle": 1,
"name": "__common__",
"colour": "White:FFF",
"_last_update": "1323855502",
"show_in_menu": 1,
"version": 1,
"doctype": "DocType",
"hide_toolbar": 0,
"allow_copy": 1
},
@@ -46,9 +40,22 @@
},
{
"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",
"label": "Company"
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
@@ -74,10 +81,10 @@
"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",
"doctype": "DocField"
"fieldtype": "Column Break"
},
{
"default": "INR",
@@ -97,21 +104,21 @@
},
{
"doctype": "DocField",
"label": "Default Currency Fraction",
"fieldname": "default_currency_fraction",
"fieldtype": "Data",
"label": "Default Currency Fraction"
"fieldtype": "Data"
},
{
"doctype": "DocField",
"label": "Stock",
"fieldname": "stock",
"fieldtype": "Section Break",
"label": "Stock"
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break2",
"fieldtype": "Column Break",
"doctype": "DocField"
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -143,7 +150,6 @@
},
{
"description": "Applicable only if valuation method is moving average",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Allow Negative Stock",
"fieldname": "allow_negative_stock",
@@ -158,9 +164,9 @@
},
{
"doctype": "DocField",
"label": "Raise Purchase Request when stock reaches re-order level",
"fieldname": "auto_indent",
"fieldtype": "Check",
"label": "Raise Purchase Request when stock reaches re-order level"
"fieldtype": "Check"
},
{
"default": "1",
@@ -171,7 +177,6 @@
},
{
"description": "Percentage you are allowed to receive or deliver more against the quantity ordered. <p>For example: If you have ordered 100 units. and your Allowance is 10% then you are allowed to receive 110 units</p>",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Allowance Percent",
"fieldname": "tolerance",
@@ -179,7 +184,6 @@
},
{
"description": "Stock level frozen up to this date, nobody can do / modify entry except authorized person",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Stock Frozen Upto",
"fieldname": "stock_frozen_upto",
@@ -187,7 +191,6 @@
},
{
"description": "Users with this role are allowed to do / modify stock entry before frozen date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Authorized Role (Frozen Entry)",
"fieldname": "stock_auth_role",
@@ -196,13 +199,12 @@
},
{
"doctype": "DocField",
"label": "Accounts",
"fieldname": "accounts",
"fieldtype": "Section Break",
"label": "Accounts"
"fieldtype": "Section Break"
},
{
"description": "Accounting entry frozen up to this date, nobody can do / modify entry except authorized person",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Accounts Frozen Upto",
"fieldname": "acc_frozen_upto",
@@ -210,7 +212,6 @@
},
{
"description": "Users with this role are allowed to do / modify accounting entry before frozen date",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Authourized Role (Frozen Entry)",
"fieldname": "bde_auth_role",
@@ -225,9 +226,9 @@
"options": "Role"
},
{
"doctype": "DocField",
"fieldname": "column_break4",
"fieldtype": "Column Break",
"doctype": "DocField"
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -238,13 +239,12 @@
},
{
"doctype": "DocField",
"label": "Selling",
"fieldname": "selling",
"fieldtype": "Section Break",
"label": "Selling"
"fieldtype": "Section Break"
},
{
"default": "Customer Name",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Customer Master created by ",
"fieldname": "cust_master_name",
@@ -280,10 +280,10 @@
"options": "<a href=\"#!Sales Browser/Territory\">To manage Territory, click here</a>"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break5",
"fieldtype": "Column Break",
"doctype": "DocField"
"fieldtype": "Column Break"
},
{
"doctype": "DocField",
@@ -301,7 +301,6 @@
},
{
"default": "No",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Sales Order Required",
"fieldname": "so_required",
@@ -310,7 +309,6 @@
},
{
"default": "No",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Delivery Note Required",
"fieldname": "dn_required",
@@ -319,9 +317,9 @@
},
{
"doctype": "DocField",
"label": "Buying",
"fieldname": "buying",
"fieldtype": "Section Break",
"label": "Buying"
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
@@ -332,7 +330,6 @@
},
{
"default": "Supplier Name",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Supplier Master created by ",
"fieldname": "supp_master_name",
@@ -340,14 +337,13 @@
"options": "Supplier Name\nNaming Series"
},
{
"doctype": "DocField",
"width": "50%",
"fieldname": "column_break6",
"fieldtype": "Column Break",
"doctype": "DocField"
"fieldtype": "Column Break"
},
{
"default": "No",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Purchase Order Required",
"fieldname": "po_required",
@@ -356,7 +352,6 @@
},
{
"default": "No",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Purchase Receipt Required",
"fieldname": "pr_required",
@@ -365,9 +360,9 @@
},
{
"doctype": "DocField",
"label": "Maintain same rate throughout purchase cycle",
"fieldname": "maintain_same_rate",
"fieldtype": "Check",
"label": "Maintain same rate throughout purchase cycle"
"fieldtype": "Check"
},
{
"doctype": "DocField",
@@ -378,7 +373,6 @@
},
{
"description": "Employee record is created using selected field. ",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Employee Records to be created by ",
"fieldname": "emp_created_by",
@@ -387,15 +381,15 @@
},
{
"doctype": "DocField",
"label": "System",
"fieldname": "system",
"fieldtype": "Section Break",
"label": "System"
"fieldtype": "Section Break"
},
{
"doctype": "DocField",
"label": "SMS Sender Name",
"fieldname": "sms_sender_name",
"fieldtype": "Data",
"label": "SMS Sender Name"
"fieldtype": "Data"
},
{
"amend": 0,
@@ -415,20 +409,20 @@
"permlevel": 0
},
{
"doctype": "DocPerm",
"write": 1,
"role": "System Manager",
"permlevel": 1
},
{
"doctype": "DocPerm",
"role": "All",
"permlevel": 1,
"doctype": "DocPerm"
"permlevel": 1
},
{
"doctype": "DocPerm",
"write": 1,
"role": "System Manager",
"permlevel": 1,
"doctype": "DocPerm"
},
{
"write": 1,
"role": "System Manager",
"permlevel": 2,
"doctype": "DocPerm"
"permlevel": 2
}
]

View File

@@ -14,6 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
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';

View File

@@ -77,7 +77,7 @@ cur_frm.cscript.make_contact = function() {
page_length: 2,
new_doctype: "Contact",
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.sales_partner = cur_frm.doc.name;
wn.set_route("Form", "Contact", contact.name);

View File

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

View File

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

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
var mydoc = doc
var call_back_action = function(mydoc){
$c('runserverobj', args={'method':'field_label_list', 'docs':compress_doclist (make_doclist (mydoc.doctype,mydoc.name))},
$c('runserverobj', args={'method':'field_label_list', 'docs':wn.model.compress (make_doclist (mydoc.doctype,mydoc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_action_details.grid.get_field("action_field").df.options = r.message;
@@ -41,7 +41,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
}
var call_back_rule = function(mydoc){
$c('runserverobj', args={'method':'compare_field', 'docs':compress_doclist (make_doclist (mydoc.doctype,mydoc.name))},
$c('runserverobj', args={'method':'compare_field', 'docs':wn.model.compress (make_doclist (mydoc.doctype,mydoc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_rule_details.grid.get_field("comparing_field").df.options = r.message;
@@ -50,7 +50,7 @@ cur_frm.cscript.select_form = function(doc, cdt, cdn){
);
}
$c('runserverobj', args={'method':'maindoc_field', 'docs':compress_doclist (make_doclist (doc.doctype,doc.name))},
$c('runserverobj', args={'method':'maindoc_field', 'docs':wn.model.compress (make_doclist (doc.doctype,doc.name))},
function(r, rt) {
var doc = locals[mydoc.doctype][mydoc.name];
cur_frm.fields_dict.workflow_rule_details.grid.get_field("rule_field").df.options = r.message;

View File

@@ -5,4 +5,6 @@
One of the Roles has <b>Submit</b> permission.
You will have to <b>Cancel</b> and then <b>Amend</b> a submitted Document for making changes.
</div>
<hr>
<div class="well">Note: A document is not accessible to a user if Permission at level 0 is not given.</div>
</div>