Merge pull request #1141 from nabinhait/hotfix

[fix] [minor] Master name validation for customer/supplier/warehouse acc...
This commit is contained in:
Nabin Hait 2013-12-04 01:50:13 -08:00
commit 80d9514636
3 changed files with 21 additions and 34 deletions

View File

@ -38,9 +38,12 @@ class DocType:
def validate_master_name(self): def validate_master_name(self):
"""Remind to add master name""" """Remind to add master name"""
if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') \ if self.doc.master_type in ('Customer', 'Supplier') or self.doc.account_type == "Warehouse":
and not self.doc.master_name: if not self.doc.master_name:
msgprint("Message: Please enter Master Name once the account is created.") msgprint(_("Please enter Master Name once the account is created."))
elif not webnotes.conn.exists(self.doc.master_type or self.doc.account_type,
self.doc.master_name):
webnotes.throw(_("Invalid Master Name"))
def validate_parent(self): def validate_parent(self):
"""Fetch Parent Details and validation for account not to be created under ledger""" """Fetch Parent Details and validation for account not to be created under ledger"""

View File

@ -18,10 +18,6 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
return $c('runserverobj', args={'method':'create_sal_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback); return $c('runserverobj', args={'method':'create_sal_slip','docs':wn.model.compress(make_doclist (cdt, cdn))},callback);
} }
//Submit salary slip
//-----------------------
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) { cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
var check = confirm(wn._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ wn._(" and fiscal year : ")+doc.fiscal_year); var check = confirm(wn._("Do you really want to Submit all Salary Slip for month : ") + doc.month+ wn._(" and fiscal year : ")+doc.fiscal_year);
if(check){ if(check){
@ -33,23 +29,21 @@ cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
} }
} }
// Make Bank Voucher
//-----------------------
cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){ cur_frm.cscript.make_bank_voucher = function(doc,cdt,cdn){
if(doc.month && doc.fiscal_year){ if(doc.company && doc.month && doc.fiscal_year){
cur_frm.cscript.make_jv(doc, cdt, cdn); cur_frm.cscript.make_jv(doc, cdt, cdn);
} } else {
msgprint(wn._("Company, Month and Fiscal Year is mandatory"));
}
} }
// Make JV
//-----------------------
cur_frm.cscript.make_jv = function(doc, dt, dn) { cur_frm.cscript.make_jv = function(doc, dt, dn) {
var call_back = function(r,rt){ var call_back = function(r, rt){
var jv = wn.model.make_new_doc_and_get_name('Journal Voucher'); var jv = wn.model.make_new_doc_and_get_name('Journal Voucher');
jv = locals['Journal Voucher'][jv]; jv = locals['Journal Voucher'][jv];
jv.voucher_type = 'Bank Voucher'; jv.voucher_type = 'Bank Voucher';
jv.user_remark = wn._('Payment of salary for the month: ') + doc.month + wn._('and fiscal year: ') + doc.fiscal_year; jv.user_remark = wn._('Payment of salary for the month: ') + doc.month +
wn._('and fiscal year: ') + doc.fiscal_year;
jv.fiscal_year = doc.fiscal_year; jv.fiscal_year = doc.fiscal_year;
jv.company = doc.company; jv.company = doc.company;
jv.posting_date = dateutil.obj_to_str(new Date()); jv.posting_date = dateutil.obj_to_str(new Date());
@ -61,10 +55,9 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
// debit to salary account // debit to salary account
var d2 = wn.model.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'] d2.debit = r.message['amount']
loaddoc('Journal Voucher', jv.name); loaddoc('Journal Voucher', jv.name);
} }
return $c_obj(make_doclist(dt,dn),'get_acc_details','',call_back); return $c_obj(make_doclist(dt, dn), 'get_acc_details', '', call_back);
} }

View File

@ -3,17 +3,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cint, flt from webnotes.utils import cint, flt
from webnotes.model import db_exists
from webnotes.model.doc import Document
from webnotes.model.bean import getlist, copy_doclist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
from webnotes import msgprint from webnotes import msgprint
class DocType: class DocType:
def __init__(self, doc, doclist): def __init__(self, doc, doclist):
self.doc = doc self.doc = doc
@ -198,14 +191,12 @@ class DocType:
get default bank account,default salary acount from company get default bank account,default salary acount from company
""" """
amt = self.get_total_salary() amt = self.get_total_salary()
com = webnotes.conn.sql("select default_bank_account from `tabCompany` where name = '%s'" % self.doc.company) default_bank_account = webnotes.conn.get_value("Company", self.doc.company,
"default_bank_account")
if not com[0][0] or not com[0][1]: if not default_bank_account:
msgprint("You can set Default Bank Account in Company master.") msgprint("You can set Default Bank Account in Company master.")
ret = { return {
'def_bank_acc' : com and com[0][0] or '', 'default_bank_account' : default_bank_account,
'def_sal_acc' : com and com[0][1] or '',
'amount' : amt 'amount' : amt
} }
return ret