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

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