Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
2 Ответы
15623 Представления

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.partner_id.name},


PDF Report should contain:


Hello Marks,

=======================================

How can I achieve this? Thanks in advance.


Аватар
Отменить

Hi please go through this link, this will tell you how to create a qweb report and how to print field values in the report.

https://www.odoo.com/documentation/8.0/reference/reports.html

Автор Лучший ответ

I solved it by following steps:

Step1 : in the py create a method to replace field variables to values:

from openerp.addons.email_template import email_template // this path may vary depending on your addons directory structure

def method_name(params)

converted_content = email_template.mako_template_env.from_string(<your_html_content>).render({
        'objects': <object>, //<object> like sale.order(1)
        'o': <object>,
    })

return converted_content


Step 2: In your report xml file, call method to py:

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


Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
окт. 22
2265
0
февр. 20
3
5
янв. 25
27881
0
окт. 23
1563
1
окт. 22
3031