Skip to content

Commit

Permalink
feat: add multilingual templates support
Browse files Browse the repository at this point in the history
  • Loading branch information
shridarpatil committed Aug 19, 2024
1 parent fcd135f commit 53609cc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ def send_template(self):
header_parameters = []
template_header_parameters = []

ref_doc = frappe.get_doc(self.reference_doctype, self.reference_name)
for field_name in field_names:
value = frappe.db.get_value(
self.reference_doctype, self.reference_name, field_name.strip()
)
value = ref_doc.get_formatted(field_name.strip())

header_parameters.append({"type": "text", "text": value})
template_header_parameters.append(value)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"actions": [],
"allow_rename": 1,
"autoname": "field:template_name",
"autoname": "format:{template_name}-{language_code}",
"creation": "2022-10-28 13:39:09.887817",
"doctype": "DocType",
"editable_grid": 1,
Expand Down Expand Up @@ -150,11 +150,11 @@
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2024-08-19 12:00:25.447511",
"modified": "2024-08-19 12:22:17.367586",
"modified_by": "Administrator",
"module": "Frappe Whatsapp",
"name": "WhatsApp Templates",
"naming_rule": "By fieldname",
"naming_rule": "Expression",
"owner": "Administrator",
"permissions": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

class WhatsAppTemplates(Document):
"""Create whatsapp template."""
def autoname(self):
self.name = self.template_name.lower().replace(" ", "_")

def validate(self):
if not self.language_code or self.has_value_changed("language"):
Expand Down

0 comments on commit 53609cc

Please sign in to comment.