Commit Graph
157648 Commits
Author SHA1 Message Date
Thibault Delavallée f652f6a75c [IMP] mass_mailing: improve composer invoke when sending
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Use the new 'res_domain_user_id' field to use in combination to 'res_domain'
on composer to delegate res_ids computation to the composer instead of relying
on res_ids or active_ids. Records to mail are not stored inside a domain.

Set auto_delete values directly when invoking the composer instead of hacking
the generate mail values. That way we delegate more to the composer itself.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:40 +01:00
Thibault Delavallée 1a1acabd7b [REF] mail: cleanup mono/multi record composer behavior
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Support a real res_ids field on mail.compose.message model. Instead of relying
on active_ids from context, store it once for all at composer level and use
it in code. Active_ids usage is still done at default_get level, using it to
populate the field.

Improve usage of domain, renamed to res_domain to match other document related
fields naming. Add support of a res_domain_user_id field allowing to set the
user from which the domain should be evaluated.

Composer now runs on a list of IDs. Mass mail mode and comment mode are now
distinct from running on a singleton or on more records. Rendered or raw
mode is not triggered by

  * mass mailing mode: always display raw mode, whatever the number of records;
  * comment mode: display rendered mode when having a single record (like the
    previous comment mode). Display raw mode when having either no records
    either at least two records.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:39 +01:00
Thibault Delavallée 55bcb62131 [REM] mail: remove mass post option from mail composer
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

Remove deprecated "mass_post" option from composer. It is either a comment
(using message_post) either a mass mail (creating emails). Mass post was
anyway nor used nor really supported. It will be replaced by supporting
having a comment on several IDs (batch comment mode, posting a message
on several records instead of being limited to one as currently).

This cleaning also allows to remove the 'notify' field that was an option
used for mass_post. All this should be supported through subtypes and
correct choice of post / mass mailing.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:39 +01:00
Thibault Delavallée 7973960784 [FIX] mail: pre-raise when trying to post on no record
RATIONALE

Improve usage of composer in comment or email mode: support batch-posting in
comment, support more configuration from templates, improve global model.

SPECIFICATIONS

When trying to use the composer without related records in comment mode
message_post raises, as record is mandatory (ensure_one). In this commit
we make this raise explicit in the composer itself, in order to be able
to assert the behavior.

In mass mail mode, having no record to mail is possible and the composer
simply skips the mail creation. Indeed when doing mass mailing, notably
with crons, records might have been updated / removed and the composer
should not crash, just produce nothing.

Task-3035101 (Mail: Support batch-posting from composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:39 +01:00
Thibault Delavallée 5b332e2d28 [REF] mail: cleanup context usage in composer
Purpose of this commit is to cleanup context usage in composer

  * remove now dead 'custom_layout' context keys that was present mainly for
    compatibility until Odoo v15. You should now correctly use default value
    for 'email_layout_xmlid' field like every field;
  * remove 'mail_auto_delete' context key, not used anywhere in codebase.
    Auto-delete field of composer will be improved soon so that setting it
    as every field will replace the context usage;
  * remove usage of self._context, to use self.env.context;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:38 +01:00
Thibault Delavallée df6171ac38 [REF] mail: rewrite values generation in composer
Purpose is to rewrite value generation as code is messy with a lot of dict
updates, rewriting key on top of existing keys until reaching the final value.

In this commit we better split computation, to have computation that is static
(currently, posting a comment as composer holds final code) separated from
dynamic computation (posting a mass mailing, as rendering is done based on
qweb or inline template value).

It allows to better understand how composer and template fields are used when
sending emails or posting messages. This commit should not change anything
functionally, even if some values are weirdly computed. Future commits will
improve support of composer / template fields, notably through computed field
and less cross computation.

Also split sending methods: do a mailing in batch in case of mass mailing
(allowing commit per batch), and simply loop on records to post a message
in case of comment (or mass post).

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:38 +01:00
Thibault Delavallée 09a1647c64 [REF] mail: improve composer call to template values generation
Now that template generation methods have been cleaned we can cleanup calls
done in composer. We notably

  * make methods private, improve their naming and docstrings;
  * better support input / output of asked fields;
  * be more coherent with composer fields and template fields usage;

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Composer Onchange to Editable Computed Stored)

Part-of: odoo/odoo#99482
2023-01-17 20:58:38 +01:00
Thibault Delavallée 041e9924c7 [REF] mail: improve default record-based data in composer
Purpose is to ease understanding of those default values and prepare move
towards editable stored computed fields by rewriting a bit the code to better
understand its purpose.

While being at it, some tests introduced recently are moved at their right
place now that everything is ready to rewrite the posting API and the
composer. Some tests are added to ensure notification-specific methods are
called along with the newly-introduced '_message_compute_subject', aka methods
to add custom header and custom mail values.

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in compo

Part-of: odoo/odoo#99482
2023-01-17 20:58:38 +01:00
Thibault Delavallée 26f1f7c433 [MOV] mail: reorganize composer values generation code
Purpose of this commit is to move methods to better prepare future changes.
Currently onchange code, value generation and tools for email management
are mixed, which leads to the file being quite messy.

Separate methods generating mail or message values, from methods doing
data marshmalling.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:37 +01:00
Thibault Delavallée ae8f0f2e83 [REF] mail: improve template recipients rendering and generation
When computing recipients based on template we generally create new partners
based on emails. This is due to the mail framework managing mainly partners
and not low level emails.

This code is currently sequential: fetching or creating partners one by one
based on found emails, for each record. This is highly inefficient when
sending emails on a lot of records based on templates.

Purpose of this commit is to improve code and performances by batching. We
do queries in batch: one search for all records, create partner in batch. This
leads to code being a bit more complicated to correctly remember and dispatch
again emails and partners to the correct records.

Task-3034875 (Mail: Speedup and batch partners find or create with templates)

Part-of: odoo/odoo#99482
2023-01-17 20:58:37 +01:00
Thibault Delavallée d744f86a98 [REF] mail: make other fields generation on template independent
Purpose of this commit is to extract fields generation on template for fields
not belonging to recipients or attachments in sub-methods. Code is cleaned to
better support parameters and be easier to call. It can now be called
independently from the main ``_generate_template`` method.

First sub method is dedicated to 'scheduled_date' which is dynamic and has its
own post processing (to be UTC agnostic as expected by ORM). Second one is
dedicated to static values coming directly from template without rendering.

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:37 +01:00
Thibault Delavallée b1df143775 [REF] mail: make attachments generation on template independent
Purpose of this commit is to extract attachments generation on template in
its own sub-method. As it contains code specific to attachments, better
have it separated from the main global generation method. Code is cleaned
to better support parameters and be easier to call. It can now be called
independently from the main ``_generate_template`` method.

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:36 +01:00
Thibault Delavallée 7982c0072d [REF] mail: make recipients generation on template independent
Purpose of this commit is to improve recipients generation on template.
Code is cleaned to better support parameters and be easier to call. It
can now be called independently from the main ``_generate_template``
method. Docstrings are updated.

Changes
  * removed support of ``tpl_force_default_to`` context key used to somehow
    simulate the check of "use default recipients" (??)
  * removed support of ``tpl_partners_only`` context key used to force to
    find or create partners based on emails generated by the template. It
    is replaced by a parameter to propagate;

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:36 +01:00
Thibault Delavallée 4d571ec8d7 [REF] mail: render only asked fields when generating a template values
Currently some value are always computed and added even if not asked by the
caller. As asking a template to render some fields is now used notably for
a subset of fields (subject and body, from / to, ...) there is no need to
automatically add other irrelevant information.

Main callers already filtered out returned results (notably composer). However
better avoid computing / rendering unnecessary stuff directly at template
level.

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:36 +01:00
Thibault Delavallée a19f2e3390 [REF] mail, various: cleanup input/output of generation methods on template and composer
Purpose of this commit is to prepare further improvements in template and
composer rendering methods. First step is to

  * make them private;
  * correctly name parameters (notably rename fields to render_fields to avoid
    collision with odoo.fields);
  * remove the "single / multi" mode. This is a relic of old implementation
    when rendering was done mainly record by record and sometimes by batch.
    Now everything should be batched;
  * split some lines to ease future diff in upcoming commits;
  * improve some docstrings;

Next commits will rewrite and split parts of ``_generate_email``.

Task-2710804 (Mail: Clean MailThread Posting API)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:36 +01:00
Thibault Delavallée 95859f6fb5 [REF] mail, various: cleanup usage of mail.composer.mixin
'email_from' fields are not necessary on 'sale.order.cancel' and 'survey.invite'
as anyway we always use the current user's email and field is not present in
form view. Override of default_get to raise about invalid email_from is not
necessary as anyway it raises when posting the message. Giving author_id to
message_post is sufficient as it computes email_from based on author when given.

Add 'render_model' in views, as it is part of the domain given to 'template_id'
field of composer mixin. When missing, also add 'lang' and 'template_id' that
come from the render mixin.

Use '_render_field' when possible instead of '_render_template' as its API
is simpler and uses field definition for rendering parameters.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:35 +01:00
Thibault Delavallée 9180843bb9 [MOV] mail: move "main attachment" update as an after-post hook
A method ``_message_set_main_attachment_id`` exists to handle main attachment
reference, used notably in discuss and accounting. It is now called inside
``_message_post_after_hook``, so that it is part of the post processing after
having posted the message. Its API has been updated so that attachment_ids is
now a real list of ids, which is clearer.

A wrong override of '_message_post_after_hook' dealing with parameters is
cleaned while passing by.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:35 +01:00
Thibault Delavallée ea3e4d2dc0 [REF] various: cleanup usage of 'message_notify'
Notification method 'message_notify' is sometimes used as a standalone method
to send notifications. In that case it is called directly on MailThread
abstract model, notably when there is no context record or when it does not
inherit from 'mail.thread' directly. This is done mostly in technical models.

However in that case some model-specific code is not called, notably methods
computing default subject. In this commit we improve some calls to be sure
notifications have content enough to be understandable.

When possible, we also redirect the notification method on real records
inheriting from mail.thread, enabling a more complete process.

See community PR for more details.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:35 +01:00
Thibault Delavallée 9bbb276c42 [REF] mail: cleanup message_{notify, log} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SPECIFICATIONS

Update methods parameters to look more like 'message_post' definition. Add
docstrings to explain parameter usage. Cleanup some parameter we do not
want. Add a api.returns on message_notify to wrap the value in case of external
call, as this method is public, like message_post.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:35 +01:00
Thibault Delavallée 4775bd93a2 [REF] mail: cleanup post with {view, template} wrappers
RATIONALE

Purpose of this commit is to cleanup main post helpers and have a more easy
and understandable way of calling them.

SUMMARY

We now have two main API methods, based on business flow: either posting
on documents, either sending a mass mailing. Indeed those two flows are
different

  * post: create message, then launch notification process by taking into
    account subtype, followers, ...
  * mail: create mails in batch with recipients being based on template or
    given partners. No notifications is involved, only maybe traces if a
    mass mailing is linked

Delegate QWeb rendering to the render mixin (i.e. _render_template_qweb_view)
in order to have a single point to forge evaluation context and re-use
existing rendering code.

SPECIFICATIONS

Main API helpers are now

  * ``message_post_with_source``: (batch) post on records, using an ir.ui.view
    (given a record or its xml id) or a mail.template record (given a record or
    its xml id). When using a template, a composer is called to post on each
    record (as batch post is not yet supported). When using a view, a direct
    call to message_post using the rendered bodies is done, one record at a
    time.
  * ``message_mail_with_source``: send a mass mailing on records, acting like
    invoking the mail composer in mass mode. Same arguments are valid, either
    a reference to a view, either a reference to a mail template.

Other helpers are

  * ``_message_log_with_view``: (batch) log on records, using an ir.ui.view
    to render the body using QWeb (no notification process);
  * ``_message_log(_batch)``: (batch) log on records (no notification process);
  * ``message_notify``: notify partners on records (creating notifications
    specifically for some people while message itself is not displayed in
    chatter);

Code migration

  * ``message_post_with_template`` in "mass mode": use ``message_mail_with_source``
    and set the template record as source;
  * ``message_post_with_template`` in "comment" mode: use ``message_post_with_source``
    and set the template record as source;
  * ``message_post_with_view``: its main usage was to post on a document, in which
    case it generally can be replaced by ``message_mail_with_source`` using
    the view reference as source;

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 3a9a791be8 [IMP] mail: allow to render views from render mixin
When calling "_render_template_qweb_view", parameter can currently be an
XmlID or an id. It can now be a recordset, allowing easy calls from Odoo.

Slug is also added in evaluation context to prepare further cleaning in
message_post helpers.

Some error messages are also improved while passing by.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 2175bde607 [IMP] mail: add sanity checks for message_post and its helpers
Purpose of this commit is to clearly check input of ``message_post`` method
and its main helpers in order to prevent wrong usage of message post API.

Some values used to populate message fields should not be set directly when
posting or logging messages. Indeed they may be part of other process (like
notification process managed by ``_notify_thread``, or could be setup by
custom routes like 'reaction_ids', or custom usage of 'model' and 'res_id'
that could conflicts with record on which methods are called).

We therefore add checks and cleanup in those methods to be sure the API
is used as intended and avoid unwanted side effects.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:34 +01:00
Thibault Delavallée 023bc67327 [IMP] mail: introduce a batch version of Partner._find_or_create ()
Purpose is to be able to create find or create partners in batch based on a
list of emails. When sending email in batch, notably using templates, doing
sequentially a search or create for each potential email to contact is not
efficient from computation point of view. This commit introduces a new batch
method for that purpose.

If no valid email is found for a given email, it is used as it to try to
find partners with same invalid email and/or keep the value in order to
allow updating it afterwards. Notably with notifications resend it is
possible to update emails, if only a typo prevents from having a real
email for example.

Falsy emails do not create partners as those have no real interest.

Task-3034875 (Mail: Speedup and batch partners find or create with templates)
Prepares Task-2088884 (Mail: Use editable computed stored fields in composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée 418761e344 [LINT] mail, various: use explicit subtype in message_post_{with_...}
RATIONALE

Purpose of this commit is to be explicit in subtype chosen when invoking the
message composer / calling message_post. As default value may not always be
clear, better be explicit in case the composer default value changes.

SPECIFICATIONS

Add explicit references to subtype when it is not obvious what will be the
final subtype, notably when using helpers (post_with_view or template which
uses the composer that is not crystal clear in its subtype management).

In this commit we also add support of XMLID-based subtype when invoking the
composer. A ``default_subtype_xmlid`` context key is transformed into a
``default_subtype_id``, to be used notably in JS where we cannot easily
use a ``ref``-like statement. Post API now also supports 'subytpe_xmlid'
argument allowing to give the xml id and ease calling the methods.

Use ``_xmlid_to_res_id`` to get directly the ID of subtypes in order to
avoid useless queries from ``ref`` that does an exists.

Also remove useless values given to post API, notably author_id that is by
default the current users' partner.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée d6aa0050da [FIX] mail: stop spamming CCs of outgoing emails
Fix usage of CCs when sending emails. Currently CCs are added to all outgoing
emails, which leads to unnecessary spam. Recipients are currently computed like

  * create an outgoing email based on 'email_to';
  * create one outgoing email / partner in 'recipient_ids';
  * add CCs to all outgoing emails;

They are now sent only once, either with the email_to if given, either as
standalone. That way partners receive specific emails (due to tracking and
partner specific links management), email_to / email_cc are sent on their own.

Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée 91672b1cab [IMP] mail: log a warning when having invalid headers on mail.mail
In this commit we add some logs when we fail to evaluate the 'headers' field
on a 'mail.mail' record, used to populate the headers of outgoing emails.

Some tests are added to ensure we do not crash if headers is malformed, and
to cover the feature itself as it was still not really done.

Task-2710804 (Mail: Clean MailThread Posting API)
Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:33 +01:00
Thibault Delavallée b1d678b12a [REF] mail, mass_mailing: extract outgoing email values preparation into a method
RATIONALE

When sending a ``MailMail`` some data preparation is done. This is done
directly in ``_send`` and in sub-methods. As a given MailMail may lead to
several emails being sent we have to go from a mail to a list of emails
to send :

  * one email for ``email_to``. They all receive the same email, as those are
    just a list of emails to contact and no specific post-processing is done;
  * one email for each partner in ``recipient_ids``. It enables a partner-based
    update of the body, for example for links or traces in mass mailing;

SPECIFICATIONS

In this commit we move code so that all preparation is done in a sub-method
``_prepare_outgoing_list``. That way it can be cleanly overridden to add or
modify values before sending the actual emails.

This commit does not change behavior and calls done to ``build_email``. This
will be updated in the next commits, notably to improve "cc" management.

Task-2710804 (Mail: Clean MailThread Posting API)
Task-3093268 (Mail: Stop spamming CCs)
Prepares Task-2684479 (Mail: Better report errors when sending emails)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée 18e6f7d376 [PERF] mail: skip state computation when posting through composer
Composer holds code to check recipients email and avoid sending emails when
recipients do not have valid emails. Purpose is to avoid bloating the email
queue with emails that are about to fail.

It is done by analyzing recipients of emails, aka checking 'recipient_ids'
value before creating the mail.mail.

When being in comment mode, this code has no use as recipients are computed
by the notification process, not by the composer. We can therefore skip this
part. It adds the 'state' and 'failure_type' values that are used on mail
model, but not on messages.

The same kind of processing could be done in notification process to avoid
sending unnecessary notifications, but this improvement belongs to another
commit and task.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée 1394903873 [IMP] test_mail: add tests for exclusion list and duplicates in composer
Purpose of this commit is to add tests for exclusion list and duplicates
management in composer.

When being in email mode (mass_mail) state of emails is pre-processed in
order to already flag emails that should not be sent or will bounce back.
Notably emails in exclusion list or duplicates emails are set as cancel
with the right failure type.

Some tests already exist at higher level in mass mailing but having tests
at composer level is better when trying to improve code and add tests for
corner cases.

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:32 +01:00
Thibault Delavallée c98f259736 [IMP] mail: improve tests tooling methods
In this commit we add a method to check MailMail, based on a given record.
When having duplicates to differentiate in a given mailing, having just
recipients is not sufficient as multiple emails may match a given recipients
list. Checking model / res_id is another method for finding emails.

This will be used notably to add tests for exclusion list and duplicates
management in standard mail composer, outside of mass mailing context.

While being at it, use subTests when having loops checking values. That
way it is easier to fix tests that have several failing values in the same
global assertMailMail_* .

Task-3132710 (Mail: Configurable composer)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 7d16ae5551 [FIX] point_of_sale: avoid entities in emails
Purpose of this commit is to avoid html entities in sent emails message by
correctly using string and html formatting.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 3e7acff8d9 [FIX] website(_sale): fix logs coming from website forms
Purpose of this commit is to avoid html entities in logged message by correctly
managing enclosures. For that purpose a new tool 'nl2br_enclose' is added that
eases Markup management on top of 'nl2br' simple tool.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée eccac1ce7b [FIX] website(_sale): stop creating message manually
In website(_sale) messages are created from website forms. However those
are technical models, you should always use the MailThread API notably to
ensure values coherency. In our case using message_log seems to be what
original committers wanted to do (even creating a message as a comment
which has no effect as the notification process is not called that way).

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:31 +01:00
Thibault Delavallée 7b96e7cb22 [FIX] mail: correctly display errors when previewing templates
In this commit we correctly set 'error_msg' field as computed. As it was not
defined as computed, it was not really updated and therefore not displayed
in the preview form view. It is now the case.

ValueError are now also catched, for example when having badly configured
'partner_ids' field we may face this kind of error, which is now logged
in the preview wizard.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 44a316275d [FIX] mail: avoid cache miss when opening the template previewer
Sometimes the previewer crashes in rendering with cache-based records, hence
trying to check directly the id of the related reference record.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 11906b776e [FIX] mail: remove microseconds when parsing vague datetime
Mail holds an helper function to convert datetime from a char input into a
datetime value. It is used notably when having to store a datetime value
(e.g. on a mail_mail) from a string generated by templates with expression
like ``{{ datetime.datetime.now() + datetime.timedelta(days=2)}}``.

In this commit we explicitly remove microseconds, as otherwise we end up with
something that the web client cannot parse, not speaking of even going into
server side storage with this value not matching the expected format.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Thibault Delavallée 04a6b74d09 [FIX] mail, various: update query counters
Update counters according to latest runbot counters. It allows to better spot
side effects of upcoming changes.

Task-2710804 (Mail: Clean MailThread Posting API)

Part-of: odoo/odoo#99482
2023-01-17 20:58:30 +01:00
Nicolas (vin) d39396c728 [IMP] account,l10n_*: remove company currency symbol in reports
There is a lot of use case where reports are exclusively in the company
currency, or have columns only in this currency. In these case, showing
the currency symbol is redundant, takes space and makes the reading
slower.

With this change, we will avoid displaying the symbol in a variety of
use case where it is not needed.

Task id #2868674

closes odoo/odoo#109666

Related: odoo/enterprise#35671
Signed-off-by: Brice Bartoletti (bib) <bib@odoo.com>
2023-01-17 19:55:50 +01:00
Romeo Fragomeli 51db7cd7b6 [FIX] *: some border aren't apply anymore
* = digest, hw_posbox_homepage, im_livechat, mass_mailing, web_editor,
website, website_slides_forum

Since the migration of Bootstrap 5 [1], some CSS rules was automatically
converted (`border-left` and `border-right`) when it shouldn't be.
These conversions were made because the CSS rules was embedded in
HTML/XML code and the REGEX for the conversion had no protection for
these cases.

This commit restores the old correct value.

Ref:
[1] odoo/odoo@1fcd098af5

closes odoo/odoo#110141

X-original-commit: 0cbf7c00ecc307fc725da345415647828e771bb4
Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: Romeo Fragomeli (rfr) <rfr@odoo.com>
2023-01-17 18:12:48 +01:00
Ivan Yelizariev 3ff9c48ba9 [FIX] sale: use partner's lang on creating invoices
This commit adds lang context on preparing invoice lines. Othwerwise we may get
lines in user's lang instead of partner lang.

For example, it's needed in sale_subscription module:

https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L235-L236
https://github.com/odoo/enterprise/blob/e5e168d596aaefcd842fc553890e474aff3322f2/sale_subscription/models/sale_order_line.py#L262

STEPS:

- Use English as your user language
- Set a language different from English on a customer C
- Create a subscription product P
- Create a SO for C with P
- Create the invoice

opw-3104785

closes odoo/odoo#110152

X-original-commit: 6dee103df5e5f64d8edf871d4e1a284ef4d21725
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-01-17 16:47:27 +01:00
Ivan Yelizariev 85f5006018 [FIX] web: fix export m2m fields on using group_by
Export tool is based on ORM method `_export_rows`. The method has special
processing of m2m fields when user checked *Import compatible* option [1].
Before this commit the negative value of `import_compatible` parameter wasn't
passed when data are exported in grouping mode. This led to empty values in m2m
fields.

STEPS:
* Order some products via website and pay via wire transfer
* Open Orders menu in backend
* group order by any field
* expand group with the order
* add field *Transactions/Acquirer/Display Name*

[1]: https://github.com/odoo/odoo/blob/b28c44a38698018ebbbc420f6567c17b2b97c279/odoo/models.py#L894-L914

opw-2864737

closes odoo/odoo#110151

X-original-commit: 6647ac83467207f4f4ef23aac96ebaf5333b967b
Signed-off-by: Ivan Elizaryev (iel) <iel@odoo.com>
2023-01-17 16:47:24 +01:00
Dũng (Trần Đình) 3062f8acc4 [FIX] account: None type of search panel
closes odoo/odoo#110149

See: 26dd1d9627cdd04e12c3187f0f53c0e11892a345
X-original-commit: b03d4c6436472d5e78bcdd612171ce56c56d906c
Signed-off-by: William André (wan) <wan@odoo.com>
2023-01-17 16:47:21 +01:00
Kevin Baptiste ae45b2f83f [FIX] hr: use correct close tag
There was an error in the XML template of the department org chart, the
opening tag was a `<t>` but closed with a `</div>`...

closes odoo/odoo#110142

X-original-commit: 10ce40dd6b181f6dd6e434f208aa9f13b33975d3
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-17 16:47:14 +01:00
gawa-odoo a599320259 [FIX] analytic: search for analytic account with ref
An analytic account was searchable in an invoice with the Ref field.
Before this commit, it is not possible, while it should.
So we add it to the search domain.

opw-3119740

closes odoo/odoo#110135

X-original-commit: f5e24b8f7ba4291b0e5ea970da948215b83e6184
Signed-off-by: William André (wan) <wan@odoo.com>
Signed-off-by: Wala Gauthier (gawa) <gawa@odoo.com>
2023-01-17 14:17:06 +01:00
Arnaud Joset c48973aba3 [FIX] calendar: fix attendee model typo
closes odoo/odoo#110133

X-original-commit: 4352aa837b3ffabbda2d3e8a6eb3e793c5b56656
Signed-off-by: Kevin Baptiste <kba@odoo.com>
2023-01-17 14:17:03 +01:00
Arnaud Joset 74c0d8862f [FIX] calendar: allow update meeting status was crashing
Before this commit, when somebody updated the status of recurrent meeting
the dialog was crashing because the component was destroyed and the orm call
could not be done.

X-original-commit: 544b7d9bf805f7860dd318293964cf822b05e0b9
Part-of: odoo/odoo#110133
2023-01-17 14:17:03 +01:00
Jorge Pinna Puissant 4af6fcd779 [FIX] web: kanban view flickering unfiltering columns
Before this commit, when unfiltering a column in a kanban view, a
flickering occurs and the show more button is visible for a moment.

closes odoo/odoo#110130

X-original-commit: 0cd9c7dbba12e362a6445f47d52b43c48dffdb61
Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-01-17 14:16:59 +01:00
tsm-odoo 3752ac6832 [FIX] bus: fix websocket timeout burst
Before this commit, the keep alive timeout could occur for many websockets at
the same time resulting in a burst of transaction (cursor is open when connecting,
disconnecting a websocket).

This issue was even worse because the cursor was opened even when it was
not needed: we don't need to open a cursor if there is no callback
registered for the lifecycle event (OPEN/CLOSE).

This commit fixes those issues by:
- adding a random delay to the keep alive timeout of every websocket.
- not triggering lifecycle events if no callbacks are registered.

closes odoo/odoo#110127

X-original-commit: b4fb1359021b6c882ece3037c82aaaf65cfc2e1e
Signed-off-by: Julien Castiaux <juc@odoo.com>
2023-01-17 14:16:56 +01:00
luvi b6612fca69 [FIX] web: fix ids to export with selected domain
This commit fixes the export when all records are selected (full domain).
Since many records ids might be present when an entire domain is selected,
the request should contains 'false' instead of a list of ids. As a limit
is set in session.active_ids_limit, not all the records were considered.

This means that only the limit was actually exported instead of the full
list that is present. As the legacy implementation of the ExportDialog
allowed to export all records, the behavior has been fixed.

A test has been added to verify the correct parameter during the download
call.

closes odoo/odoo#110126

X-original-commit: 7200e1c5875bc148fb64187fd67d58a7d6c13c7c
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-01-17 14:16:54 +01:00
luvi 6a74bfae9f [FIX] web: fix export templates list filtering
Before this commit, exporting templates were not filtered as
expected. It means templates were visible even on other domains,
polluting the list of templates of a model.

This restores the legacy behavior by filtering the domain in the
rpc and only displaying the desired template list.

A test has been modified to verify the presence of the domain
filter in the parameters of the rpc.

task #3127779

X-original-commit: 30a673c044e53bfb1edc1e6733b2c83c67e0232c
Part-of: odoo/odoo#110126
2023-01-17 14:16:53 +01:00