Skip to content

Commit 69916b8

Browse files
committed
ADD option to strip HTML from communication snippets
1 parent 401d191 commit 69916b8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

partner_communication/models/communication_job.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from odoo import Command, _, api, fields, models, tools
1818
from odoo.exceptions import UserError
19+
from odoo.tools import html2plaintext
1920

2021
from odoo.addons.base.models.ir_qweb import QWebException
2122

@@ -836,12 +837,15 @@ def download_data(self):
836837
return action
837838

838839
@api.model
839-
def get_snippet(self, snippet_name):
840-
return (
840+
def get_snippet(self, snippet_name, strip_html=False):
841+
result = (
841842
self.env["communication.snippet"]
842-
.search([("name", "=", snippet_name)])
843+
.search([("name", "=", snippet_name)], limit=1)
843844
.snippet_text
844-
)
845+
) or ""
846+
if strip_html:
847+
result = html2plaintext(result)
848+
return result
845849

846850
##########################################################################
847851
# PRIVATE METHODS #

0 commit comments

Comments
 (0)