From 27240c01b17645c029bdcfc966f2fb762a871a42 Mon Sep 17 00:00:00 2001 From: HarryPaulo Date: Thu, 8 Aug 2024 12:20:28 -0300 Subject: [PATCH] feat: acess DB only one time and load the doc and get field with values formatted --- .../doctype/whatsapp_message/whatsapp_message.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py b/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py index 7a55534..9e684c1 100644 --- a/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py +++ b/frappe_whatsapp/frappe_whatsapp/doctype/whatsapp_message/whatsapp_message.py @@ -68,10 +68,10 @@ def send_template(self): parameters = [] template_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()) + parameters.append({"type": "text", "text": value}) template_parameters.append(value)