refactored client side Model and Meta - frappe/frappe#478

This commit is contained in:
Rushabh Mehta
2014-03-26 18:24:30 +05:30
parent 5c6b34a84c
commit aa355af2cf
31 changed files with 53 additions and 77 deletions

View File

@@ -68,7 +68,7 @@ erpnext.hr.EmployeeController = frappe.ui.form.Controller.extend({
Go to the active Salary Structure and set \"Is Active\" = \"No\""));
} else if(!r.exc) {
frappe.model.map({
source: frappe.model.get_doclist(me.frm.doc.doctype, me.frm.doc.name),
source: me.frm.doc,
target: "Salary Structure"
});
}

View File

@@ -125,7 +125,7 @@ cur_frm.cscript.validate = function(doc) {
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
doc.total_claimed_amount = 0;
doc.total_sanctioned_amount = 0;
$.each(frappe.model.get("Expense Claim Detail", {parent:doc.name}), function(i, d) {
$.each((doc.expense_voucher_details || []), function(i, d) {
doc.total_claimed_amount += d.claim_amount;
if(d.sanctioned_amount==null) {
d.sanctioned_amount = d.claim_amount;

View File

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

View File

@@ -15,7 +15,7 @@ cur_frm.cscript.create_salary_slip = function(doc, cdt, cdn) {
if (r.message)
display_activity_log(r.message);
}
return $c('runserverobj', args={'method':'create_sal_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback);
return $c('runserverobj', args={'method':'create_sal_slip','docs':doc},callback);
}
cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
@@ -25,7 +25,7 @@ cur_frm.cscript.submit_salary_slip = function(doc, cdt, cdn) {
if (r.message)
display_activity_log(r.message);
}
return $c('runserverobj', args={'method':'submit_salary_slip','docs':frappe.model.compress(make_doclist (cdt, cdn))},callback);
return $c('runserverobj', args={'method':'submit_salary_slip','docs':doc},callback);
}
}
@@ -59,5 +59,5 @@ cur_frm.cscript.make_jv = function(doc, dt, dn) {
loaddoc('Journal Voucher', jv.name);
}
return $c_obj(make_doclist(dt, dn), 'get_acc_details', '', call_back);
return $c_obj(doc, 'get_acc_details', '', call_back);
}

View File

@@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc,dt,dn){
// Get leave details
//---------------------------------------------------------------------
cur_frm.cscript.fiscal_year = function(doc,dt,dn){
return $c_obj(make_doclist(doc.doctype,doc.name), 'get_emp_and_leave_details','',function(r, rt) {
return $c_obj(doc, 'get_emp_and_leave_details','',function(r, rt) {
var doc = locals[dt][dn];
cur_frm.refresh();
calculate_all(doc, dt, dn);
@@ -32,7 +32,7 @@ cur_frm.cscript.month = cur_frm.cscript.employee = cur_frm.cscript.fiscal_year;
cur_frm.cscript.leave_without_pay = function(doc,dt,dn){
if (doc.employee && doc.fiscal_year && doc.month) {
return $c_obj(make_doclist(doc.doctype,doc.name), 'get_leave_details',doc.leave_without_pay,function(r, rt) {
return $c_obj(doc, 'get_leave_details',doc.leave_without_pay,function(r, rt) {
var doc = locals[dt][dn];
cur_frm.refresh();
calculate_all(doc, dt, dn);

View File

@@ -7,7 +7,7 @@ cur_frm.cscript.onload = function(doc, dt, dn){
e_tbl = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype);
d_tbl = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype);
if (e_tbl.length == 0 && d_tbl.length == 0)
return $c_obj(make_doclist(doc.doctype,doc.name),'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);});
return $c_obj(doc,'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);});
}
cur_frm.cscript.refresh = function(doc, dt, dn){