Skip to content

Commit

Permalink
fix: don't trigger settings change for check run creation
Browse files Browse the repository at this point in the history
  • Loading branch information
agritheory committed Aug 29, 2022
1 parent 6dca9fa commit a672f46
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions check_run/public/js/check_run/check_run_quick_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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"),
Expand All @@ -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()
Expand Down

0 comments on commit a672f46

Please sign in to comment.