diff --git a/erpnext/accounts/doctype/bank/bank.js b/erpnext/accounts/doctype/bank/bank.js index 49b2b186c4..8c0abc2447 100644 --- a/erpnext/accounts/doctype/bank/bank.js +++ b/erpnext/accounts/doctype/bank/bank.js @@ -42,10 +42,7 @@ let add_fields_to_mapping_table = function (frm) { }); }); - frappe.meta.get_docfield("Bank Transaction Mapping", "bank_transaction_field", - frm.doc.name).options = options; - - frm.fields_dict.bank_transaction_mapping.grid.refresh(); + frm.fields_dict.bank_transaction_mapping.grid.update_docfield_property('frm.fields_dict.bank_transaction_mapping.grid', 'options', options); }; erpnext.integrations.refreshPlaidLink = class refreshPlaidLink { diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 37b03f3f0e..411bd3d6fc 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -327,18 +327,16 @@ erpnext.accounts.JournalEntry = frappe.ui.form.Controller.extend({ }, setup_balance_formatter: function() { - var me = this; - $.each(["balance", "party_balance"], function(i, field) { - var df = frappe.meta.get_docfield("Journal Entry Account", field, me.frm.doc.name); - df.formatter = function(value, df, options, doc) { - var currency = frappe.meta.get_field_currency(df, doc); - var dr_or_cr = value ? ('') : ""; - return "
" - + ((value==null || value==="") ? "" : format_currency(Math.abs(value), currency)) - + " " + dr_or_cr - + "
"; - } - }) + const formatter = function(value, df, options, doc) { + var currency = frappe.meta.get_field_currency(df, doc); + var dr_or_cr = value ? ('') : ""; + return "
" + + ((value==null || value==="") ? "" : format_currency(Math.abs(value), currency)) + + " " + dr_or_cr + + "
"; + } + this.frm.fields_dict.accounts.grid.update_docfield_property('balance', 'formatter', formatter); + this.frm.fields_dict.accounts.grid.update_docfield_property('party_balance', 'formatter', formatter); }, reference_name: function(doc, cdt, cdn) { @@ -431,15 +429,6 @@ cur_frm.cscript.validate = function(doc,cdt,cdn) { cur_frm.cscript.update_totals(doc); } -cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ - if(doc.select_print_heading){ - // print heading - cur_frm.pformat.print_heading = doc.select_print_heading; - } - else - cur_frm.pformat.print_heading = __("Journal Entry"); -} - frappe.ui.form.on("Journal Entry Account", { party: function(frm, cdt, cdn) { var d = frappe.get_doc(cdt, cdn); @@ -511,8 +500,11 @@ $.extend(erpnext.journal_entry, { }; $.each(field_label_map, function (fieldname, label) { - var df = frappe.meta.get_docfield("Journal Entry Account", fieldname, frm.doc.name); - df.label = frm.doc.multi_currency ? (label + " in Account Currency") : label; + frm.fields_dict.accounts.grid.update_docfield_property( + fieldname, + 'label', + frm.doc.multi_currency ? (label + " in Account Currency") : label + ); }) }, diff --git a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js index 6b07197ec1..b693863fb2 100644 --- a/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js +++ b/erpnext/accounts/doctype/payment_reconciliation/payment_reconciliation.js @@ -234,8 +234,9 @@ erpnext.accounts.PaymentReconciliationController = frappe.ui.form.Controller.ext }); if (invoices) { - frappe.meta.get_docfield("Payment Reconciliation Payment", "invoice_number", - me.frm.doc.name).options = "\n" + invoices.join("\n"); + this.frm.fields_dict.payment.grid.update_docfield_property( + 'invoice_number', options, "\n" + invoices.join("\n") + ) $.each(me.frm.doc.payments || [], function(i, p) { if(!in_list(invoices, cstr(p.invoice_number))) p.invoice_number = null; diff --git a/erpnext/accounts/doctype/pos_settings/pos_settings.js b/erpnext/accounts/doctype/pos_settings/pos_settings.js index 8890d59403..4037a927fa 100644 --- a/erpnext/accounts/doctype/pos_settings/pos_settings.js +++ b/erpnext/accounts/doctype/pos_settings/pos_settings.js @@ -16,8 +16,13 @@ frappe.ui.form.on('POS Settings', { } }); - frappe.meta.get_docfield("POS Field", "fieldname", frm.doc.name).options = [""].concat(fields); + frm.fields_dict.invoice_fields.grid.update_docfield_property( + 'fieldname', + 'options', + [""].concat(fields) + ); }); + } }); diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js index 66a8e206a8..e61cde8fd0 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.js @@ -496,15 +496,6 @@ cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, } } -cur_frm.cscript.select_print_heading = function(doc,cdt,cdn){ - if(doc.select_print_heading){ - // print heading - cur_frm.pformat.print_heading = doc.select_print_heading; - } - else - cur_frm.pformat.print_heading = __("Purchase Invoice"); -} - frappe.ui.form.on("Purchase Invoice", { setup: function(frm) { frm.custom_make_buttons = { diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index 26d60389f6..8a42d9e13c 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -1,9 +1,6 @@ // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // License: GNU General Public License v3. See license.txt -// print heading -cur_frm.pformat.print_heading = 'Invoice'; - {% include 'erpnext/selling/sales_common.js' %}; frappe.provide("erpnext.accounts"); diff --git a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.js b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.js index c7074e88d5..f28d32c22c 100644 --- a/erpnext/healthcare/doctype/patient_assessment/patient_assessment.js +++ b/erpnext/healthcare/doctype/patient_assessment/patient_assessment.js @@ -39,11 +39,13 @@ frappe.ui.form.on('Patient Assessment', { }, set_score_range: function(frm) { - let options = []; + let options = ['']; for(let i = frm.doc.scale_min; i <= frm.doc.scale_max; i++) { options.push(i); } - frappe.meta.get_docfield('Patient Assessment Sheet', 'score', frm.doc.name).options = [''].concat(options); + frm.fields_dict.assessment_sheet.grid.update_docfield_property( + 'score', 'options', options + ); }, calculate_total_score: function(frm, cdt, cdn) { @@ -83,4 +85,4 @@ frappe.ui.form.on('Patient Assessment Sheet', { score: function(frm, cdt, cdn) { frm.events.calculate_total_score(frm, cdt, cdn); } -}); \ No newline at end of file +}); diff --git a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.js b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.js index d1f72d625b..3bad65c312 100644 --- a/erpnext/healthcare/doctype/therapy_plan/therapy_plan.js +++ b/erpnext/healthcare/doctype/therapy_plan/therapy_plan.js @@ -58,8 +58,12 @@ frappe.ui.form.on('Therapy Plan', { } if (frm.doc.therapy_plan_template) { - frappe.meta.get_docfield('Therapy Plan Detail', 'therapy_type', frm.doc.name).read_only = 1; - frappe.meta.get_docfield('Therapy Plan Detail', 'no_of_sessions', frm.doc.name).read_only = 1; + frm.fields_dict.therapy_plan_details.grid.update_docfield_property( + 'therapy_type', 'read_only', 1, + ); + frm.fields_dict.therapy_plan_details.grid.update_docfield_property( + 'no_of_sessions', 'read_only', 1 + ); } }, @@ -126,4 +130,4 @@ frappe.ui.form.on('Therapy Plan Detail', { frm.set_value('total_sessions', total); refresh_field('total_sessions'); } -}); \ No newline at end of file +}); diff --git a/erpnext/manufacturing/doctype/routing/routing.js b/erpnext/manufacturing/doctype/routing/routing.js index 9b1a8ca670..032c9cd9a2 100644 --- a/erpnext/manufacturing/doctype/routing/routing.js +++ b/erpnext/manufacturing/doctype/routing/routing.js @@ -11,10 +11,9 @@ frappe.ui.form.on('Routing', { }, display_sequence_id_column: function(frm) { - frappe.meta.get_docfield("BOM Operation", "sequence_id", - frm.doc.name).in_list_view = true; - - frm.fields_dict.operations.grid.refresh(); + frm.fields_dict.operations.grid.update_docfield_property( + 'sequence_id', 'in_list_view', 1 + ); }, calculate_operating_cost: function(frm, child) { @@ -69,4 +68,4 @@ frappe.ui.form.on('BOM Operation', { const d = locals[cdt][cdn]; frm.events.calculate_operating_cost(frm, d); } -}); \ No newline at end of file +}); diff --git a/erpnext/payroll/doctype/salary_structure/salary_structure.js b/erpnext/payroll/doctype/salary_structure/salary_structure.js index 6aa1387363..21e9d81225 100755 --- a/erpnext/payroll/doctype/salary_structure/salary_structure.js +++ b/erpnext/payroll/doctype/salary_structure/salary_structure.js @@ -111,12 +111,17 @@ frappe.ui.form.on('Salary Structure', { frappe.set_route('Form', 'Salary Structure Assignment', doc.name); }); frm.add_custom_button(__("Assign to Employees"),function () { - frm.trigger('assign_to_employees') - }) + frm.trigger('assign_to_employees') + }) } + + // set columns read-only let fields_read_only = ["is_tax_applicable", "is_flexible_benefit", "variable_based_on_taxable_salary"]; fields_read_only.forEach(function(field) { - frappe.meta.get_docfield("Salary Detail", field, frm.doc.name).read_only = 1; + frm.fields_dict.earnings.grid.update_docfield_property( + field, 'read_only', 1); + frm.fields_dict.deductions.grid.update_docfield_property( + field, 'read_only', 1); }); frm.trigger('set_earning_deduction_component'); }, diff --git a/erpnext/portal/doctype/products_settings/products_settings.js b/erpnext/portal/doctype/products_settings/products_settings.js index b68b5d7aa8..2f8b037164 100644 --- a/erpnext/portal/doctype/products_settings/products_settings.js +++ b/erpnext/portal/doctype/products_settings/products_settings.js @@ -10,10 +10,12 @@ frappe.ui.form.on('Products Settings', { df => ['Link', 'Table MultiSelect'].includes(df.fieldtype) && !df.hidden ).map(df => ({ label: df.label, value: df.fieldname })); - const field = frappe.meta.get_docfield("Website Filter Field", "fieldname", frm.docname); - field.fieldtype = 'Select'; - field.options = valid_fields; - frm.fields_dict.filter_fields.grid.refresh(); + frm.fields_dict.filter_fields.grid.update_docfield_property( + 'fieldname', 'fieldtype', 'Select' + ); + frm.fields_dict.filter_fields.grid.update_docfield_property( + 'fieldname', 'options', valid_fields + ); }); } }); diff --git a/erpnext/public/js/controllers/accounts.js b/erpnext/public/js/controllers/accounts.js index 649eb454ac..ceeecb28a2 100644 --- a/erpnext/public/js/controllers/accounts.js +++ b/erpnext/public/js/controllers/accounts.js @@ -276,74 +276,3 @@ erpnext.taxes.set_conditional_mandatory_rate_or_amount = function(grid_row) { } } } - - -// For customizing print -cur_frm.pformat.total = function(doc) { return ''; } -cur_frm.pformat.discount_amount = function(doc) { return ''; } -cur_frm.pformat.grand_total = function(doc) { return ''; } -cur_frm.pformat.rounded_total = function(doc) { return ''; } -cur_frm.pformat.in_words = function(doc) { return ''; } - -cur_frm.pformat.taxes= function(doc){ - //function to make row of table - var make_row = function(title, val, bold, is_negative) { - var bstart = ''; var bend = ''; - return '' + (bold?bstart:'') + title + (bold?bend:'') + '' - + '' + (is_negative ? '- ' : '') - + format_currency(val, doc.currency) + ''; - } - - function print_hide(fieldname) { - var doc_field = frappe.meta.get_docfield(doc.doctype, fieldname, doc.name); - return doc_field.print_hide; - } - - out =''; - if (!doc.print_without_amount) { - var cl = doc.taxes || []; - - // outer table - var out='
'; - - // main table - - out +=''; - - if(!print_hide('total')) { - out += make_row('Total', doc.total, 1); - } - - // Discount Amount on net total - if(!print_hide('discount_amount') && doc.apply_discount_on == "Net Total" && doc.discount_amount) - out += make_row('Discount Amount', doc.discount_amount, 0, 1); - - // add rows - if(cl.length){ - for(var i=0;i'; - } - out += '
'; - } - return out; -} \ No newline at end of file diff --git a/erpnext/setup/doctype/item_group/item_group.js b/erpnext/setup/doctype/item_group/item_group.js index 1413cb2862..885d874720 100644 --- a/erpnext/setup/doctype/item_group/item_group.js +++ b/erpnext/setup/doctype/item_group/item_group.js @@ -61,7 +61,7 @@ frappe.ui.form.on("Item Group", { frappe.set_route("List", "Item", {"item_group": frm.doc.name}); }); } - + frappe.model.with_doctype('Item', () => { const item_meta = frappe.get_meta('Item'); @@ -69,10 +69,12 @@ frappe.ui.form.on("Item Group", { df => ['Link', 'Table MultiSelect'].includes(df.fieldtype) && !df.hidden ).map(df => ({ label: df.label, value: df.fieldname })); - const field = frappe.meta.get_docfield("Website Filter Field", "fieldname", frm.docname); - field.fieldtype = 'Select'; - field.options = valid_fields; - frm.fields_dict.filter_fields.grid.refresh(); + frm.fields_dict.filter_fields.grid.update_docfield_property( + 'fieldname', 'fieldtype', 'Select' + ); + frm.fields_dict.filter_fields.grid.update_docfield_property( + 'fieldname', 'options', valid_fields + ); }); }, diff --git a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js index 24f7e31a0c..e8fb34732f 100644 --- a/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js +++ b/erpnext/stock/doctype/item_variant_settings/item_variant_settings.js @@ -15,8 +15,9 @@ frappe.ui.form.on('Item Variant Settings', { } }); - const child = frappe.meta.get_docfield("Variant Field", "field_name", frm.doc.name); - child.options = allow_fields; + frm.fields_dict.fields.grid.update_docfield_property( + 'field_name', 'options', allow_fields + ); }); } }); diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js index bd14e5f616..40d46852d0 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.js +++ b/erpnext/stock/doctype/packing_slip/packing_slip.js @@ -110,19 +110,4 @@ cur_frm.cscript.calc_net_total_pkg = function(doc, ps_detail) { refresh_many(['net_weight_pkg', 'net_weight_uom', 'gross_weight_uom', 'gross_weight_pkg']); } -var make_row = function(title,val,bold){ - var bstart = ''; var bend = ''; - return ''+(bold?bstart:'')+title+(bold?bend:'')+'' - +''+ val +'' - +'' -} - -cur_frm.pformat.net_weight_pkg= function(doc){ - return '' + make_row('Net Weight', doc.net_weight_pkg) + '
' -} - -cur_frm.pformat.gross_weight_pkg= function(doc){ - return '' + make_row('Gross Weight', doc.gross_weight_pkg) + '
' -} - // TODO: validate gross weight field diff --git a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js index 57cc3504a9..4d1a514c6b 100644 --- a/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js +++ b/erpnext/stock/doctype/purchase_receipt/purchase_receipt.js @@ -248,13 +248,6 @@ cur_frm.fields_dict['items'].grid.get_field('project').get_query = function(doc, } } -cur_frm.cscript.select_print_heading = function(doc, cdt, cdn) { - if(doc.select_print_heading) - cur_frm.pformat.print_heading = doc.select_print_heading; - else - cur_frm.pformat.print_heading = "Purchase Receipt"; -} - cur_frm.fields_dict['select_print_heading'].get_query = function(doc, cdt, cdn) { return { filters: [ diff --git a/erpnext/support/doctype/service_level_agreement/service_level_agreement.js b/erpnext/support/doctype/service_level_agreement/service_level_agreement.js index 5346195a39..00060b9530 100644 --- a/erpnext/support/doctype/service_level_agreement/service_level_agreement.js +++ b/erpnext/support/doctype/service_level_agreement/service_level_agreement.js @@ -10,7 +10,9 @@ frappe.ui.form.on('Service Level Agreement', { let statuses = frappe.meta.get_docfield('Issue', 'status', frm.doc.name).options; statuses = statuses.split('\n'); allow_statuses = statuses.filter((status) => !exclude_statuses.includes(status)); - frappe.meta.get_docfield('Pause SLA On Status', 'status', frm.doc.name).options = [''].concat(allow_statuses); + frm.fields_dict.pause_sla_on.grid.update_docfield_property( + 'status', 'options', [''].concat(allow_statuses) + ); }); } -}); \ No newline at end of file +});