2
votes

I have created html field in the form view. Then user will add content in that field. The content will have some field variables of form view same as we declare in email template. Then user will print pdf report and that report should display values instead of the variables.

  • Example:

Hello ${object.employee_id.name},


  • PDF Report should contain:

Hello Marks,

How can I achieve this? Thanks in advance.

1

1 Answers

0
votes

I find a solution for my problem

from odoo.addons.mail.models import mail_template


class Class_name

    def method_name(self): 
        model = self.env['your.model_name'].search([('id', '=', self.Many2onefield.id)])
        converted_content = mail_template.mako_template_env.from_string(model.<htmlcontent>).render({'object': object_value,})
        self.contract_ready = converted_content

in XML i put

<t t-raw="method_name()"/>

Thanks for all