Skip to content
Snippets Groups Projects
Commit a03f6483 authored by Thibault Delavallée's avatar Thibault Delavallée
Browse files

[REF] mail: clean code about rendering in mail_template

PURPOSE

Clean and rename code about language management and template rendering in mail
template model.

SPECIFICATIONS

Clean method naming and try to make code easier to understand and call. Also
add and/or clean docstrings of rendering methods.

Notably

  * ``_classify_per_lang``: for each lang-contextualized template, give the list
    of record ids;
  * ``_render_template``: now working only on a valid list of IDs instead of
    allowing both int / list and having a return type depending on the input
    type. It allows to simplify code and delegate some processing to callers;

Introduce new API method

  * ``_render_lang``: for each record id return the lang matching it;
  * ``_render_field``: render a field of mail.template, on given set of record
    ids. Usage: template._render_field('body_html', records.ids). Language
    computation is available for this method;

Remove the "multi mode" support of rendering that either returned a rendered
value, either a dict based on given ids. Now all methods always work in batch
and caller have to fetch the correct result if necessary.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
parent aa31e677
Branches
Tags
No related merge requests found
Showing with 206 additions and 135 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment