This commit is contained in:
Rushabh Mehta 2014-03-27 14:17:33 +05:30
parent aa355af2cf
commit 66d52b55c0
31 changed files with 74 additions and 80 deletions

View File

@ -18,7 +18,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
if(doc.group_or_ledger=='Ledger') {
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
var accounts_settings = frappe.model.get_doc("Accounts Settings", name);
var accounts_settings = frappe.get_doc("Accounts Settings", name);
var display = accounts_settings["frozen_accounts_modifier"]
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);

View File

@ -39,7 +39,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
$.each([["against_voucher", "Purchase Invoice", "credit_to"],
["against_invoice", "Sales Invoice", "debit_to"]], function(i, opts) {
me.frm.set_query(opts[0], "entries", function(doc, cdt, cdn) {
var jvd = frappe.model.get_doc(cdt, cdn);
var jvd = frappe.get_doc(cdt, cdn);
frappe.model.validate_missing(jvd, "account");
return {
filters: [
@ -52,7 +52,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
});
this.frm.set_query("against_jv", "entries", function(doc, cdt, cdn) {
var jvd = frappe.model.get_doc(cdt, cdn);
var jvd = frappe.get_doc(cdt, cdn);
frappe.model.validate_missing(jvd, "account");
return {
@ -63,7 +63,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
},
against_voucher: function(doc, cdt, cdn) {
var d = frappe.model.get_doc(cdt, cdn);
var d = frappe.get_doc(cdt, cdn);
if (d.against_voucher && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Purchase Invoice',
@ -73,7 +73,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
},
against_invoice: function(doc, cdt, cdn) {
var d = frappe.model.get_doc(cdt, cdn);
var d = frappe.get_doc(cdt, cdn);
if (d.against_invoice && !flt(d.credit)) {
this.get_outstanding({
'doctype': 'Sales Invoice',
@ -83,7 +83,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({
},
against_jv: function(doc, cdt, cdn) {
var d = frappe.model.get_doc(cdt, cdn);
var d = frappe.get_doc(cdt, cdn);
if (d.against_jv && !flt(d.credit) && !flt(d.debit)) {
this.get_outstanding({
'doctype': 'Journal Voucher',
@ -138,7 +138,7 @@ cur_frm.cscript.is_opening = function(doc, cdt, cdn) {
cur_frm.cscript.update_totals = function(doc) {
var td=0.0; var tc =0.0;
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
var el = doc.entries || [];
for(var i in el) {
td += flt(el[i].debit, 2);
tc += flt(el[i].credit, 2);

View File

@ -108,7 +108,7 @@ erpnext.accounts.PurchaseInvoice = erpnext.buying.BuyingController.extend({
},
entries_add: function(doc, cdt, cdn) {
var row = frappe.model.get_doc(cdt, cdn);
var row = frappe.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("entries", row, ["expense_account", "cost_center"]);
}
});
@ -184,7 +184,7 @@ cur_frm.set_query("expense_account", "entries", function(doc) {
cur_frm.cscript.expense_account = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.idx == 1 && d.expense_account){
var cl = getchildren('Purchase Invoice Item', doc.name, 'entries', doc.doctype);
var cl = doc.entries || [];
for(var i = 0; i < cl.length; i++){
if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
}
@ -205,7 +205,7 @@ cur_frm.fields_dict["entries"].grid.get_field("cost_center").get_query = functio
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.idx == 1 && d.cost_center){
var cl = getchildren('Purchase Invoice Item', doc.name, 'entries', doc.doctype);
var cl = doc.entries || [];
for(var i = 0; i < cl.length; i++){
if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
}

View File

@ -41,7 +41,7 @@ cur_frm.pformat.other_charges= function(doc) {
return doc_field.print_hide;
}
var cl = getchildren('Purchase Taxes and Charges', doc.name, 'other_charges');
var cl = doc.other_charges || [];
// outer table
var out='<div><table class="noborder" style="width:100%">\

View File

@ -293,8 +293,7 @@ erpnext.POS = Class.extend({
// check whether the item is already added
if (no_of_items != 0) {
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
$.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) {
if (d.item_code == item_code) {
caught = true;
if (serial_no)
@ -335,8 +334,7 @@ erpnext.POS = Class.extend({
},
update_qty: function(item_code, qty) {
var me = this;
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
$.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) {
if (d.item_code == item_code) {
if (qty == 0) {
frappe.model.clear_doc(d.doctype, d.name);
@ -387,8 +385,7 @@ erpnext.POS = Class.extend({
var me = this;
var $items = this.wrapper.find("#cart tbody").empty();
$.each(frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
$.each(this.frm.doc[this.frm.cscript.fname] || [], function(i, d) {
$(repl('<tr id="%(item_code)s" data-selected="false">\
<td>%(item_code)s%(item_name)s</td>\
@ -422,8 +419,7 @@ erpnext.POS = Class.extend({
},
show_taxes: function() {
var me = this;
var taxes = frappe.model.get_children(this.sales_or_purchase + " Taxes and Charges",
this.frm.doc.name, this.frm.cscript.other_fname, this.frm.doctype);
var taxes = this.frm.doc[this.frm.cscript.other_fname] || [];
$(this.wrapper).find(".tax-table")
.toggle((taxes && taxes.length) ? true : false)
.find("tbody").empty();
@ -544,8 +540,7 @@ erpnext.POS = Class.extend({
}
}
var child = frappe.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
this.frm.cscript.fname, this.frm.doctype);
var child = this.frm.doc[this.frm.cscript.fname] || [];
$.each(child, function(i, d) {
for (var i in selected_items) {

View File

@ -199,7 +199,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
},
entries_add: function(doc, cdt, cdn) {
var row = frappe.model.get_doc(cdt, cdn);
var row = frappe.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("entries", row, ["income_account", "cost_center"]);
},

View File

@ -54,7 +54,7 @@ cur_frm.pformat.other_charges= function(doc){
out ='';
if (!doc.print_without_amount) {
var cl = getchildren('Sales Taxes and Charges', doc.name, 'other_charges');
var cl = doc.other_charges || [];
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 60%"></td><td>';

View File

@ -78,7 +78,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
price_list_rate: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
@ -92,7 +92,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
rate: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["rate", "discount_percentage"]);
if(item.price_list_rate) {
@ -107,7 +107,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
uom: function(doc, cdt, cdn) {
var me = this;
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.item_code && item.uom) {
return this.frm.call({
method: "erpnext.buying.utils.get_conversion_factor",
@ -132,7 +132,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
conversion_factor: function(doc, cdt, cdn) {
if(frappe.meta.get_docfield(cdt, "stock_qty", cdn)) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "conversion_factor"]);
item.stock_qty = flt(item.qty * item.conversion_factor, precision("stock_qty", item));
refresh_field("stock_qty", item.name, item.parentfield);
@ -140,7 +140,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
warehouse: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.item_code && item.warehouse) {
return this.frm.call({
method: "erpnext.buying.utils.get_projected_qty",
@ -154,7 +154,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
},
project_name: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.project_name) {
$.each(this.frm.doc[this.fname],
function(i, other_item) {

View File

@ -170,7 +170,7 @@ cur_frm.pformat.indent_no = function(doc, cdt, cdn){
out ='';
var cl = getchildren('Purchase Order Item',doc.name,'po_details');
var cl = doc.po_details || [];
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';

View File

@ -17,7 +17,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) {
cur_frm.cscript.make_contact(doc,dt,dn);
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"supplier": doc.name}),
list: frappe.get_list("Communication", {"supplier": doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc
})

View File

@ -23,7 +23,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
"Installation Note", "Opportunity", "Customer Issue", "Maintenance Visit",
"Maintenance Schedule"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.model.get_doc(doctype, docname);
var refdoc = frappe.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Customer" : true) {
cur_frm.set_value("customer", refdoc.customer || refdoc.name);
@ -34,7 +34,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.model.get_doc(doctype, docname);
var refdoc = frappe.get_doc(doctype, docname);
cur_frm.set_value("supplier", refdoc.supplier || refdoc.name);
cur_frm.set_value("supplier_name", refdoc.supplier_name);
if(cur_frm.doc.doctype==="Address")
@ -42,7 +42,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
if(["Lead", "Quotation"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.model.get_doc(doctype, docname);
var refdoc = frappe.get_doc(doctype, docname);
if(refdoc.doctype == "Quotation" ? refdoc.quotation_to=="Lead" : true) {
cur_frm.set_value("lead", refdoc.lead || refdoc.name);

View File

@ -32,7 +32,7 @@ cur_frm.cscript.kra_template = function(doc, dt, dn) {
cur_frm.cscript.calculate_total_score = function(doc,cdt,cdn){
//return get_server_fields('calculate_total','','',doc,cdt,cdn,1);
var val = getchildren('Appraisal Goal', doc.name, 'appraisal_details', doc.doctype);
var val = doc.appraisal_details || [];
var total =0;
for(var i = 0; i<val.length; i++){
total = flt(total)+flt(val[i].score_earned)
@ -61,7 +61,7 @@ cur_frm.cscript.score = function(doc,cdt,cdn){
}
cur_frm.cscript.calculate_total = function(doc,cdt,cdn){
var val = getchildren('Appraisal Goal', doc.name, 'appraisal_details', doc.doctype);
var val = doc.appraisal_details || [];
var total =0;
for(var i = 0; i<val.length; i++){
total = flt(total)+flt(val[i].score_earned);

View File

@ -69,8 +69,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn) {
}
cur_frm.cscript.clear_sanctioned = function(doc) {
var val = getchildren('Expense Claim Detail', doc.name,
'expense_voucher_details', doc.doctype);
var val = doc.expense_voucher_details || [];
for(var i = 0; i<val.length; i++){
val[i].sanctioned_amount ='';
}

View File

@ -15,7 +15,7 @@ cur_frm.cscript = {
},
make_listing: function(doc) {
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Job Applicant"}),
list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Job Applicant"}),
parent: cur_frm.fields_dict['thread_html'].wrapper,
doc: doc,
recipients: doc.email_id

View File

@ -65,7 +65,7 @@ cur_frm.cscript.d_depends_on_lwp = cur_frm.cscript.d_modified_amount;
// Calculate earning total
// ------------------------------------------------------------------------
var calculate_earning_total = function(doc, dt, dn) {
var tbl = getchildren('Salary Slip Earning', doc.name, 'earning_details', doc.doctype);
var tbl = doc.earning_details || [];
var total_earn = 0;
for(var i = 0; i < tbl.length; i++){
@ -82,7 +82,7 @@ var calculate_earning_total = function(doc, dt, dn) {
// Calculate deduction total
// ------------------------------------------------------------------------
var calculate_ded_total = function(doc, dt, dn) {
var tbl = getchildren('Salary Slip Deduction', doc.name, 'deduction_details', doc.doctype);
var tbl = doc.deduction_details || [];
var total_ded = 0;
for(var i = 0; i < tbl.length; i++){

View File

@ -4,8 +4,8 @@
cur_frm.add_fetch('employee', 'company', 'company');
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);
e_tbl = doc.earning_details || [];
d_tbl = doc.deduction_details || [];
if (e_tbl.length == 0 && d_tbl.length == 0)
return $c_obj(doc,'make_earn_ded_table','', function(r, rt) { refresh_many(['earning_details', 'deduction_details']);});
}
@ -39,8 +39,8 @@ cur_frm.cscript.d_modified_amt = function(doc, cdt, cdn){
}
var calculate_totals = function(doc, cdt, cdn) {
var tbl1 = getchildren('Salary Structure Earning', doc.name, 'earning_details', doc.doctype);
var tbl2 = getchildren('Salary Structure Deduction', doc.name, 'deduction_details', doc.doctype);
var tbl1 = doc.earning_details || [];
var tbl2 = doc.deduction_details || [];
var total_earn = 0; var total_ded = 0;
for(var i = 0; i < tbl1.length; i++){

View File

@ -34,7 +34,7 @@ cur_frm.cscript.operation_no = function(doc, cdt, cdn) {
}
var set_operation_no = function(doc) {
var op_table = getchildren('BOM Operation', doc.name, 'bom_operations');
var op_table = doc.bom_operations || [];
var operations = [];
for (var i=0, j=op_table.length; i<j; i++) {
@ -45,7 +45,7 @@ var set_operation_no = function(doc) {
frappe.meta.get_docfield("BOM Item", "operation_no",
cur_frm.docname).options = operations.join("\n");
$.each(getchildren("BOM Item", doc.name, "bom_materials"), function(i, v) {
$.each(doc.bom_materials || [], function(i, v) {
if(!inList(operations, cstr(v.operation_no))) v.operation_no = null;
});
@ -132,7 +132,7 @@ cur_frm.cscript.rate = function(doc, cdt, cdn) {
}
var calculate_op_cost = function(doc) {
var op = getchildren('BOM Operation', doc.name, 'bom_operations');
var op = doc.bom_operations || [];
total_op_cost = 0;
for(var i=0;i<op.length;i++) {
op_cost = flt(flt(op[i].hour_rate) * flt(op[i].time_in_mins) / 60, 2);
@ -144,7 +144,7 @@ var calculate_op_cost = function(doc) {
}
var calculate_rm_cost = function(doc) {
var rm = getchildren('BOM Item', doc.name, 'bom_materials');
var rm = doc.bom_materials || [];
total_rm_cost = 0;
for(var i=0;i<rm.length;i++) {
amt = flt(rm[i].rate) * flt(rm[i].qty);

View File

@ -39,7 +39,7 @@ erpnext.stock.StockController = frappe.ui.form.Controller.extend({
copy_account_in_all_row: function(doc, dt, dn, fieldname) {
var d = locals[dt][dn];
if(d[fieldname]){
var cl = getchildren(this.frm.cscript.tname, doc.name, this.frm.cscript.fname, doc.doctype);
var cl = doc[this.frm.cscript.fname] || [];
for(var i = 0; i < cl.length; i++) {
if(!cl[i][fieldname]) cl[i][fieldname] = d[fieldname];
}

View File

@ -113,7 +113,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
item_code: function(doc, cdt, cdn) {
var me = this;
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.item_code || item.barcode || item.serial_no) {
if(!this.validate_company_and_party()) {
cur_frm.fields_dict[me.frm.cscript.fname].grid.grid_rows[item.idx - 1].remove();
@ -156,7 +156,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
serial_no: function(doc, cdt, cdn) {
var me = this;
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if (item.serial_no) {
if (!item.item_code) {
@ -262,7 +262,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
get_exchange_rate: function(from_currency, to_currency, callback) {
var exchange_name = from_currency + "-" + to_currency;
frappe.model.with_doc("Currency Exchange", exchange_name, function(name) {
var exchange_doc = frappe.model.get_doc("Currency Exchange", exchange_name);
var exchange_doc = frappe.get_doc("Currency Exchange", exchange_name);
callback(exchange_doc ? flt(exchange_doc.exchange_rate) : 0);
});
},
@ -304,7 +304,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
},
row_id: function(doc, cdt, cdn) {
var tax = frappe.model.get_doc(cdt, cdn);
var tax = frappe.get_doc(cdt, cdn);
try {
this.validate_on_previous_row(tax);
this.calculate_taxes_and_totals();
@ -339,7 +339,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
},
included_in_print_rate: function(doc, cdt, cdn) {
var tax = frappe.model.get_doc(cdt, cdn);
var tax = frappe.get_doc(cdt, cdn);
try {
this.validate_on_previous_row(tax);
this.validate_inclusive_tax(tax);

View File

@ -7,7 +7,7 @@ $.extend(erpnext, {
if(!company && cur_frm)
company = cur_frm.doc.company;
if(company)
return frappe.model.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency;
return frappe.get_doc(":Company", company).default_currency || frappe.boot.sysdefaults.currency;
else
return frappe.boot.sysdefaults.currency;
},

View File

@ -41,7 +41,7 @@ erpnext.LeadController = frappe.ui.form.Controller.extend({
}
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"parenttype": "Lead", "parent":this.frm.doc.name}),
list: frappe.get_list("Communication", {"parenttype": "Lead", "parent":this.frm.doc.name}),
parent: this.frm.fields_dict.communication_html.wrapper,
doc: this.frm.doc,
recipients: this.frm.doc.email_id

View File

@ -30,7 +30,7 @@ erpnext.selling.Opportunity = frappe.ui.form.Controller.extend({
if(!this.frm.doc.__islocal) {
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"opportunity": this.frm.doc.name}),
list: frappe.get_list("Communication", {"opportunity": this.frm.doc.name}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: this.frm.doc,
recipients: this.frm.doc.contact_email

View File

@ -55,7 +55,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
if (!doc.__islocal) {
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Quotation"}),
list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Quotation"}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
recipients: doc.contact_email

View File

@ -86,7 +86,7 @@ erpnext.selling.SalesOrderController = erpnext.selling.SellingController.extend(
},
warehouse: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.item_code && item.warehouse) {
return this.frm.call({
method: "erpnext.selling.utils.get_available_qty",

View File

@ -70,7 +70,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
if(this.frm.fields_dict[this.fname].grid.get_field('batch_no')) {
this.frm.set_query("batch_no", this.fname, function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(!item.item_code) {
frappe.throw(frappe._("Please enter Item Code to get batch no"));
} else {
@ -128,7 +128,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
price_list_rate: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["price_list_rate", "discount_percentage"]);
item.rate = flt(item.price_list_rate * (1 - item.discount_percentage / 100.0),
@ -138,7 +138,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
discount_percentage: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(!item.price_list_rate) {
item.discount_percentage = 0.0;
} else {
@ -147,7 +147,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
rate: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
if(item.price_list_rate) {
@ -188,7 +188,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
allocated_percentage: function(doc, cdt, cdn) {
var sales_person = frappe.model.get_doc(cdt, cdn);
var sales_person = frappe.get_doc(cdt, cdn);
if(sales_person.allocated_percentage) {
sales_person.allocated_percentage = flt(sales_person.allocated_percentage,
@ -203,7 +203,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
},
warehouse: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
if(item.item_code && item.warehouse) {
return this.frm.call({
method: "erpnext.selling.utils.get_available_qty",
@ -565,7 +565,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
// Help for Sales BOM items
var set_sales_bom_help = function(doc) {
if(!cur_frm.fields_dict.packing_list) return;
if (getchildren('Packed Item', doc.name, 'packing_details').length) {
if ((doc.packing_details || []).length) {
$(cur_frm.fields_dict.packing_list.row.wrapper).toggle(true);
if (inList(['Delivery Note', 'Sales Invoice'], doc.doctype)) {

View File

@ -166,7 +166,7 @@ cur_frm.pformat.sales_order_no= function(doc, cdt, cdn){
out ='';
var cl = getchildren('Delivery Note Item',doc.name,'delivery_note_details');
var cl = doc.delivery_note_details || [];
// outer table
var out='<div><table class="noborder" style="width:100%"><tr><td style="width: 50%"></td><td>';
@ -204,7 +204,7 @@ if (sys_defaults.auto_accounting_for_stock) {
cur_frm.cscript.expense_account = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.expense_account) {
var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype);
var cl = doc[cur_frm.cscript.fname] || [];
for(var i = 0; i < cl.length; i++){
if(!cl[i].expense_account) cl[i].expense_account = d.expense_account;
}
@ -227,7 +227,7 @@ if (sys_defaults.auto_accounting_for_stock) {
cur_frm.cscript.cost_center = function(doc, cdt, cdn){
var d = locals[cdt][cdn];
if(d.cost_center) {
var cl = getchildren('Delivery Note Item', doc.name, cur_frm.cscript.fname, doc.doctype);
var cl = doc[cur_frm.cscript.fname] || [];
for(var i = 0; i < cl.length; i++){
if(!cl[i].cost_center) cl[i].cost_center = d.cost_center;
}

View File

@ -59,7 +59,7 @@ cur_frm.cscript.validate_case_nos = function(doc) {
cur_frm.cscript.validate_calculate_item_details = function(doc) {
doc = locals[doc.doctype][doc.name];
var ps_detail = getchildren('Packing Slip Item', doc.name, 'item_details');
var ps_detail = doc.item_details || [];
cur_frm.cscript.validate_duplicate_items(doc, ps_detail);
cur_frm.cscript.calc_net_total_pkg(doc, ps_detail);

View File

@ -47,7 +47,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
},
received_qty: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
item.qty = (item.qty < item.received_qty) ? item.qty : item.received_qty;
@ -55,7 +55,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
},
qty: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["qty", "received_qty"]);
if(!(item.received_qty || item.rejected_qty) && item.qty) {
@ -74,7 +74,7 @@ erpnext.stock.PurchaseReceiptController = erpnext.buying.BuyingController.extend
},
rejected_qty: function(doc, cdt, cdn) {
var item = frappe.model.get_doc(cdt, cdn);
var item = frappe.get_doc(cdt, cdn);
frappe.model.round_floats_in(item, ["received_qty", "rejected_qty"]);
if(item.rejected_qty > item.received_qty) {

View File

@ -105,9 +105,9 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
callback: function(r) {
if (!r.exc) {
for(d in getchildren('Stock Entry Detail', me.frm.doc.name, 'mtn_details')) {
$.each(doc.mtn_details || [], function(i, d) {
if(!d.expense_account) d.expense_account = r.message;
}
});
}
}
});
@ -225,7 +225,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
mtn_details_add: function(doc, cdt, cdn) {
var row = frappe.model.get_doc(cdt, cdn);
var row = frappe.get_doc(cdt, cdn);
this.frm.script_manager.copy_from_first_row("mtn_details", row,
["expense_account", "cost_center"]);
@ -388,7 +388,7 @@ cur_frm.cscript.validate = function(doc, cdt, cdn) {
}
cur_frm.cscript.validate_items = function(doc) {
cl = getchildren('Stock Entry Detail', doc.name, 'mtn_details');
cl = doc.mtn_details || [];
if (!cl.length) {
msgprint(frappe._("Item table can not be blank"));
validated = false;

View File

@ -34,7 +34,7 @@ $.extend(cur_frm.cscript, {
make_listing: function(doc) {
var wrapper = cur_frm.fields_dict['thread_html'].wrapper;
var comm_list = frappe.model.get("Communication", {"parent": doc.name, "parenttype":"Support Ticket"})
var comm_list = frappe.get_list("Communication", {"parent": doc.name, "parenttype":"Support Ticket"})
if(!comm_list.length) {
comm_list.push({

View File

@ -5,7 +5,7 @@
cur_frm.cscript.refresh = function(doc) {
cur_frm.communication_view = new frappe.views.CommunicationList({
list: frappe.model.get("Communication", {"parent": doc.name, "parenttype": "Contact"}),
list: frappe.get_list("Communication", {"parent": doc.name, "parenttype": "Contact"}),
parent: cur_frm.fields_dict.communication_html.wrapper,
doc: doc,
recipients: doc.email_id