From 0e1c27a362c6107d877a270bbe9f0a4e56ca82a8 Mon Sep 17 00:00:00 2001 From: John Kelley Date: Thu, 7 Jul 2022 11:11:13 -0600 Subject: [PATCH] fixes: check run table save and render on save --- check_run/check_run/doctype/check_run/check_run.js | 3 +-- check_run/check_run/doctype/check_run/check_run.json | 9 ++++++++- check_run/check_run/doctype/check_run/check_run.py | 6 +++--- check_run/public/js/check_run/check_run.js | 10 ++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/check_run/check_run/doctype/check_run/check_run.js b/check_run/check_run/doctype/check_run/check_run.js index cc41d85a..8ffb157f 100644 --- a/check_run/check_run/doctype/check_run/check_run.js +++ b/check_run/check_run/doctype/check_run/check_run.js @@ -92,7 +92,6 @@ function set_queries(frm){ function get_entries(frm){ frappe.xcall('check_run.check_run.doctype.check_run.check_run.get_entries', { doc: frm.doc} ).then((r) => { - console.log("TRANSACTIONS", frm.transactions.length, r.transactions.length) frm.transactions = r.transactions frm.modes_of_payment = r.modes_of_payment check_run.mount_table(frm) @@ -211,4 +210,4 @@ function reprint_checks(frm){ d.hide() }) d.show() -} \ No newline at end of file +} diff --git a/check_run/check_run/doctype/check_run/check_run.json b/check_run/check_run/doctype/check_run/check_run.json index 8a7d918f..274e17ff 100644 --- a/check_run/check_run/doctype/check_run/check_run.json +++ b/check_run/check_run/doctype/check_run/check_run.json @@ -22,6 +22,7 @@ "pay_to_account", "section_break_9", "check_run_table", + "html_15", "transactions", "amended_from", "print_count", @@ -143,13 +144,19 @@ "options": "Draft\nSubmitted\nConfirm Print\nPrinted" }, { + "default": "", "fieldname": "check_run_table", "fieldtype": "HTML" + }, + { + "default": "", + "fieldname": "html_15", + "fieldtype": "HTML" } ], "is_submittable": 1, "links": [], - "modified": "2022-07-04 05:50:56.817736", + "modified": "2022-07-07 11:07:40.783065", "modified_by": "Administrator", "module": "Check Run", "name": "Check Run", diff --git a/check_run/check_run/doctype/check_run/check_run.py b/check_run/check_run/doctype/check_run/check_run.py index bf9dc9ce..8e15737a 100644 --- a/check_run/check_run/doctype/check_run/check_run.py +++ b/check_run/check_run/doctype/check_run/check_run.py @@ -277,8 +277,8 @@ def get_entries(doc): if frappe.db.exists('Check Run', doc.name): db_doc = frappe.get_doc('Check Run', doc.name) print("dirty", db_doc.is_dirty(doc)) - if db_doc.docstatus > 0 or not db_doc.is_dirty(doc): - return {'transactions': json.loads(frappe.get_value('Check Run', doc.name, 'transactions')), 'modes_of_payment': modes_of_payment} + if db_doc.transactions and json.loads(db_doc.transactions): + return {'transactions': json.loads(db_doc.transactions), 'modes_of_payment': modes_of_payment} transactions = frappe.db.sql(""" ( SELECT @@ -319,7 +319,7 @@ def get_entries(doc): AND `tabExpense Claim`.payable_account = %(pay_to_account)s ) UNION ( - SELECT + SELECT 'Journal Entry' AS doctype, `tabJournal Entry`.name, `tabJournal Entry`.name AS ref_number, diff --git a/check_run/public/js/check_run/check_run.js b/check_run/public/js/check_run/check_run.js index 4b3e9d49..792bd711 100644 --- a/check_run/public/js/check_run/check_run.js +++ b/check_run/public/js/check_run/check_run.js @@ -7,9 +7,7 @@ check_run.mount_table = frm => { console.log('existing vue app') frm.check_run_state.docstatus = frm.doc.docstatus frm.check_run_state.transactions = frm.transactions - frm.check_run_state.modes_of_payment = state.modes_of_payment - frm.check_run_state.state = state - frm.$check_run.$forceUpdate() + frm.check_run_state.modes_of_payment = frm.check_run_state.modes_of_payment return } const state = Vue.observable({ @@ -21,7 +19,7 @@ check_run.mount_table = frm => { }) frm.check_run_state = state - // if (frm.$check_run instanceof Vue) { return } + frm.$check_run = new window.Vue({ el: $(frm.fields_dict['check_run_table'].wrapper).get(0), render: h => h( @@ -31,7 +29,7 @@ check_run.mount_table = frm => { modes_of_payment: state.modes_of_payment, // populate modes_of_payment select. doesn't get updated docstatus: state.docstatus, // used to conditionally render column inputs based on submission status. doesn't get updated state: state - } + } }) }) -} \ No newline at end of file +}