-
Notifications
You must be signed in to change notification settings - Fork 10k
feat: Letter Management feature standardize official correspondence. #50918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aadhilpm
wants to merge
11
commits into
frappe:develop
Choose a base branch
from
aadhilpm:feature/letter-management
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+886
−0
Open
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a25de78
feat: Letter Management feature standardize official correspondence.
aadhilpm 0416a19
fix: linter and prettier formatting issues
aadhilpm 4cd2e14
fix: add permission and error handling
aadhilpm 9c2148e
fix: apply ruff formatter
aadhilpm 743456f
fix: permission checks and type hints
aadhilpm 62bef40
chore: trigger CI
aadhilpm 65a0862
chore: trigger CI
aadhilpm 5e04cbd
fix: improve UX by removing msgprint from set_query
aadhilpm de144d3
fix: trim trailing whitespace
aadhilpm ca47f32
refactor: move Letter Management from CRM to Utilities module
aadhilpm 9aebafd
test: add tests for Letter and Letter Type doctype
aadhilpm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
| # For license information, please see license.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| // Copyright (c) 2025, Frappe Technologies Pvt. Ltd. and contributors | ||
| // For license information, please see license.txt | ||
|
|
||
| frappe.ui.form.on("Letter", { | ||
| refresh(frm) { | ||
| // Filter for recipient address | ||
| frm.set_query("recipient_address", () => { | ||
| if (!frm.doc.recipient_type || !frm.doc.recipient) { | ||
| return { filters: { name: "" } }; | ||
| } | ||
| return { | ||
| query: "frappe.contacts.doctype.address.address.address_query", | ||
| filters: { | ||
| link_doctype: frm.doc.recipient_type, | ||
| link_name: frm.doc.recipient, | ||
| }, | ||
| }; | ||
| }); | ||
|
|
||
| // Filter for company address | ||
| frm.set_query("company_address", () => { | ||
| if (!frm.doc.company) { | ||
| return { filters: { name: "" } }; | ||
| } | ||
| return { | ||
| query: "frappe.contacts.doctype.address.address.address_query", | ||
| filters: { | ||
| link_doctype: "Company", | ||
| link_name: frm.doc.company, | ||
| }, | ||
| }; | ||
| }); | ||
| }, | ||
|
|
||
| recipient(frm) { | ||
| if (frm.doc.recipient_type && frm.doc.recipient) { | ||
| frappe.call({ | ||
| method: "erpnext.utilities.doctype.letter.letter.get_recipient_details", | ||
| args: { | ||
| recipient_type: frm.doc.recipient_type, | ||
| recipient: frm.doc.recipient, | ||
| }, | ||
| callback: function (r) { | ||
| if (r.message) { | ||
| frm.set_value("recipient_name", r.message.recipient_name); | ||
| if (r.message.language) { | ||
| frm.set_value("language", r.message.language); | ||
| } | ||
| } | ||
| }, | ||
| }); | ||
| } else { | ||
| frm.set_value("recipient_name", ""); | ||
| frm.set_value("language", ""); | ||
| } | ||
| frm.set_value("recipient_address", ""); | ||
| frm.set_value("address_display", ""); | ||
| }, | ||
|
|
||
| recipient_type(frm) { | ||
| frm.set_value("recipient", ""); | ||
| frm.set_value("recipient_name", ""); | ||
| frm.set_value("recipient_address", ""); | ||
| frm.set_value("address_display", ""); | ||
| }, | ||
|
|
||
| recipient_address(frm) { | ||
| if (frm.doc.recipient_address) { | ||
| frappe.call({ | ||
| method: "frappe.contacts.doctype.address.address.get_address_display", | ||
| args: { | ||
| address_dict: frm.doc.recipient_address, | ||
| }, | ||
| callback: function (r) { | ||
| if (r.message) { | ||
| frm.set_value("address_display", r.message); | ||
| } | ||
| }, | ||
| }); | ||
| } else { | ||
| frm.set_value("address_display", ""); | ||
| } | ||
| }, | ||
|
|
||
| company(frm) { | ||
| frm.set_value("company_address", ""); | ||
| frm.set_value("company_address_display", ""); | ||
|
|
||
| // Set default letter head from company | ||
| erpnext.utils.set_letter_head(frm); | ||
| }, | ||
|
|
||
| company_address(frm) { | ||
| if (frm.doc.company_address) { | ||
| frappe.call({ | ||
| method: "frappe.contacts.doctype.address.address.get_address_display", | ||
| args: { | ||
| address_dict: frm.doc.company_address, | ||
| }, | ||
| callback: function (r) { | ||
| if (r.message) { | ||
| frm.set_value("company_address_display", r.message); | ||
| } | ||
| }, | ||
| }); | ||
| } else { | ||
| frm.set_value("company_address_display", ""); | ||
| } | ||
| }, | ||
|
|
||
| letter_template(frm) { | ||
| if (frm.doc.letter_template) { | ||
| frappe.call({ | ||
| method: "erpnext.utilities.doctype.letter_template.letter_template.get_letter_template", | ||
| args: { | ||
| template_name: frm.doc.letter_template, | ||
| doc: frm.doc, | ||
| }, | ||
| callback: function (r) { | ||
| if (r && r.message) { | ||
| if (r.message.subject) { | ||
| frm.set_value("subject", r.message.subject); | ||
| } | ||
| if (r.message.content) { | ||
| frm.set_value("content", r.message.content); | ||
| } | ||
| } | ||
| }, | ||
| }); | ||
| } | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| { | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "actions": [], | ||
| "allow_rename": 1, | ||
| "autoname": "naming_series:", | ||
| "creation": "2025-12-03 20:35:18.414308", | ||
| "doctype": "DocType", | ||
| "engine": "InnoDB", | ||
| "field_order": [ | ||
| "section_break_letter", | ||
| "naming_series", | ||
| "recipient_type", | ||
| "recipient", | ||
| "recipient_name", | ||
| "recipient_address", | ||
| "address_display", | ||
| "column_break_pmit", | ||
| "letter_type", | ||
| "date", | ||
| "company", | ||
| "company_address", | ||
| "company_address_display", | ||
| "amended_from", | ||
| "letter_details_section", | ||
| "letter_template", | ||
| "subject", | ||
| "content", | ||
| "printing_settings_section", | ||
| "letter_head", | ||
| "column_break_ksdg", | ||
| "language" | ||
| ], | ||
| "fields": [ | ||
| { | ||
| "fieldname": "amended_from", | ||
| "fieldtype": "Link", | ||
| "label": "Amended From", | ||
| "no_copy": 1, | ||
| "options": "Letter", | ||
| "print_hide": 1, | ||
| "read_only": 1, | ||
| "search_index": 1 | ||
| }, | ||
| { | ||
| "fieldname": "recipient_type", | ||
| "fieldtype": "Select", | ||
| "in_filter": 1, | ||
| "in_list_view": 1, | ||
| "label": "Recipient Type", | ||
| "options": "Customer\nSupplier\nEmployee\nShareholder\nContact", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "fieldname": "recipient_address", | ||
| "fieldtype": "Link", | ||
| "label": "Recipient Address", | ||
| "options": "Address" | ||
| }, | ||
| { | ||
| "fieldname": "column_break_pmit", | ||
| "fieldtype": "Column Break" | ||
| }, | ||
| { | ||
| "fieldname": "recipient", | ||
| "fieldtype": "Dynamic Link", | ||
| "in_filter": 1, | ||
| "in_list_view": 1, | ||
| "label": "Recipient", | ||
| "options": "recipient_type", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "fieldname": "recipient_name", | ||
| "fieldtype": "Data", | ||
| "label": "Recipient Name", | ||
| "read_only": 1 | ||
| }, | ||
| { | ||
| "fieldname": "address_display", | ||
| "fieldtype": "Text Editor", | ||
| "label": "Recipient Address Details", | ||
| "read_only": 1 | ||
| }, | ||
| { | ||
| "fieldname": "company", | ||
| "fieldtype": "Link", | ||
| "in_list_view": 1, | ||
| "label": "Company", | ||
| "options": "Company", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "fieldname": "naming_series", | ||
| "fieldtype": "Select", | ||
| "label": "Series", | ||
| "no_copy": 1, | ||
| "options": "L-.YY.-", | ||
| "print_hide": 1, | ||
| "reqd": 1, | ||
| "set_only_once": 1 | ||
| }, | ||
| { | ||
| "fieldname": "company_address", | ||
| "fieldtype": "Link", | ||
| "label": "Company Address", | ||
| "options": "Address" | ||
| }, | ||
| { | ||
| "fieldname": "company_address_display", | ||
| "fieldtype": "Text Editor", | ||
| "label": "Company Address Details", | ||
| "read_only": 1 | ||
| }, | ||
| { | ||
| "fieldname": "letter_type", | ||
| "fieldtype": "Link", | ||
| "in_filter": 1, | ||
| "in_list_view": 1, | ||
| "label": "Letter Type", | ||
| "options": "Letter Type", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "default": "Today", | ||
| "fieldname": "date", | ||
| "fieldtype": "Date", | ||
| "in_list_view": 1, | ||
| "label": "Date", | ||
| "reqd": 1 | ||
| }, | ||
| { | ||
| "fieldname": "letter_details_section", | ||
| "fieldtype": "Section Break", | ||
| "label": "Letter Details" | ||
| }, | ||
| { | ||
| "fieldname": "letter_template", | ||
| "fieldtype": "Link", | ||
| "label": "Letter Template", | ||
| "link_filters": "[[\"Letter Template\",\"letter_type\",\"=\",\"eval:doc.letter_type\"]]", | ||
| "options": "Letter Template" | ||
| }, | ||
| { | ||
| "fieldname": "subject", | ||
| "fieldtype": "Data", | ||
| "label": "Subject" | ||
| }, | ||
| { | ||
| "fieldname": "content", | ||
| "fieldtype": "Text Editor", | ||
| "label": "Content" | ||
| }, | ||
| { | ||
| "fieldname": "section_break_letter", | ||
| "fieldtype": "Section Break" | ||
| }, | ||
| { | ||
| "collapsible": 1, | ||
| "fieldname": "printing_settings_section", | ||
| "fieldtype": "Section Break", | ||
| "label": "Printing Settings" | ||
| }, | ||
| { | ||
| "allow_on_submit": 1, | ||
| "fieldname": "letter_head", | ||
| "fieldtype": "Link", | ||
| "label": "Letter Head", | ||
| "options": "Letter Head", | ||
| "print_hide": 1 | ||
| }, | ||
| { | ||
| "fieldname": "column_break_ksdg", | ||
| "fieldtype": "Column Break" | ||
| }, | ||
| { | ||
| "fieldname": "language", | ||
| "fieldtype": "Data", | ||
| "label": "Print Language", | ||
| "print_hide": 1 | ||
| } | ||
| ], | ||
| "grid_page_length": 50, | ||
| "index_web_pages_for_search": 1, | ||
| "is_submittable": 1, | ||
| "links": [], | ||
| "modified": "2025-12-03 23:40:09.332016", | ||
| "modified_by": "Administrator", | ||
| "module": "Utilities", | ||
| "name": "Letter", | ||
| "naming_rule": "By \"Naming Series\" field", | ||
| "owner": "Administrator", | ||
| "permissions": [ | ||
| { | ||
| "create": 1, | ||
| "delete": 1, | ||
| "email": 1, | ||
| "export": 1, | ||
| "print": 1, | ||
| "read": 1, | ||
| "report": 1, | ||
| "role": "System Manager", | ||
| "share": 1, | ||
| "submit": 1, | ||
| "write": 1 | ||
| } | ||
| ], | ||
| "row_format": "Dynamic", | ||
| "rows_threshold_for_grid_search": 20, | ||
| "sort_field": "creation", | ||
| "sort_order": "DESC", | ||
| "states": [] | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.