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

I have a custom template implementation and created template view like mail. Template now I am facing an issue with take values ​​to the field.

eg:

I have a field called 'test' and I need to take values ​​for this test field,

"$ {object.company_id.name} $ {object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref $ {object.name or 'n / a'})"

'test' is char field and i entered something like this, and now i need original value for this in t.I see something in mail. template and odoo takes values ​​in mail. template. Suppose its character field and value like this then how can i get original value for this code?    

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

${object.test}

use this code in your mail template, you can get the value.

Автор

Not actually the point is I have model called 'text.template' this actually a template view like mail.template.I wrote this for another

purpose ,now filed inside the text.template i saved a value for this field is, "$ {object.company_id.name} $ {object.state in ('draft', 'sent') and 'Quotation' or 'Order'} (Ref $ {object.name or 'n / a'})" . then while selecting this template i need to generate value for this code.This character field and stored like this then how would i get the value?

Лучший ответ

Hi, mail template use jinja2 template for compile the expression 

>>> MailTemplate = self.env['mail.template']
>>> subject = "Hi ${object.name} Welcome"
>>> MailTemplate.render_template(subject, 'res.partner', [3])
{3: 'Hi Administrator Welcome'}

You can use mail.template `render_template` method to get similar result


Аватар
Отменить
Related Posts Ответы Просмотры Активность
1
авг. 21
4224
2
февр. 25
2481
8
мая 23
36351
0
нояб. 18
3783
0
июл. 24
1368