From aa355af2cf3d44f7c13df7ffe7f58018f701ae41 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Wed, 26 Mar 2014 18:24:30 +0530 Subject: [PATCH] refactored client side Model and Meta - frappe/frappe#478 --- erpnext/accounts/doctype/account/account.js | 4 ++-- .../budget_distribution.js | 3 +-- .../doctype/cost_center/cost_center.js | 4 ++-- .../journal_voucher/journal_voucher.js | 8 +++---- .../doctype/pos_setting/pos_setting.js | 2 +- .../doctype/sales_invoice/sales_invoice.js | 2 +- .../purchase_common/purchase_common.js | 2 +- .../doctype/purchase_order/purchase_order.js | 6 ++--- erpnext/hr/doctype/employee/employee.js | 2 +- .../hr/doctype/expense_claim/expense_claim.js | 2 +- .../leave_control_panel.js | 2 +- .../doctype/salary_manager/salary_manager.js | 6 ++--- erpnext/hr/doctype/salary_slip/salary_slip.js | 4 ++-- .../salary_structure/salary_structure.js | 2 +- .../production_order/production_order.js | 4 ++-- .../production_planning_tool.js | 4 ++-- .../doctype/time_log_batch/time_log_batch.js | 3 +-- erpnext/public/js/transaction.js | 23 ++++--------------- erpnext/public/js/utils.js | 3 +-- .../doctype/sales_order/sales_order.js | 4 ++-- erpnext/selling/sales_common.js | 9 ++++---- .../contact_control/contact_control.js | 2 +- .../doctype/email_digest/email_digest.js | 6 ++--- .../global_defaults/global_defaults.js | 2 +- .../doctype/naming_series/naming_series.js | 2 +- .../notification_control.js | 2 +- .../doctype/delivery_note/delivery_note.js | 3 +-- erpnext/stock/doctype/item/item.js | 3 +-- .../material_request/material_request.js | 6 ++--- .../maintenance_schedule.js | 3 +-- .../support/doctype/newsletter/newsletter.js | 2 +- 31 files changed, 53 insertions(+), 77 deletions(-) diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js index 2577ccf88b..f4f2b8a795 100644 --- a/erpnext/accounts/doctype/account/account.js +++ b/erpnext/accounts/doctype/account/account.js @@ -87,7 +87,7 @@ cur_frm.cscript.add_toolbar_buttons = function(doc) { } cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } @@ -95,7 +95,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { } cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } diff --git a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js index c2563741a4..3c11d874a4 100644 --- a/erpnext/accounts/doctype/budget_distribution/budget_distribution.js +++ b/erpnext/accounts/doctype/budget_distribution/budget_distribution.js @@ -7,8 +7,7 @@ cur_frm.cscript.onload = function(doc,cdt,cdn){ refresh_field('budget_distribution_details'); } - return $c('runserverobj',args={'method' : 'get_months', 'docs' : - frappe.model.compress(make_doclist(doc.doctype, doc.name))},callback1); + return $c('runserverobj',args={'method':'get_months', 'docs':doc}, callback1); } } diff --git a/erpnext/accounts/doctype/cost_center/cost_center.js b/erpnext/accounts/doctype/cost_center/cost_center.js index 5c8be10a3f..0cd3a700a4 100644 --- a/erpnext/accounts/doctype/cost_center/cost_center.js +++ b/erpnext/accounts/doctype/cost_center/cost_center.js @@ -70,7 +70,7 @@ cur_frm.cscript.hide_unhide_group_ledger = function(doc) { } cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_group_to_ledger','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } @@ -78,7 +78,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) { } cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) { - return $c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) { + return $c_obj(cur_frm.doc,'convert_ledger_to_group','',function(r,rt) { if(r.message == 1) { cur_frm.refresh(); } diff --git a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js index 1107ba4a6c..fc042ba82c 100644 --- a/erpnext/accounts/doctype/journal_voucher/journal_voucher.js +++ b/erpnext/accounts/doctype/journal_voucher/journal_voucher.js @@ -12,8 +12,7 @@ erpnext.accounts.JournalVoucher = frappe.ui.form.Controller.extend({ load_defaults: function() { if(this.frm.doc.__islocal && this.frm.doc.company) { frappe.model.set_default_values(this.frm.doc); - $.each(frappe.model.get_doclist(this.frm.doc.doctype, - this.frm.doc.name, {parentfield: "entries"}), function(i, jvd) { + $.each(this.frm.doc.entries, function(i, jvd) { frappe.model.set_default_values(jvd); } ); @@ -156,7 +155,7 @@ cur_frm.cscript.credit = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc cur_frm.cscript.get_balance = function(doc,dt,dn) { cur_frm.cscript.update_totals(doc); - return $c_obj(make_doclist(dt,dn), 'get_balance', '', function(r, rt){ + return $c_obj(cur_frm.doc, 'get_balance', '', function(r, rt){ cur_frm.refresh(); }); } @@ -194,8 +193,7 @@ cur_frm.cscript.voucher_type = function(doc, cdt, cdn) { cur_frm.set_df_property("cheque_no", "reqd", doc.voucher_type=="Bank Voucher"); cur_frm.set_df_property("cheque_date", "reqd", doc.voucher_type=="Bank Voucher"); - if(frappe.model.get("Journal Voucher Detail", {"parent":doc.name}).length!==0 // too late - || !doc.company) // too early + if((doc.entries || []).length!==0 || !doc.company) // too early return; var update_jv_details = function(doc, r) { diff --git a/erpnext/accounts/doctype/pos_setting/pos_setting.js b/erpnext/accounts/doctype/pos_setting/pos_setting.js index debfcd9d1a..61c64c2839 100755 --- a/erpnext/accounts/doctype/pos_setting/pos_setting.js +++ b/erpnext/accounts/doctype/pos_setting/pos_setting.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt cur_frm.cscript.onload = function(doc,cdt,cdn){ - return $c_obj(make_doclist(cdt,cdn),'get_series','',function(r,rt){ + return $c_obj(cur_frm.doc, 'get_series','',function(r,rt){ if(r.message) set_field_options('naming_series', r.message); }); diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 42cf8239b2..ebde867655 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -68,7 +68,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte if(cint(doc.update_stock)!=1) { // show Make Delivery Note button only if Sales Invoice is not created from Delivery Note var from_delivery_note = false; - from_delivery_note = cur_frm.get_doclist({parentfield: "entries"}) + from_delivery_note = cur_frm.doc.entries .some(function(item) { return item.delivery_note ? true : false; }); diff --git a/erpnext/buying/doctype/purchase_common/purchase_common.js b/erpnext/buying/doctype/purchase_common/purchase_common.js index 6afcd95b92..14f1843abe 100644 --- a/erpnext/buying/doctype/purchase_common/purchase_common.js +++ b/erpnext/buying/doctype/purchase_common/purchase_common.js @@ -156,7 +156,7 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ project_name: function(doc, cdt, cdn) { var item = frappe.model.get_doc(cdt, cdn); if(item.project_name) { - $.each(frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, {parentfield: this.fname}), + $.each(this.frm.doc[this.fname], function(i, other_item) { if(!other_item.project_name) { other_item.project_name = item.project_name; diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js index 0db8d6fd99..410deeb07d 100644 --- a/erpnext/buying/doctype/purchase_order/purchase_order.js +++ b/erpnext/buying/doctype/purchase_order/purchase_order.js @@ -128,7 +128,7 @@ cur_frm.fields_dict['po_details'].grid.get_field('project_name').get_query = fun } cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){ - return $c_obj(make_doclist(doc.doctype, doc.name), 'get_last_purchase_rate', '', function(r, rt) { + return $c_obj(doc, 'get_last_purchase_rate', '', function(r, rt) { refresh_field(cur_frm.cscript.fname); var doc = locals[cdt][cdn]; cur_frm.cscript.calc_amount( doc, 2); @@ -140,7 +140,7 @@ cur_frm.cscript['Stop Purchase Order'] = function() { var check = confirm(frappe._("Do you really want to STOP ") + doc.name); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs':doc}, function(r,rt) { cur_frm.refresh(); }); } @@ -151,7 +151,7 @@ cur_frm.cscript['Unstop Purchase Order'] = function() { var check = confirm(frappe._("Do you really want to UNSTOP ") + doc.name); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted', 'docs':doc}, function(r,rt) { cur_frm.refresh(); }); } diff --git a/erpnext/hr/doctype/employee/employee.js b/erpnext/hr/doctype/employee/employee.js index c27a4c56a2..88cf7cad68 100644 --- a/erpnext/hr/doctype/employee/employee.js +++ b/erpnext/hr/doctype/employee/employee.js @@ -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" }); } diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 6ff1d3f261..9c54fd6384 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -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; diff --git a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js index be9096c23a..16ede6782d 100644 --- a/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js +++ b/erpnext/hr/doctype/leave_control_panel/leave_control_panel.js @@ -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) { diff --git a/erpnext/hr/doctype/salary_manager/salary_manager.js b/erpnext/hr/doctype/salary_manager/salary_manager.js index 312a06d5c2..3745ee5a94 100644 --- a/erpnext/hr/doctype/salary_manager/salary_manager.js +++ b/erpnext/hr/doctype/salary_manager/salary_manager.js @@ -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); } diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.js b/erpnext/hr/doctype/salary_slip/salary_slip.js index ceab14843e..e8aa6389bb 100644 --- a/erpnext/hr/doctype/salary_slip/salary_slip.js +++ b/erpnext/hr/doctype/salary_slip/salary_slip.js @@ -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); diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.js b/erpnext/hr/doctype/salary_structure/salary_structure.js index 3b90ee6245..fc70455880 100644 --- a/erpnext/hr/doctype/salary_structure/salary_structure.js +++ b/erpnext/hr/doctype/salary_structure/salary_structure.js @@ -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){ diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index 86580d611c..59017319b9 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -70,7 +70,7 @@ cur_frm.cscript['Stop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(frappe._("Do you really want to stop production order: " + doc.name)); if (check) { - return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Stopped', function(r, rt) {cur_frm.refresh();}); + return $c_obj(doc, 'stop_unstop', 'Stopped', function(r, rt) {cur_frm.refresh();}); } } @@ -78,7 +78,7 @@ cur_frm.cscript['Unstop Production Order'] = function() { var doc = cur_frm.doc; var check = confirm(frappe._("Do really want to unstop production order: " + doc.name)); if (check) - return $c_obj(make_doclist(doc.doctype, doc.name), 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); + return $c_obj(doc, 'stop_unstop', 'Unstopped', function(r, rt) {cur_frm.refresh();}); } cur_frm.cscript['Transfer Raw Materials'] = function() { diff --git a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js index fdd4db1d77..fc7abde06c 100644 --- a/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js +++ b/erpnext/manufacturing/doctype/production_planning_tool/production_planning_tool.js @@ -25,9 +25,9 @@ cur_frm.cscript.item_code = function(doc,cdt,cdn) { } cur_frm.cscript.download_materials_required = function(doc, cdt, cdn) { - return $c_obj(make_doclist(cdt, cdn), 'validate_data', '', function(r, rt) { + return $c_obj(doc, 'validate_data', '', function(r, rt) { if (!r['exc']) - $c_obj_csv(make_doclist(cdt, cdn), 'download_raw_materials', '', ''); + $c_obj_csv(doc, 'download_raw_materials', '', ''); }); } diff --git a/erpnext/projects/doctype/time_log_batch/time_log_batch.js b/erpnext/projects/doctype/time_log_batch/time_log_batch.js index 7aa3e16097..7f3a17e6ef 100644 --- a/erpnext/projects/doctype/time_log_batch/time_log_batch.js +++ b/erpnext/projects/doctype/time_log_batch/time_log_batch.js @@ -30,9 +30,8 @@ $.extend(cur_frm.cscript, { } }, make_invoice: function() { - var doc = cur_frm.doc; frappe.model.map({ - source: frappe.model.get_doclist(doc.doctype, doc.name), + source: cur_frm.doc, target: "Sales Invoice" }); } diff --git a/erpnext/public/js/transaction.js b/erpnext/public/js/transaction.js index 2f89470b59..22c3c3a782 100644 --- a/erpnext/public/js/transaction.js +++ b/erpnext/public/js/transaction.js @@ -46,7 +46,6 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ freeze: true, callback: function(r) { // remove this call when using client side mapper - me.set_default_values(); me.set_dynamic_labels(); me.calculate_taxes_and_totals(); } @@ -192,18 +191,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ validate: function() { this.calculate_taxes_and_totals(); }, - - set_default_values: function() { - $.each(frappe.model.get_doclist(this.frm.doctype, this.frm.docname), function(i, doc) { - var updated = frappe.model.set_default_values(doc); - if(doc.parentfield) { - refresh_field(doc.parentfield); - } else { - refresh_field(updated); - } - }); - }, - + company: function() { if(this.frm.doc.company && this.frm.fields_dict.currency) { var company_currency = this.get_company_currency(); @@ -517,13 +505,11 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ }, get_item_doclist: function() { - return frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: this.fname}); + return this.frm.doc[this.fname] || []; }, get_tax_doclist: function() { - return frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: this.other_fname}); + return this.frm.doc[this.other_fname] || []; }, validate_conversion_rate: function() { @@ -716,8 +702,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({ calculate_total_advance: function(parenttype, advance_parentfield) { if(this.frm.doc.doctype == parenttype && this.frm.doc.docstatus < 2) { - var advance_doclist = frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: advance_parentfield}); + var advance_doclist = this.frm.doc[advance_parentfield] || []; this.frm.doc.total_advance = flt(frappe.utils.sum( $.map(advance_doclist, function(adv) { return adv.allocated_amount }) ), precision("total_advance")); diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index c5d3e0b729..9f7f278d95 100644 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -29,8 +29,7 @@ $.extend(erpnext, { }, add_applicable_territory: function() { - if(cur_frm.doc.__islocal && - frappe.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name).length === 1) { + if(cur_frm.doc.__islocal && (cur_frm.doc.valid_for_territories || []).length===0) { var default_territory = frappe.defaults.get_user_default("territory"); if(default_territory) { var territory = frappe.model.add_child(cur_frm.doc, "Applicable Territory", diff --git a/erpnext/selling/doctype/sales_order/sales_order.js b/erpnext/selling/doctype/sales_order/sales_order.js index 0a3ca99bb0..727cca8544 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.js +++ b/erpnext/selling/doctype/sales_order/sales_order.js @@ -162,7 +162,7 @@ cur_frm.cscript['Stop Sales Order'] = function() { if (check) { return $c('runserverobj', { 'method':'stop_sales_order', - 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name)) + 'docs': doc }, function(r,rt) { cur_frm.refresh(); }); @@ -177,7 +177,7 @@ cur_frm.cscript['Unstop Sales Order'] = function() { if (check) { return $c('runserverobj', { 'method':'unstop_sales_order', - 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name)) + 'docs': doc }, function(r,rt) { cur_frm.refresh(); }); diff --git a/erpnext/selling/sales_common.js b/erpnext/selling/sales_common.js index 1dbbbfe2a1..6859567df4 100644 --- a/erpnext/selling/sales_common.js +++ b/erpnext/selling/sales_common.js @@ -98,7 +98,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ this.frm.toggle_display("customer_name", (this.frm.doc.customer_name && this.frm.doc.customer_name!==this.frm.doc.customer)); if(this.frm.fields_dict.packing_details) { - var packing_list_exists = this.frm.get_doclist({parentfield: "packing_details"}).length; + var packing_list_exists = (this.frm.doc.packing_details || []).length; this.frm.toggle_display("packing_list", packing_list_exists ? true : false); } }, @@ -434,8 +434,7 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ calculate_contribution: function() { var me = this; - $.each(frappe.model.get_doclist(this.frm.doc.doctype, this.frm.doc.name, - {parentfield: "sales_team"}), function(i, sales_person) { + $.each(this.frm.doc.doctype.sales_team || [], function(i, sales_person) { frappe.model.round_floats_in(sales_person); if(sales_person.allocated_percentage) { sales_person.allocated_amount = flt( @@ -545,8 +544,8 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({ // toggle columns var item_grid = this.frm.fields_dict[this.fname].grid; var show = (this.frm.doc.currency != company_currency) || - (frappe.model.get_doclist(cur_frm.doctype, cur_frm.docname, - {parentfield: "other_charges", included_in_print_rate: 1}).length); + (cur_frm.doc.other_charges.filter( + function(d) { return d.included_in_print_rate===1}).length); $.each(["base_rate", "base_price_list_rate", "base_amount"], function(i, fname) { if(frappe.meta.get_docfield(item_grid.doctype, fname)) diff --git a/erpnext/setup/doctype/contact_control/contact_control.js b/erpnext/setup/doctype/contact_control/contact_control.js index f28e3a0972..743bedd1dc 100755 --- a/erpnext/setup/doctype/contact_control/contact_control.js +++ b/erpnext/setup/doctype/contact_control/contact_control.js @@ -2,7 +2,7 @@ // License: GNU General Public License v3. See license.txt cur_frm.cscript.get_states=function(doc, dt, dn) { - return $c('runserverobj', args={'method': 'check_state', 'docs':frappe.model.compress(make_doclist(doc.doctype, doc.name))}, + return $c('runserverobj', args={'method': 'check_state', 'docs':doc}, function(r, rt) { if(r.message) set_field_options('state', r.message); diff --git a/erpnext/setup/doctype/email_digest/email_digest.js b/erpnext/setup/doctype/email_digest/email_digest.js index 875061b1b2..51f6231c29 100644 --- a/erpnext/setup/doctype/email_digest/email_digest.js +++ b/erpnext/setup/doctype/email_digest/email_digest.js @@ -9,7 +9,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.add_custom_button(frappe._('View Now'), function() { doc = locals[dt][dn]; if(doc.__unsaved != 1) { - return $c_obj(make_doclist(dt, dn), 'get_digest_msg', '', function(r, rt) { + return $c_obj(doc, 'get_digest_msg', '', function(r, rt) { if(r.exc) { msgprint(err_msg); console.log(r.exc); @@ -32,7 +32,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.add_custom_button(frappe._('Send Now'), function() { doc = locals[dt][dn]; if(doc.__unsaved != 1) { - return $c_obj(make_doclist(dt, dn), 'send', '', function(r, rt) { + return $c_obj(doc, 'send', '', function(r, rt) { if(r.exc) { msgprint(err_msg); console.log(r.exc); @@ -49,7 +49,7 @@ cur_frm.cscript.refresh = function(doc, dt, dn) { cur_frm.cscript.addremove_recipients = function(doc, dt, dn) { // Get user list - return $c_obj(make_doclist(dt, dn), 'get_users', '', function(r, rt) { + return $c_obj(doc, 'get_users', '', function(r, rt) { if(r.exc) { msgprint(r.exc); } else { diff --git a/erpnext/setup/doctype/global_defaults/global_defaults.js b/erpnext/setup/doctype/global_defaults/global_defaults.js index 4b378b3d7e..85d718ae79 100644 --- a/erpnext/setup/doctype/global_defaults/global_defaults.js +++ b/erpnext/setup/doctype/global_defaults/global_defaults.js @@ -18,7 +18,7 @@ $.extend(cur_frm.cscript, { }, validate: function(doc, cdt, cdn) { - return $c_obj(make_doclist(cdt, cdn), 'get_defaults', '', function(r, rt){ + return $c_obj(doc, 'get_defaults', '', function(r, rt){ sys_defaults = r.message; }); }, diff --git a/erpnext/setup/doctype/naming_series/naming_series.js b/erpnext/setup/doctype/naming_series/naming_series.js index 4f6a4c92c0..b9b94ca823 100644 --- a/erpnext/setup/doctype/naming_series/naming_series.js +++ b/erpnext/setup/doctype/naming_series/naming_series.js @@ -29,7 +29,7 @@ cur_frm.cscript.select_doc_for_series = function(doc, cdt, cdn) { } if(doc.select_doc_for_series) - return $c_obj(make_doclist(doc.doctype, doc.name),'get_options','',callback); + return $c_obj(doc,'get_options','',callback); } cur_frm.cscript.update = function() { diff --git a/erpnext/setup/doctype/notification_control/notification_control.js b/erpnext/setup/doctype/notification_control/notification_control.js index 9d26496d87..19660b8f7f 100644 --- a/erpnext/setup/doctype/notification_control/notification_control.js +++ b/erpnext/setup/doctype/notification_control/notification_control.js @@ -8,6 +8,6 @@ cur_frm.cscript.select_transaction = function(doc, cdt, cdn) { doc.custom_message = r.message; refresh_field('custom_message'); } - return $c_obj(make_doclist(cdt, cdn),'get_message',doc.select_transaction, callback) + return $c_obj(doc,'get_message',doc.select_transaction, callback) } } diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.js b/erpnext/stock/doctype/delivery_note/delivery_note.js index 371c093a2a..3a9ef8ddc0 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.js +++ b/erpnext/stock/doctype/delivery_note/delivery_note.js @@ -20,8 +20,7 @@ erpnext.stock.DeliveryNoteController = erpnext.selling.SellingController.extend( if(!doc.__billing_complete && doc.docstatus==1) { // show Make Invoice button only if Delivery Note is not created from Sales Invoice var from_sales_invoice = false; - from_sales_invoice = cur_frm.get_doclist({parentfield: "delivery_note_details"}) - .some(function(item) { + from_sales_invoice = cur_frm.doc.delivery_note_details.some(function(item) { return item.against_sales_invoice ? true : false; }); diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js index 3cae599255..b797420bdb 100644 --- a/erpnext/stock/doctype/item/item.js +++ b/erpnext/stock/doctype/item/item.js @@ -151,8 +151,7 @@ cur_frm.fields_dict.item_supplier_details.grid.get_field("supplier").get_query = cur_frm.cscript.copy_from_item_group = function(doc) { frappe.model.with_doc("Item Group", doc.item_group, function() { - $.each(frappe.model.get("Item Website Specification", {parent:doc.item_group}), - function(i, d) { + $.each((doc.item_website_specifications || []), function(i, d) { var n = frappe.model.add_child(doc, "Item Website Specification", "item_website_specifications"); n.label = d.label; diff --git a/erpnext/stock/doctype/material_request/material_request.js b/erpnext/stock/doctype/material_request/material_request.js index c83077530c..081469b103 100644 --- a/erpnext/stock/doctype/material_request/material_request.js +++ b/erpnext/stock/doctype/material_request/material_request.js @@ -80,7 +80,7 @@ erpnext.buying.MaterialRequestController = erpnext.buying.BuyingController.exten schedule_date: function(doc, cdt, cdn) { var val = locals[cdt][cdn].schedule_date; if(val) { - $.each(frappe.model.get("Material Request Item", { parent: cur_frm.doc.name }), function(i, d) { + $.each((doc.indent_details || []), function(i, d) { if(!d.schedule_date) { d.schedule_date = val; } @@ -172,7 +172,7 @@ cur_frm.cscript['Stop Material Request'] = function() { var check = confirm(frappe._("Do you really want to STOP this Material Request?")); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Stopped', 'docs': doc}, function(r,rt) { cur_frm.refresh(); }); } @@ -183,7 +183,7 @@ cur_frm.cscript['Unstop Material Request'] = function(){ var check = confirm(frappe._("Do you really want to UNSTOP this Material Request?")); if (check) { - return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': frappe.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt) { + return $c('runserverobj', args={'method':'update_status', 'arg': 'Submitted','docs': doc}, function(r,rt) { cur_frm.refresh(); }); } diff --git a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js index 328ca1d82c..c6ac73c0f7 100644 --- a/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js +++ b/erpnext/support/doctype/maintenance_schedule/maintenance_schedule.js @@ -94,8 +94,7 @@ cur_frm.cscript.periodicity = function(doc, cdt, cdn){ cur_frm.cscript.generate_schedule = function(doc, cdt, cdn) { if (!doc.__islocal) { - return $c('runserverobj', args={'method':'generate_schedule', - 'docs':frappe.model.compress(make_doclist(cdt,cdn))}, + return $c('runserverobj', args={'method':'generate_schedule', 'docs':doc}, function(r, rt) { refresh_field('maintenance_schedule_detail'); }); diff --git a/erpnext/support/doctype/newsletter/newsletter.js b/erpnext/support/doctype/newsletter/newsletter.js index dfa9af9a2e..5c88692c91 100644 --- a/erpnext/support/doctype/newsletter/newsletter.js +++ b/erpnext/support/doctype/newsletter/newsletter.js @@ -17,7 +17,7 @@ cur_frm.cscript.refresh = function(doc) { if(!doc.__islocal && !cint(doc.email_sent) && !doc.__unsaved && inList(frappe.boot.user.can_write, doc.doctype)) { cur_frm.add_custom_button(frappe._('Send'), function() { - return $c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) { + return $c_obj(doc, 'send_emails', '', function(r) { cur_frm.refresh(); }); })