From 291449b6fbe01013699e89cdb757ab66a98b7f8b Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Thu, 13 Dec 2012 12:53:21 +0530 Subject: [PATCH] refactored javascript models --- .../budget_distribution.js | 2 +- .../journal_voucher/journal_voucher.js | 6 ++-- .../purchase_invoice/purchase_invoice.js | 6 ++-- .../doctype/sales_invoice/sales_invoice.js | 12 ++++---- .../purchase_common/purchase_common.js | 4 +-- .../doctype/purchase_order/purchase_order.js | 12 ++++---- .../purchase_request/purchase_request.js | 12 ++++---- buying/doctype/supplier/supplier.js | 2 +- .../supplier_quotation/supplier_quotation.js | 4 +-- home/page/activity/activity.js | 2 +- hr/doctype/employee/employee.js | 2 +- .../leave_control_panel.js | 2 +- hr/doctype/salary_manager/salary_manager.js | 10 +++---- .../salary_structure/salary_structure.js | 4 +-- .../production_order/production_order.js | 2 +- public/js/gantt_task.js | 2 +- public/js/modules.js | 4 +-- selling/doctype/customer/customer.js | 4 +-- selling/doctype/lead/lead.js | 12 ++++---- selling/doctype/opportunity/opportunity.js | 4 +-- selling/doctype/quotation/quotation.js | 4 +-- selling/doctype/sales_common/sales_common.js | 4 +-- selling/doctype/sales_order/sales_order.js | 28 +++++++++---------- .../contact_control/contact_control.js | 2 +- setup/doctype/sales_partner/sales_partner.js | 2 +- setup/doctype/workflow_rule/workflow_rule.js | 6 ++-- stock/doctype/delivery_note/delivery_note.js | 14 +++++----- .../purchase_receipt/purchase_receipt.js | 8 +++--- .../sales_and_purchase_return_tool.js | 10 +++---- .../doctype/customer_issue/customer_issue.js | 4 +-- .../maintenance_schedule.js | 2 +- .../doctype/support_ticket/support_ticket.js | 6 ---- utilities/page/calendar/calendar.js | 15 +++++----- 33 files changed, 104 insertions(+), 109 deletions(-) diff --git a/accounts/doctype/budget_distribution/budget_distribution.js b/accounts/doctype/budget_distribution/budget_distribution.js index c8bfe11525d..5abd5259996 100644 --- a/accounts/doctype/budget_distribution/budget_distribution.js +++ b/accounts/doctype/budget_distribution/budget_distribution.js @@ -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); } } diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 784a134e5b1..8c60838376e 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -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\ Create a new Task').click(function() { wn.model.with_doctype('Task', function() { - var new_name = LocalDB.create('Task'); + var new_name = wn.model.make_new_doc_and_get_name('Task'); if(project) locals.Task[new_name].project = project; wn.set_route('Form', 'Task', new_name); diff --git a/public/js/modules.js b/public/js/modules.js index 9fa7f30cb1e..7dc8038589a 100644 --- a/public/js/modules.js +++ b/public/js/modules.js @@ -111,7 +111,7 @@ erpnext.module_page.hide_links = function(wrapper) { $(wrapper).find('[href*="List/"]').each(function() { var href = $(this).attr('href'); var dt = href.split('/')[1]; - if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { + if(wn.boot.profile.all_read.indexOf(dt)==-1) { replace_link(this); } }); @@ -128,7 +128,7 @@ erpnext.module_page.hide_links = function(wrapper) { $(wrapper).find('[href*="Form/"]').each(function() { var href = $(this).attr('href'); var dt = href.split('/')[1]; - if(wn.boot.profile.all_read.indexOf(get_label_doctype(dt))==-1) { + if(wn.boot.profile.all_read.indexOf(dt)==-1) { replace_link(this); } }); diff --git a/selling/doctype/customer/customer.js b/selling/doctype/customer/customer.js index d20b0c927d1..845f5434671 100644 --- a/selling/doctype/customer/customer.js +++ b/selling/doctype/customer/customer.js @@ -35,7 +35,7 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn) { doc = locals[doc.doctype][doc.name]; if(!(doc.__islocal && doc.lead_name)) { return; } - 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); } } @@ -89,7 +89,7 @@ cur_frm.cscript.make_contact = function() { parent: cur_frm.fields_dict['contact_html'].wrapper, page_length: 2, custom_new_doc: function(doctype) { - var contact = LocalDB.create('Contact'); + var contact = wn.model.make_new_doc_and_get_name('Contact'); contact = locals['Contact'][contact]; contact.customer = cur_frm.doc.name; contact.customer_name = cur_frm.doc.customer_name; diff --git a/selling/doctype/lead/lead.js b/selling/doctype/lead/lead.js index e4b3a7db580..9dd64de25db 100644 --- a/selling/doctype/lead/lead.js +++ b/selling/doctype/lead/lead.js @@ -83,15 +83,15 @@ cur_frm.cscript.status = function(doc, cdt, cdn){ cur_frm.cscript['Create Customer'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, + $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is already converted to customer"); } else{ - n = createLocal("Customer"); + n = wn.model.make_new_doc_and_get_name("Customer"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Customer"][n]]), + 'docs':wn.model.compress([locals["Customer"][n]]), 'from_doctype':'Lead', 'to_doctype':'Customer', 'from_docname':doc.name, @@ -110,15 +110,15 @@ cur_frm.cscript['Create Customer'] = function(){ // =============================================================== cur_frm.cscript['Create Opportunity'] = function(){ var doc = cur_frm.doc; - $c('runserverobj',args={ 'method':'check_status', 'docs':compress_doclist(make_doclist(doc.doctype, doc.name))}, + $c('runserverobj',args={ 'method':'check_status', 'docs':wn.model.compress(make_doclist(doc.doctype, doc.name))}, function(r,rt){ if(r.message == 'Converted'){ msgprint("This lead is now converted to customer. Please create enquiry on behalf of customer"); } else{ - n = createLocal("Opportunity"); + n = wn.model.make_new_doc_and_get_name("Opportunity"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Opportunity"][n]]), + 'docs':wn.model.compress([locals["Opportunity"][n]]), 'from_doctype':'Lead', 'to_doctype':'Opportunity', 'from_docname':doc.name, diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 2b530ff4a5f..70924835d8a 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -156,9 +156,9 @@ cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = f // Create New Quotation cur_frm.cscript['Create Quotation'] = function(){ - n = createLocal("Quotation"); + n = wn.model.make_new_doc_and_get_name("Quotation"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Quotation"][n]]), + 'docs':wn.model.compress([locals["Quotation"][n]]), 'from_doctype':'Opportunity', 'to_doctype':'Quotation', 'from_docname':cur_frm.docname, diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index 7199132d615..40e15186e7f 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -180,9 +180,9 @@ cur_frm.cscript['Make Sales Order'] = function() { var doc = cur_frm.doc; if (doc.docstatus == 1) { - var n = createLocal("Sales Order"); + var n = wn.model.make_new_doc_and_get_name("Sales Order"); $c('dt_map', args={ - 'docs':compress_doclist([locals["Sales Order"][n]]), + 'docs':wn.model.compress([locals["Sales Order"][n]]), 'from_doctype':'Quotation', 'to_doctype':'Sales Order', 'from_docname':doc.name, diff --git a/selling/doctype/sales_common/sales_common.js b/selling/doctype/sales_common/sales_common.js index c5eed98f716..de56a6c113c 100644 --- a/selling/doctype/sales_common/sales_common.js +++ b/selling/doctype/sales_common/sales_common.js @@ -46,14 +46,14 @@ cur_frm.cscript.load_defaults = function(doc, dt, dn, callback) { if(!cur_frm.doc.__islocal) { 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(cur_frm.cscript.tname, doc.name, cur_frm.cscript.fname); if(!children) { return; } for(var i=0; i