From 1958749382080f0698fde18c5980e87d2b3790f4 Mon Sep 17 00:00:00 2001 From: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com> Date: Mon, 6 Apr 2020 10:21:50 +0530 Subject: [PATCH] fix(minor): Minor anti pattern fixes in Exchange rate revaluation doctype (#21147) * fix(minor): Minor anti pattern fixes in Exchange rate revaluation doctype * fix: Codacy --- .../exchange_rate_revaluation.js | 14 +++----------- .../exchange_rate_revaluation_dashboard.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js index 0d5456ece6..1092f4c8f1 100644 --- a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation.js @@ -30,18 +30,10 @@ frappe.ui.form.on('Exchange Rate Revaluation', { frm.doc.accounts.forEach(d=> { total_amt = total_amt + d['new_balance_in_base_currency']; }); - if(total_amt === r.sum) { - frm.add_custom_button(__("Journal Entry"), function(){ - frappe.route_options = { - 'reference_type': 'Exchange Rate Revaluation', - 'reference_name': frm.doc.name - }; - frappe.set_route("List", "Journal Entry"); - }, __("View")); - } else { - frm.add_custom_button(__('Create Journal Entry'), function() { + if(total_amt !== r.sum) { + frm.add_custom_button(__('Journal Entry'), function() { return frm.events.make_jv(frm); - }); + }, __('Create')); } }, 'Journal Entry'); } diff --git a/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py new file mode 100644 index 0000000000..b5cfa04ed6 --- /dev/null +++ b/erpnext/accounts/doctype/exchange_rate_revaluation/exchange_rate_revaluation_dashboard.py @@ -0,0 +1,11 @@ +from __future__ import unicode_literals + +def get_data(): + return { + 'fieldname': 'reference_name', + 'transactions': [ + { + 'items': ['Journal Entry'] + } + ] + }