Skip to content

Commit 697f521

Browse files
committed
feat: use single remark field with custom remark toggle
1 parent c805324 commit 697f521

5 files changed

Lines changed: 39 additions & 14 deletions

File tree

erpnext/accounts/doctype/journal_entry/journal_entry.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ $.extend(erpnext.journal_entry, {
648648
reqd: 1,
649649
default: frm.doc.posting_date,
650650
},
651-
{ fieldtype: "Small Text", fieldname: "user_remark", label: __("User Remark") },
651+
{ fieldtype: "Small Text", fieldname: "remark", label: __("Remark") },
652652
{
653653
fieldtype: "Select",
654654
fieldname: "naming_series",
@@ -665,8 +665,11 @@ $.extend(erpnext.journal_entry, {
665665
var values = dialog.get_values();
666666

667667
frm.set_value("posting_date", values.posting_date);
668-
frm.set_value("user_remark", values.user_remark);
669668
frm.set_value("naming_series", values.naming_series);
669+
if (values.remark) {
670+
frm.set_value("custom_remark", 1);
671+
frm.set_value("remark", values.remark);
672+
}
670673

671674
// clear table is used because there might've been an error while adding child
672675
// and cleanup didn't happen

erpnext/accounts/doctype/journal_entry/journal_entry.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
"from_template",
7979
"title",
8080
"column_break3",
81+
"custom_remark",
8182
"remark",
8283
"mode_of_payment",
8384
"party_not_required"
@@ -202,6 +203,7 @@
202203
{
203204
"fieldname": "user_remark",
204205
"fieldtype": "Small Text",
206+
"hidden": 1,
205207
"label": "User Remark",
206208
"no_copy": 1,
207209
"oldfieldname": "user_remark",
@@ -315,7 +317,7 @@
315317
"no_copy": 1,
316318
"oldfieldname": "remark",
317319
"oldfieldtype": "Small Text",
318-
"read_only": 1
320+
"read_only_depends_on": "eval: !doc.custom_remark"
319321
},
320322
{
321323
"depends_on": "eval:doc.voucher_type== \"Inter Company Journal Entry\"",
@@ -651,6 +653,12 @@
651653
"fieldname": "auto_repeat_section",
652654
"fieldtype": "Section Break",
653655
"label": "Auto Repeat"
656+
},
657+
{
658+
"default": "0",
659+
"fieldname": "custom_remark",
660+
"fieldtype": "Check",
661+
"label": "Custom Remark"
654662
}
655663
],
656664
"icon": "fa fa-file-text",
@@ -665,7 +673,7 @@
665673
"table_fieldname": "payment_entries"
666674
}
667675
],
668-
"modified": "2026-03-09 17:15:26.569327",
676+
"modified": "2026-04-08 14:19:30.870894",
669677
"modified_by": "Administrator",
670678
"module": "Accounts",
671679
"name": "Journal Entry",

erpnext/accounts/doctype/journal_entry/journal_entry.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class JournalEntry(AccountsController):
6262
cheque_no: DF.Data | None
6363
clearance_date: DF.Date | None
6464
company: DF.Link
65+
custom_remark: DF.Check
6566
difference: DF.Currency
6667
due_date: DF.Date | None
6768
finance_book: DF.Link | None
@@ -1024,11 +1025,11 @@ def set_exchange_rate(self):
10241025
def create_remarks(self):
10251026
r = []
10261027

1027-
if self.flags.skip_remarks_creation:
1028+
if self.get("custom_remark"):
10281029
return
10291030

1030-
if self.user_remark:
1031-
r.append(_("Note: {0}").format(self.user_remark))
1031+
if self.flags.skip_remarks_creation:
1032+
return
10321033

10331034
if self.cheque_no:
10341035
if self.cheque_date:
@@ -1136,9 +1137,7 @@ def build_gl_map(self):
11361137

11371138
for d in self.get("accounts"):
11381139
if d.debit or d.credit or (self.voucher_type == "Exchange Gain Or Loss"):
1139-
r = [d.user_remark, self.remark]
1140-
r = [x for x in r if x]
1141-
remarks = "\n".join(r)
1140+
remarks = self.remark
11421141

11431142
row = {
11441143
"account": d.account,
@@ -1571,7 +1570,7 @@ def get_against_jv(
15711570
frappe.qb.from_(JournalEntry)
15721571
.join(JournalEntryAccount)
15731572
.on(JournalEntryAccount.parent == JournalEntry.name)
1574-
.select(JournalEntry.name, JournalEntry.posting_date, JournalEntry.user_remark)
1573+
.select(JournalEntry.name, JournalEntry.posting_date, JournalEntry.remark)
15751574
.where(JournalEntryAccount.account == filters.get("account"))
15761575
.where(JournalEntryAccount.reference_type.isnull() | (JournalEntryAccount.reference_type == ""))
15771576
.where(JournalEntry.docstatus == 1)

erpnext/accounts/doctype/journal_entry/journal_entry_list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
frappe.listview_settings["Journal Entry"] = {
2-
add_fields: ["voucher_type", "posting_date", "total_debit", "company", "user_remark"],
2+
add_fields: ["voucher_type", "posting_date", "total_debit", "company", "remark"],
33
get_indicator: function (doc) {
44
if (doc.docstatus === 1) {
55
return [__(doc.voucher_type), "blue", `voucher_type,=,${doc.voucher_type}`];

erpnext/accounts/doctype/journal_entry/test_journal_entry.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ def test_toggle_debit_credit_if_negative(self):
523523
jv = frappe.new_doc("Journal Entry")
524524
jv.posting_date = nowdate()
525525
jv.company = "_Test Company"
526-
jv.user_remark = "test"
526+
jv.remark = "test"
527527
jv.extend(
528528
"accounts",
529529
[
@@ -592,6 +592,21 @@ def test_pay_to_recd_from(self):
592592

593593
self.assertEqual(jv.pay_to_recd_from, "_Test Receiver 2")
594594

595+
def test_custom_remark(self):
596+
# When custom_remark is enabled, remark should not be auto-overwritten on save
597+
jv = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, save=False)
598+
jv.custom_remark = 1
599+
jv.remark = "My custom remark text"
600+
jv.insert()
601+
self.assertEqual(jv.remark, "My custom remark text")
602+
603+
# When custom_remark is disabled, remark should be auto-generated
604+
jv2 = make_journal_entry("_Test Cash - _TC", "_Test Bank - _TC", 100, save=False)
605+
jv2.custom_remark = 0
606+
jv2.remark = "Should be overwritten"
607+
jv2.insert()
608+
self.assertNotEqual(jv2.remark, "Should be overwritten")
609+
595610
def test_credit_limit_for_customer(self):
596611
customer = make_customer("_Test New Customer")
597612
set_credit_limit("_Test New Customer", "_Test Company", 50)
@@ -620,7 +635,7 @@ def make_journal_entry(
620635
jv = frappe.new_doc("Journal Entry")
621636
jv.posting_date = posting_date or nowdate()
622637
jv.company = company or "_Test Company"
623-
jv.user_remark = "test"
638+
jv.remark = "test"
624639
jv.multi_currency = 1
625640
jv.set(
626641
"accounts",

0 commit comments

Comments
 (0)