merged with master

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

View File

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

View File

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

View File

@ -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 += '<p><b>Note:</b> This is Cost Center is a <i>Group</i>, \
intro_txt += '<p><b>Note:</b> This Cost Center is a <i>Group</i>, \
Accounting Entries are not allowed against groups.</p>';
}

View File

@ -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<children.length; i++) {
LocalDB.set_default_values(children[i]);
wn.model.set_default_values(children[i]);
}
refresh_field('entries');
}
@ -193,7 +193,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) {
if(!children || children.length==0) {
$c('accounts.get_default_bank_account', {company: doc.company }, function(r, rt) {
if(!r.exc) {
var jvd = LocalDB.add_child(doc, 'Journal Voucher Detail', 'entries');
var jvd = wn.model.add_child(doc, 'Journal Voucher Detail', 'entries');
jvd.account = cstr(r.message);
refresh_field('entries');
}

View File

@ -266,7 +266,7 @@ calc_total_advance = function(doc,cdt,cdn) {
}
cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
var jv = LocalDB.create('Journal Voucher');
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv];
jv.voucher_type = 'Bank Voucher';
jv.remark = repl('Payment against voucher %(vn)s for %(rem)s', {vn:doc.name, rem:doc.remarks});
@ -276,13 +276,13 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
jv.company = doc.company;
// debit to creditor
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d1.account = doc.credit_to;
d1.debit = doc.outstanding_amount;
d1.against_voucher = doc.name;
// credit to bank
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d1.account = bank_account;
d1.credit = doc.outstanding_amount;

View File

@ -29,7 +29,7 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
// On Load
// -------
cur_frm.cscript.onload = function(doc,dt,dn) {
if(!doc.customer && doc.debit_to) Meta.get_field(dt, 'debit_to', dn).print_hide = 0;
if(!doc.customer && doc.debit_to) wn.meta.get_docfield(dt, 'debit_to', dn).print_hide = 0;
if (doc.__islocal) {
//if(!doc.voucher_date) set_multiple(dt,dn,{voucher_date:get_today()});
if(!doc.due_date) set_multiple(dt,dn,{due_date:get_today()});
@ -322,9 +322,9 @@ cur_frm.cscript.allocated_amount = function(doc,cdt,cdn){
cur_frm.cscript['Make Delivery Note'] = function() {
var doc = cur_frm.doc
n = createLocal('Delivery Note');
n = wn.model.make_new_doc_and_get_name('Delivery Note');
$c('dt_map', args={
'docs':compress_doclist([locals['Delivery Note'][n]]),
'docs':wn.model.compress([locals['Delivery Note'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Delivery Note',
'from_docname':doc.name,
@ -484,7 +484,7 @@ cur_frm.cscript.calc_adjustment_amount = function(doc,cdt,cdn) {
// Make Journal Voucher
// --------------------
cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
var jv = LocalDB.create('Journal Voucher');
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv];
jv.voucher_type = 'Bank Voucher';
@ -493,14 +493,14 @@ cur_frm.cscript.make_jv = function(doc, dt, dn, bank_account) {
jv.fiscal_year = doc.fiscal_year;
// debit to creditor
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d1.account = doc.debit_to;
d1.credit = doc.outstanding_amount;
d1.against_invoice = doc.name;
// credit to bank
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d1.account = bank_account;
d1.debit = doc.outstanding_amount;

View File

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

View File

@ -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"):

View File

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

View File

@ -51,14 +51,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<children.length; i++) {
LocalDB.set_default_values(children[i]);
wn.model.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
cur_frm.cscript.load_taxes(doc, dt, dn, callback);

View File

@ -122,9 +122,9 @@ cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){
//========================= Make Purchase Receipt =======================================================
cur_frm.cscript['Make Purchase Receipt'] = function() {
n = createLocal('Purchase Receipt');
n = wn.model.make_new_doc_and_get_name('Purchase Receipt');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Receipt'][n]]),
'docs':wn.model.compress([locals['Purchase Receipt'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Receipt',
'from_docname':cur_frm.doc.name,
@ -137,9 +137,9 @@ cur_frm.cscript['Make Purchase Receipt'] = function() {
//========================== Make Purchase Invoice =====================================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = createLocal('Purchase Invoice');
n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', {
'docs':compress_doclist([locals['Purchase Invoice'][n]]),
'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype':cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,
@ -158,7 +158,7 @@ cur_frm.cscript['Stop Purchase Order'] = function() {
var check = confirm("Do you really want to STOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
@ -171,7 +171,7 @@ cur_frm.cscript['Unstop Purchase Order'] = function() {
var check = confirm("Do you really want to UNSTOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}

View File

@ -86,9 +86,9 @@ cur_frm.cscript.qty = function(doc, cdt, cdn) {
// Make Purchase Order
cur_frm.cscript['Make Purchase Order'] = function() {
var doc = cur_frm.doc;
n = createLocal('Purchase Order');
n = wn.model.make_new_doc_and_get_name('Purchase Order');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Order'][n]]),
'docs':wn.model.compress([locals['Purchase Order'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Purchase Order',
'from_docname':doc.name,
@ -106,7 +106,7 @@ cur_frm.cscript['Stop Purchase Request'] = function() {
var check = confirm("Do you really want to STOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
@ -119,7 +119,7 @@ cur_frm.cscript['Unstop Purchase Request'] = function(){
var check = confirm("Do you really want to UNSTOP this Purchase Request?");
if (check) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
@ -127,9 +127,9 @@ cur_frm.cscript['Unstop Purchase Request'] = function(){
}
cur_frm.cscript.make_supplier_quotation = function() {
var new_sq_name = createLocal("Supplier Quotation");
var new_sq_name = wn.model.make_new_doc_and_get_name("Supplier Quotation");
$c("dt_map", {
"docs": compress_doclist([locals['Supplier Quotation'][new_sq_name]]),
"docs": wn.model.compress([locals['Supplier Quotation'][new_sq_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Supplier Quotation",
"from_docname": cur_frm.doc.name,

View File

@ -79,7 +79,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.supplier = cur_frm.doc.name;
contact.supplier_name = cur_frm.doc.supplier_name;

View File

@ -49,9 +49,9 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
}
cur_frm.cscript.make_purchase_order = function() {
var new_po_name = createLocal("Purchase Order");
var new_po_name = wn.model.make_new_doc_and_get_name("Purchase Order");
$c("dt_map", {
"docs": compress_doclist([locals['Purchase Order'][new_po_name]]),
"docs": wn.model.compress([locals['Purchase Order'][new_po_name]]),
"from_doctype": cur_frm.doc.doctype,
"to_doctype": "Purchase Order",
"from_docname": cur_frm.doc.name,

View File

@ -36,7 +36,7 @@ erpnext.ActivityFeed = Class.extend({
// feedtype
if(!data.feed_type) {
data.feed_type = get_doctype_label(data.doc_type);
data.feed_type = wn._(data.doc_type);
data.add_class = "label-info";
data.onclick = repl('onclick="window.location.href=\'#!List/%(feed_type)s\';"', data)
}

View File

@ -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.",

View File

@ -2,23 +2,18 @@
{
"owner": "ashwini@webnotestech.com",
"docstatus": 0,
"creation": "2012-03-27 14:35:53",
"creation": "2012-07-03 13:30:41",
"modified_by": "Administrator",
"modified": "2012-03-27 14:45:46"
"modified": "2012-12-13 14:23:24"
},
{
"section_style": "Simple",
"is_submittable": 1,
"autoname": "naming_series:",
"name": "__common__",
"search_fields": "employee, employee_name, att_date, status",
"module": "HR",
"doctype": "DocType",
"server_code_error": " ",
"document_type": "Master",
"name": "__common__",
"colour": "White:FFF",
"_last_update": "1317365120",
"show_in_menu": 0,
"version": 75
"document_type": "Master"
},
{
"name": "__common__",
@ -30,12 +25,11 @@
{
"name": "__common__",
"parent": "Attendance",
"amend": 0,
"read": 1,
"create": 1,
"submit": 1,
"doctype": "DocPerm",
"write": 1,
"read": 1,
"parenttype": "DocType",
"cancel": 1,
"permlevel": 0,
@ -45,26 +39,14 @@
"name": "Attendance",
"doctype": "DocType"
},
{
"role": "System Manager",
"doctype": "DocPerm"
},
{
"role": "HR User",
"doctype": "DocPerm"
},
{
"role": "HR Manager",
"doctype": "DocPerm"
},
{
"oldfieldtype": "Section Break",
"doctype": "DocField",
"label": "Attendance Details",
"permlevel": 0,
"options": "Simple",
"fieldname": "attendance_details",
"fieldtype": "Section Break",
"options": "Simple"
"permlevel": 0
},
{
"no_copy": 1,
@ -72,25 +54,23 @@
"doctype": "DocField",
"label": "Naming Series",
"oldfieldname": "naming_series",
"permlevel": 0,
"options": "ATT",
"fieldname": "naming_series",
"fieldtype": "Select",
"reqd": 1,
"options": "ATT"
"permlevel": 0
},
{
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Employee",
"oldfieldname": "employee",
"permlevel": 0,
"trigger": "Client",
"options": "Employee",
"fieldname": "employee",
"fieldtype": "Link",
"search_index": 1,
"reqd": 1,
"options": "Employee",
"permlevel": 0,
"in_filter": 1
},
{
@ -105,7 +85,6 @@
{
"no_copy": 1,
"oldfieldtype": "Select",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Status",
"oldfieldname": "status",
@ -120,7 +99,6 @@
{
"print_hide": 1,
"oldfieldtype": "Link",
"colour": "White:FFF",
"doctype": "DocField",
"label": "Leave Type",
"oldfieldname": "leave_type",
@ -140,13 +118,13 @@
"permlevel": 0
},
{
"search_index": 0,
"oldfieldtype": "Date",
"doctype": "DocField",
"label": "Attendance Date",
"oldfieldname": "att_date",
"fieldname": "att_date",
"fieldtype": "Date",
"oldfieldtype": "Date",
"search_index": 0,
"reqd": 1,
"permlevel": 0,
"in_filter": 1
@ -156,11 +134,11 @@
"doctype": "DocField",
"label": "Fiscal Year",
"oldfieldname": "fiscal_year",
"permlevel": 0,
"options": "\n2012\n2013",
"fieldname": "fiscal_year",
"fieldtype": "Select",
"reqd": 1,
"options": "link:Fiscal Year",
"permlevel": 0,
"in_filter": 1
},
{
@ -168,11 +146,11 @@
"doctype": "DocField",
"label": "Company",
"oldfieldname": "company",
"permlevel": 0,
"options": "\nAlpha\nBeta\nDemo Company",
"fieldname": "company",
"fieldtype": "Select",
"reqd": 1,
"options": "link:Company",
"permlevel": 0,
"in_filter": 1
},
{
@ -191,9 +169,21 @@
"no_copy": 1,
"doctype": "DocField",
"label": "Amended From",
"permlevel": 1,
"options": "Attendance",
"fieldname": "amended_from",
"fieldtype": "Link",
"options": "Sales Invoice"
"permlevel": 1
},
{
"role": "HR User",
"doctype": "DocPerm"
},
{
"role": "HR Manager",
"doctype": "DocPerm"
},
{
"role": "System Manager",
"doctype": "DocPerm"
}
]

View File

@ -53,7 +53,7 @@ cur_frm.cscript['Make Salary Structure']=function(){
}
cur_frm.cscript.make_salary_structure = function(doc,dt,dn,det){
var st = LocalDB.create('Salary Structure');
var st = wn.model.make_new_doc_and_get_name('Salary Structure');
st = locals['Salary Structure'][st];
st.employee = doc.name;
st.employee_name = doc.employee_name;

View File

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

View File

@ -24,7 +24,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){
// Validation For To Date
// ================================================================================================
cur_frm.cscript.to_date = function(doc, cdt, cdn) {
$c('runserverobj', args={'method':'to_date_validation','docs':compress_doclist(make_doclist(doc.doctype, doc.name))},
$c('runserverobj', args={'method':'to_date_validation','docs':wn.model.compress(make_doclist(doc.doctype, doc.name))},
function(r, rt) {
var doc = locals[cdt][cdn];
if (r.message) {

View File

@ -28,7 +28,7 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
if (r.message)
display_activity_log(r.message);
}
$c('runserverobj', args={'method':'create_sal_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
$c('runserverobj', args={'method':'create_sal_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback);
}
@ -42,7 +42,7 @@ cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
if (r.message)
display_activity_log(r.message);
}
$c('runserverobj', args={'method':'submit_salary_slip','docs':compress_doclist(make_doclist (cdt, cdn))},callback);
$c('runserverobj', args={'method':'submit_salary_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback);
}
}
@ -59,7 +59,7 @@ cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){
//-----------------------
cur_frm.cscript.make_jv = function(doc, dt, dn) {
var call_back = function(r,rt){
var jv = LocalDB.create('Journal Voucher');
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv];
jv.voucher_type = 'Bank Voucher';
jv.user_remark = 'Payment of salary for the month: ' + doc.month + 'and fiscal year: ' + doc.fiscal_year;
@ -68,12 +68,12 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
jv.posting_date = dateutil.obj_to_str(new Date());
// credit to bank
var d1 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d1 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d1.account = r.message['default_bank_account'];
d1.credit = r.message['amount']
// debit to salary account
var d2 = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var d2 = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
d2.account = r.message['default_salary_account'];
d2.debit = r.message['amount']

View File

@ -42,9 +42,9 @@ cur_frm.cscript['Make Salary Slip'] = function(){
var doc = cur_frm.doc;
var callback = function(r,rt){
ret = r.message;
n = createLocal("Salary Slip");
n = wn.model.make_new_doc_and_get_name("Salary Slip");
$c('dt_map', args={
'docs':compress_doclist([locals["Salary Slip"][n]]),
'docs':wn.model.compress([locals["Salary Slip"][n]]),
'from_doctype':'Salary Structure',
'to_doctype':'Salary Slip',
'from_docname':doc.name,

View File

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

View File

@ -0,0 +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] and p[1][0]=='[':
webnotes.cache().set_value("recent:" + p[0], json.loads(p[1]))

View File

@ -0,0 +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')
where script_type='Client'""")

View File

@ -530,4 +530,12 @@ patch_list = [
'patch_module': 'patches.december_2012',
'patch_file': 'fix_default_print_format',
},
{
'patch_module': 'patches.december_2012',
'patch_file': 'file_list_rename',
},
{
'patch_module': 'patches.december_2012',
'patch_file': 'replace_createlocal',
},
]

View File

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

View File

@ -79,7 +79,7 @@ erpnext.show_task_gantt = function(parent, project) {
$('<button class="btn"><i class="icon icon-plus"></i>\
Create a new Task</button>').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);

View File

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

View File

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

View File

@ -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
})
}
@ -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,

View File

@ -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
});
}
@ -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,
@ -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) {

View File

@ -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
});
}
}
@ -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,
@ -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);

View File

@ -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<children.length; i++) {
LocalDB.set_default_values(children[i]);
wn.model.set_default_values(children[i]);
}
refresh_field(cur_frm.cscript.fname);
cur_frm.cscript.load_taxes(doc, dt, dn, callback);

View File

@ -77,7 +77,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// indent
if(!doc.order_type || (doc.order_type == 'Sales'))
cur_frm.add_custom_button('Make ' + get_doctype_label('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
cur_frm.add_custom_button('Make ' + wn._('Purchase Request'), cur_frm.cscript['Make Purchase Request']);
// sales invoice
if(flt(doc.per_billed, 2) < 100)
@ -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']);
@ -163,7 +163,7 @@ cur_frm.cscript.pull_quotation_details = function(doc,dt,dn) {
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
@ -222,9 +222,9 @@ cur_frm.cscript['Make Maintenance Schedule'] = function() {
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_schedule','',
function(r,rt){
if(r.message == 'No'){
n = createLocal("Maintenance Schedule");
n = wn.model.make_new_doc_and_get_name("Maintenance Schedule");
$c('dt_map', args={
'docs':compress_doclist([locals["Maintenance Schedule"][n]]),
'docs':wn.model.compress([locals["Maintenance Schedule"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Maintenance Schedule',
'from_docname':doc.name,
@ -251,9 +251,9 @@ cur_frm.cscript.make_maintenance_visit = function() {
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_visit','',
function(r,rt){
if(r.message == 'No'){
n = createLocal("Maintenance Visit");
n = wn.model.make_new_doc_and_get_name("Maintenance Visit");
$c('dt_map', args={
'docs':compress_doclist([locals["Maintenance Visit"][n]]),
'docs':wn.model.compress([locals["Maintenance Visit"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Maintenance Visit',
'from_docname':doc.name,
@ -277,9 +277,9 @@ cur_frm.cscript.make_maintenance_visit = function() {
cur_frm.cscript['Make Purchase Request'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
n = createLocal("Purchase Request");
n = wn.model.make_new_doc_and_get_name("Purchase Request");
$c('dt_map', args={
'docs':compress_doclist([locals["Purchase Request"][n]]),
'docs':wn.model.compress([locals["Purchase Request"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Purchase Request',
'from_docname':doc.name,
@ -298,9 +298,9 @@ cur_frm.cscript['Make Purchase Request'] = function() {
cur_frm.cscript['Make Delivery Note'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
n = createLocal("Delivery Note");
n = wn.model.make_new_doc_and_get_name("Delivery Note");
$c('dt_map', args={
'docs':compress_doclist([locals["Delivery Note"][n]]),
'docs':wn.model.compress([locals["Delivery Note"][n]]),
'from_doctype':'Sales Order',
'to_doctype':'Delivery Note',
'from_docname':doc.name,
@ -319,9 +319,9 @@ cur_frm.cscript['Make Delivery Note'] = function() {
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc;
n = createLocal('Sales Invoice');
n = wn.model.make_new_doc_and_get_name('Sales Invoice');
$c('dt_map', args={
'docs':compress_doclist([locals['Sales Invoice'][n]]),
'docs':wn.model.compress([locals['Sales Invoice'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Sales Invoice',
'from_docname':doc.name,
@ -341,7 +341,7 @@ cur_frm.cscript['Stop Sales Order'] = function() {
var check = confirm("Are you sure you want to STOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'stop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'stop_sales_order', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}
@ -355,7 +355,7 @@ cur_frm.cscript['Unstop Sales Order'] = function() {
var check = confirm("Are you sure you want to UNSTOP " + doc.name);
if (check) {
$c('runserverobj', args={'method':'unstop_sales_order', 'docs': compress_doclist(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
$c('runserverobj', args={'method':'unstop_sales_order', 'docs': wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) {
cur_frm.refresh();
});
}

View File

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

View File

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

View File

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

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>

View File

@ -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()
@ -119,7 +115,7 @@ def check_if_expired():
from webnotes.utils import formatdate
msg = """Oops! Your subscription expired on <b>%s</b>.<br>""" % 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 <b>support@erpnext.com</b> and
we will guide you to get your account re-activated."""
else:

View File

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

View File

@ -128,7 +128,7 @@ cur_frm.cscript.get_items = function(doc,dt,dn) {
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
@ -192,9 +192,9 @@ cur_frm.fields_dict['transporter_name'].get_query = function(doc) {
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Sales Invoice'] = function() {
var doc = cur_frm.doc
n = createLocal('Sales Invoice');
n = wn.model.make_new_doc_and_get_name('Sales Invoice');
$c('dt_map', args={
'docs':compress_doclist([locals['Sales Invoice'][n]]),
'docs':wn.model.compress([locals['Sales Invoice'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Sales Invoice',
'from_docname':doc.name,
@ -209,9 +209,9 @@ cur_frm.cscript['Make Sales Invoice'] = function() {
cur_frm.cscript['Make Installation Note'] = function() {
var doc = cur_frm.doc;
if(doc.per_installed < 99.99){
n = createLocal('Installation Note');
n = wn.model.make_new_doc_and_get_name('Installation Note');
$c('dt_map', args={
'docs':compress_doclist([locals['Installation Note'][n]]),
'docs':wn.model.compress([locals['Installation Note'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Installation Note',
'from_docname':doc.name,
@ -228,9 +228,9 @@ cur_frm.cscript['Make Installation Note'] = function() {
//-----------------------------------Make Sales Invoice----------------------------------------------
cur_frm.cscript['Make Packing Slip'] = function() {
var doc = cur_frm.doc
n = createLocal('Packing Slip');
n = wn.model.make_new_doc_and_get_name('Packing Slip');
$c('dt_map', args={
'docs':compress_doclist([locals['Packing Slip'][n]]),
'docs':wn.model.compress([locals['Packing Slip'][n]]),
'from_doctype':doc.doctype,
'to_doctype':'Packing Slip',
'from_docname':doc.name,

View File

@ -24,7 +24,7 @@ wn.require('app/utilities/doctype/sms_control/sms_control.js');
//========================== On Load ================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.fiscal_year && doc.__islocal){ set_default_values(doc);}
if(!doc.fiscal_year && doc.__islocal){ wn.model.set_default_values(doc);}
if (!doc.posting_date) doc.posting_date = dateutil.obj_to_str(new Date());
if (!doc.transaction_date) doc.transaction_date = dateutil.obj_to_str(new Date());
if (!doc.status) doc.status = 'Draft';
@ -107,7 +107,7 @@ cur_frm.cscript.pull_purchase_order_details = function(doc, dt, dn) {
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
tn = wn.model.make_new_doc_and_get_name('Contact');
locals['Contact'][tn].is_supplier = 1;
if(doc.supplier) locals['Contact'][tn].supplier = doc.supplier;
loaddoc('Contact', tn);
@ -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' : 0,
'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);
@ -240,9 +241,9 @@ cur_frm.fields_dict.purchase_receipt_details.grid.get_field("qa_no").get_query =
// ================================ Make Purchase Invoice ==========================================
cur_frm.cscript['Make Purchase Invoice'] = function() {
n = createLocal('Purchase Invoice');
n = wn.model.make_new_doc_and_get_name('Purchase Invoice');
$c('dt_map', args={
'docs':compress_doclist([locals['Purchase Invoice'][n]]),
'docs':wn.model.compress([locals['Purchase Invoice'][n]]),
'from_doctype': cur_frm.doc.doctype,
'to_doctype':'Purchase Invoice',
'from_docname': cur_frm.doc.name,

View File

@ -120,7 +120,7 @@ cur_frm.cscript.validate_returned_qty = function(cl) {
// map parent fields of stock entry
//----------------------------------
cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
var se = LocalDB.create('Stock Entry');
var se = wn.model.make_new_doc_and_get_name('Stock Entry');
se = locals['Stock Entry'][se];
se.posting_date = dateutil.obj_to_str(new Date());
se.transfer_date = dateutil.obj_to_str(new Date());
@ -148,7 +148,7 @@ cur_frm.cscript.map_parent_fields = function(doc, cdt, cdn) {
cur_frm.cscript.map_child_fields = function(cl, se) {
for(var i = 0; i<cl.length; i++){
if (cl[i].returned_qty) {
var d1 = LocalDB.add_child(se, 'Stock Entry Detail', 'mtn_details');
var d1 = wn.model.add_child(se, 'Stock Entry Detail', 'mtn_details');
d1.detail_name = cl[i].detail_name;
d1.item_code = cl[i].item_code;
d1.description = cl[i].description;
@ -167,7 +167,7 @@ cur_frm.cscript.map_child_fields = function(cl, se) {
// Make excise voucher
//-------------------------------
cur_frm.cscript.make_excise_invoice = function(doc) {
var excise = LocalDB.create('Journal Voucher');
var excise = wn.model.make_new_doc_and_get_name('Journal Voucher');
excise = locals['Journal Voucher'][excise];
excise.voucher_type = 'Excise Voucher';
loaddoc('Journal Voucher',excise.name);
@ -203,7 +203,7 @@ cur_frm.cscript.make_credit_note = function(doc) {
// Make JV
//--------------------------------
cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
var jv = LocalDB.create('Journal Voucher');
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv];
jv.voucher_type = dr_or_cr;
@ -216,7 +216,7 @@ cur_frm.cscript.make_jv = function(doc, dr_or_cr, children) {
// Add children
if(children) {
for(var i=0; i<children.length; i++) {
var ch = LocalDB.add_child(jv, 'Journal Voucher Detail', 'entries');
var ch = wn.model.add_child(jv, 'Journal Voucher Detail', 'entries');
$.extend(ch, children[i]);
ch.balance = fmt_money(ch.balance);
}

View File

@ -71,9 +71,9 @@ cur_frm.cscript['Make Maintenance Visit'] = function() {
$c_obj(make_doclist(doc.doctype, doc.name),'check_maintenance_visit','',
function(r,rt){
if(r.message == 'No'){
n = createLocal("Maintenance Visit");
n = wn.model.make_new_doc_and_get_name("Maintenance Visit");
$c('dt_map', args={
'docs':compress_doclist([locals["Maintenance Visit"][n]]),
'docs':wn.model.compress([locals["Maintenance Visit"][n]]),
'from_doctype':'Customer Issue',
'to_doctype':'Maintenance Visit',
'from_docname':doc.name,

View File

@ -116,7 +116,7 @@ cur_frm.cscript.periodicity = function(doc, cdt, cdn){
cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) {
if (!doc.__islocal) {
$c('runserverobj', args={'method':'generate_schedule', 'docs':compress_doclist(make_doclist(cdt,cdn))},
$c('runserverobj', args={'method':'generate_schedule', 'docs':wn.model.compress(make_doclist(cdt,cdn))},
function(r,rt){
refresh_field('maintenance_schedule_detail');
}

View File

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

View File

@ -18,7 +18,6 @@ cur_frm.fields_dict.customer.get_query = erpnext.utils.customer_query;
$.extend(cur_frm.cscript, {
onload: function(doc, dt, dn) {
cur_frm.last_reload = new Date();
if(in_list(user_roles,'System Manager')) {
cur_frm.page_layout.footer.help_area.innerHTML = '<hr>\
<p><a href="#Form/Email Settings/Email Settings">Email Settings</a><br>\
@ -27,11 +26,6 @@ $.extend(cur_frm.cscript, {
},
refresh: function(doc) {
if(new Date() - cur_frm.last_reload > 20000) {
cur_frm.last_reload = new Date();
cur_frm.reload_doc();
return;
}
erpnext.hide_naming_series();
cur_frm.cscript.make_listing(doc);
if(!doc.__islocal) {

View File

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

View File

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

View File

@ -85,7 +85,7 @@ Calendar.prototype.show_event = function(ev, cal_ev) {
,['Text','Description']
,['HTML', 'Ref Link']
,['Check', 'Public Event']
,['Check', 'Cancel Event']
,['Check', 'Cancelled Event']
,['HTML', 'Event Link']
,['Button', 'Save']
])
@ -106,7 +106,7 @@ Calendar.prototype.show_event = function(ev, cal_ev) {
this.widgets['Description'].value = cstr(this.ev.description);
this.widgets['Public Event'].checked = false;
this.widgets['Cancel Event'].checked = false;
this.widgets['Cancelled Event'].checked = false;
if(this.ev.event_type=='Public')
this.widgets['Public Event'].checked = true;
@ -134,7 +134,7 @@ Calendar.prototype.show_event = function(ev, cal_ev) {
// save values
d.ev.description = d.widgets['Description'].value;
if(d.widgets['Cancel Event'].checked)
if(d.widgets['Cancelled Event'].checked)
d.ev.event_type='Cancel';
else if(d.widgets['Public Event'].checked)
d.ev.event_type='Public';
@ -154,7 +154,8 @@ Calendar.prototype.show_event = function(ev, cal_ev) {
Calendar.prototype.save_event = function(doc) {
var me = this;
save_doclist('Event', doc.name, 'Save', function(r) {
var doclist = new wn.model.DocList("Event", doc.name);
doclist.save("Save", function(r) {
var doc = locals['Event'][r.docname];
var cal = erpnext.calendar;
cal.cur_view.refresh();
@ -162,15 +163,15 @@ Calendar.prototype.save_event = function(doc) {
// if cancelled, hide
if(doc.event_type=='Cancel') {
$(cal.events_by_name[doc.name].body).toggle(false);
}
});
}
})
}
//------------------------------------------------------
Calendar.prototype.add_event = function() {
var ev = LocalDB.create('Event');
var ev = wn.model.make_new_doc_and_get_name('Event');
ev = locals['Event'][ev];
ev.event_date = dateutil.obj_to_str(this.selected_date);