diff --git a/check_run/public/js/check_run/check_run_quick_entry.js b/check_run/public/js/check_run/check_run_quick_entry.js index 7c1b6240..f11388f3 100644 --- a/check_run/public/js/check_run/check_run_quick_entry.js +++ b/check_run/public/js/check_run/check_run_quick_entry.js @@ -4,7 +4,7 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ init: function (doctype, after_insert) { this._super(doctype, after_insert) }, - render_dialog: function() { + render_dialog: function () { this.mandatory = this.get_fields() this._super() this.dialog.$wrapper.find('.btn-secondary').hide() @@ -28,7 +28,7 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ } this.default_accounts() }, - get_fields: function() { + get_fields: function () { return [ { label: __("Company"), @@ -53,25 +53,24 @@ frappe.ui.form.CheckRunQuickEntryForm = frappe.ui.form.QuickEntryForm.extend({ } ] }, - default_accounts: function() { - const frm = cur_frm - if(frm){ - this.dialog.fields_dict["company"].set_value(frm.doc.company) - this.dialog.fields_dict["pay_to_account"].set_value(frm.doc.pay_to_account) - this.dialog.fields_dict["bank_account"].set_value(frm.doc.bank_account) + default_accounts: function () { + if (frappe.get_route() && frappe.get_route()[0] == 'Form') { + this.dialog.fields_dict["company"] = cur_frm.doc.company + this.dialog.fields_dict["pay_to_account"].set_value(cur_frm.doc.pay_to_account) + this.dialog.fields_dict["bank_account"].set_value(cur_frm.doc.bank_account) } else { let company = this.dialog.fields_dict.company.get_value() frappe.db.get_value('Company', company, 'default_payable_account') - .then(r => { - this.dialog.fields_dict["pay_to_account"].set_value(r.message.default_payable_account) - }) - frappe.db.get_value('Bank Account', {company: company, is_default: 1, is_company_account: 1}, 'name') - .then(r => { - this.dialog.fields_dict["bank_account"].set_value(r.message.name) - }) + .then(r => { + this.dialog.fields_dict["pay_to_account"].set_value(r.message.default_payable_account) + }) + frappe.db.get_value('Bank Account', { company: company, is_default: 1, is_company_account: 1 }, 'name') + .then(r => { + this.dialog.fields_dict["bank_account"].set_value(r.message.name) + }) } }, - register_primary_action: function() { + register_primary_action: function () { const me = this this.dialog.set_primary_action(__('Start Check Run'), () => { let values = me.dialog.get_values()