Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
2235 Lượt xem

I'm trying to print some values in the body HTML of an email template based on the values in the environment context object (ctx object). Unfortunately, non of the syntaxes mentioned in the forum or in the Jinja documentation itself is not working, and I get the "Email template does not fit the required schema !" error in the log. 

I'll be grateful for any clue or solution to this problem.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Thanks a lot, Waleed Ali Mohen. It's totally worked. I'm afraid it's impossible to choose your answer as the best answer or make a positive vote, as I don't have enough Karma on my profile.


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi,

You can use for loop for enumerate variable as below:

The blow code loop the event attendees.

Attendees


% for attendee in object.event_id.attendee_ids:

style="display: inline-block; border-radius: 50%; width: 10px; height: 10px; background:${colors[attendee.state] or 'white'};">
% if attendee.common_name != object.common_name:
style="margin-left:5px">${attendee.common_name}
% else:
style="margin-left:5px">You
% endif

% endfor
 

Another example from Odoo code using ctx. (Check line 91 and 112)

 

Ảnh đại diện
Huỷ bỏ