From e6b6bc9597d0ffd02f5da2f981504d0e1c3f4706 Mon Sep 17 00:00:00 2001 From: Charles-Henri Decultot Date: Sat, 23 Mar 2024 14:22:47 +0100 Subject: [PATCH] feat: Option to add an accounting journal in a journal entry template --- .../doctype/journal_entry/journal_entry.js | 3 +- .../journal_entry_template.js | 9 +++++ .../journal_entry_template.json | 13 ++++++- .../journal_entry_template.py | 38 +++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js index 475e95750c..227f7993ee 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.js +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js @@ -248,7 +248,8 @@ frappe.ui.form.on("Journal Entry", { "voucher_type": doc.voucher_type, "naming_series": doc.naming_series, "is_opening": doc.is_opening, - "multi_currency": doc.multi_currency + "multi_currency": doc.multi_currency, + "accounting_journal": doc.accounting_journal, }) update_jv_details(frm.doc, doc.accounts); }); diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js index 846d0f9f1d..71a06c98cc 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.js @@ -17,6 +17,15 @@ frappe.ui.form.on("Journal Entry Template", { }); } }, + setup: function(frm) { + frm.set_query("accounting_journal", function(){ + return { + filters: { + "company": frm.doc.company + } + } + }); + }, refresh: function(frm) { frappe.model.set_default_values(frm.doc); diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json index d7fe6cdde4..6536dfc73c 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.json @@ -10,6 +10,7 @@ "section_break_1", "template_title", "voucher_type", + "accounting_journal", "naming_series", "column_break_3", "company", @@ -83,13 +84,20 @@ "fieldname": "multi_currency", "fieldtype": "Check", "label": "Multi Currency" + }, + { + "fieldname": "accounting_journal", + "fieldtype": "Link", + "label": "Accounting Journal", + "options": "Accounting Journal" } ], "links": [], - "modified": "2020-05-01 18:32:01.420488", + "modified": "2024-03-23 14:18:06.010774", "modified_by": "Administrator", "module": "Accounts", "name": "Journal Entry Template", + "naming_rule": "By fieldname", "owner": "Administrator", "permissions": [ { @@ -129,6 +137,7 @@ "search_fields": "voucher_type, company", "sort_field": "modified", "sort_order": "DESC", + "states": [], "title_field": "template_title", "track_changes": 1 -} \ No newline at end of file +} diff --git a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py index 866e2a3eb9..831c1be6d4 100644 --- a/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py +++ b/erpnext/accounts/doctype/journal_entry_template/journal_entry_template.py @@ -8,6 +8,44 @@ from frappe.utils import cint class JournalEntryTemplate(Document): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.accounts.doctype.journal_entry_template_account.journal_entry_template_account import ( + JournalEntryTemplateAccount, + ) + + accounting_journal: DF.Link | None + accounts: DF.Table[JournalEntryTemplateAccount] + company: DF.Link + is_opening: DF.Literal["No", "Yes"] + multi_currency: DF.Check + naming_series: DF.Literal[None] + template_title: DF.Data + voucher_type: DF.Literal[ + "Journal Entry", + "Inter Company Journal Entry", + "Bank Entry", + "Cash Entry", + "Credit Card Entry", + "Debit Note", + "Credit Note", + "Contra Entry", + "Excise Entry", + "Write Off Entry", + "Opening Entry", + "Depreciation Entry", + "Exchange Rate Revaluation", + "Deferred Revenue", + "Deferred Expense", + ] + # end: auto-generated types + pass -- GitLab