Commit Graph
140 Commits
Author SHA1 Message Date
Florian Charlier bd5a68a1a7 [IMP] mail, mass_mailing, sms: process delivery reports
Also impacts mass_mailing_sms, test_mail_sms,
test_mass_mailing

This PR adds support to receive sms delivery reports.

Before this PR, an SMS was considered 'sent' when successfully
handled by the third party. The user couldn't know if/when an
SMS was actually sent for delivery or delivered to the
recipient's device.
This was similar to the behavior for emails as delivery reports
are not commonly used (and not supported in Odoo).

With this work, the SMS `pending` state is introduced in mail,
mass_mailing, sms and mass_mailing_sms contexts although only fully
used in the latter two modules (+tests of course).

Because of the huge cost related to upgrading very large existing
databases, the following compromises were made:

1. An email and sms notification/trace SENT means DELIVERED.
  Those that are sent but NOT DELIVERED are PENDING.
  The difference between email and sms traces reinforced with this PR
  is that an email sent will be counted as "sent" ~ "delivered"
  unless an error is returned for emails while for SMS it can only be
  reached if a delivery report is received.
2. The Link between an SMS uuid (shared with trusted parties) and
  the tracking records (notifications or traces) is done via an
  explicit relationship table (sms_tracker) instead of via a new field.
  This however allowed to nicely concentrate the state update logic.

A `process` state is added to represent an intermediate
step in the sending process, such as held at IAP for SMS.

A few adjustments are also included to update for IAP api v3.
Also, adapts and includes new tests.

Task-2560666

Part-of: odoo/odoo#133392
2023-10-24 12:38:13 +00:00
Pierre-Yves Dufays 3f2f3c1beb [IMP] mail, various: simplify the systray
The system tray has been simplified:
- only one clickable area per activity group
- by default, a click on an activity group open the list view, except for some
model (ex.: journal entries, project, task, documents where the activity view
is opened). This can be defined per model using the _systray_view attribute on
the model.
- the clock icon providing access to the activity view has been removed. As it
is the only action, we also remove "actions" returned by systray_get_activities
in res_users.
- the KPIs are no longer clickable

The tests have been updated (for example, because we open the list view instead
of the kanban view) and one removed "activity menu widget: activity view icon"
as we only have one clickable area now and no more icons.

Task-3300854

Part-of: odoo/odoo#138135
2023-10-19 19:08:12 +00:00
dht-odoo e542cca69e [IMP] mass_mailing: improve mailing form view design
- Before this commit, it could happen sometime that the time for
  which mailing was schedules has passed, but user was still
  getting the same ribbon that mail was scheduled for a particular
  time (which is a bit confusing). And also in the case of
  schedule_type equals to now we are displaying the next_departure
  datetime in ribbon.

  This commit improves the behavior and in such cases, displays a new
  ribbon message saying "This mailing will be sent as soon as possible."
  and has as refresh button next to it, which reloads the page. Once
  the mailing is sent, this ribbon will also be hidden.

  For that, we introduce a new compute boolean `is_past_departure` which
  will be true only if the scheduled time is in past and the mailing is
  still in queue.

  And for the case scedule_type equals to now we are displaying
  a new message on ribbon with refresh button.

- Re-arranges the model container part of the form view of
  a mailing in order to utilize the horizontal space.

  It moves domain next to the model / filter related fields so that
  everything is in a single row, and thus reducing vertical space.

TaskId-2702607

Part-of: odoo/odoo#82107
2023-10-12 08:09:25 +00:00
Astik Singh d24bbca51f [FIX] mass_mailing: duplicate the "Send final on" field when copy
Before this commit:
In the `mailings` when we enable the A/B testing and click on the "Create an Alternative" button,
the "Send final on" field doesn't copy to the new mailing.

Reason:
The related field are copy `false` by default.

After this Commit:
Now it will copy the "Send final on" into a new mailing

closes odoo/odoo#138195

Task: 3465887
X-original-commit: 3d6dd2402a65af40c77692250fd710d3355960e7
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-10-10 12:35:08 +00:00
Thibault Delavallée b897571b9f [REF] mass_mailing: rename subscription model
PURPOSE

Overall cleaning of subscription and exclusion management code from portal.
This code comes mainly from v12 and can now benefit from cleaning and update.

SPECIFICATIONS

In this commit we rename ``mailing.contact.subscription`` model into the
shorter ``mailing.subscription``. This is sufficient to explain the model
purpose. As we plan to add an opt-out model this also allows to have sub
models with suffixes without being too long.

We also rename ``subscription_list_ids`` field on contact model to
``subscription_ids`` as this is shorter and clearer.

Finally the ``mailing_contact_list_rel`` table name that comes from old
implementations (simple m2m table) is renamed to ``mailing_subscription``
to match the model name.

Task-2669037 (Mass Mailing: Refactor js/portal for subscription)

Part-of: odoo/odoo#86084
2023-10-06 06:13:53 +00:00
Thibault Delavallée 8019a605c7 [REF] mass_mailing: update route parameters
PURPOSE

Overall cleaning of subscription and exclusion management code from portal.
This code comes mainly from v12 and can now benefit from cleaning and update.

SPECIFICATIONS

Rename route parameters to be more clear about their usage. Notably res_id
is better labelled document_id, token is a hash_token, ...

Update legacy to still support old routes.

Task-2669037 (Mass Mailing: Refactor js/portal for subscription)

Part-of: odoo/odoo#86084
2023-10-06 06:13:53 +00:00
Thibault Delavallée 11e813d7f3 [REF] mass_mailing: cleanup subscriptions update (optin / optout from lists)
PURPOSE

Overall cleaning of subscription and exclusion management code from portal.
This code comes mainly from v12 and can now benefit from cleaning and update.

SPECIFICATIONS

Purpose of this commit is to cleanup code that manages chosen lists from
portal and updates opt-in and opt-out accordingly.

Code is now located on mailing list model. When opting-it, new subscriptions
have to be created for mailing lists so that email is part of the list. When
opting-out we just have to toggle the opt_out flag on subscription model.

Logged messages are also improved. We log on contact model the updated
mailing lists for opt-in or opt-out.

Task-2669037 (Mass Mailing: Refactor js/portal for subscription)

Part-of: odoo/odoo#86084
2023-10-06 06:13:53 +00:00
Aditya Sharma 35bb9ffd52 [IMP] various: add minor UI improvements
PURPOSE

Slightly modify various apps to improve the user experience. Changes include
notably labels and views fine tuning, roundings, and small css fixes.

SPECIFICATIONS

- Remove the decorator from the event list view as it's a bit confusing
- Ensure mailing KPIs are now shown with 2 decimal places
- Re-order the mailing stat buttons
- Improve the background / font colors of the cover block
- Improve the labels of:
  - Title and confirm button of the /button and /link modals
  - Confirm button when archiving a record

Task-3204554

closes odoo/odoo#128108

Related: odoo/enterprise#43937
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-10-03 19:19:52 +00:00
miad-odoo 5a6fbaacc7 [FIX] mass_mailing: fix finding duplicate mails
Before the commit, the _get_seen_list() function in the mass_mailing module was
not able to correctly identify all the duplicate email addresses in a given mass
mailing. This was because the function chose and used only one way to find an
email address for each record in the mailing list, even though there are many
ways to find an email address for a record.

For example, a crm.lead record might have an email address in its partner_id
field, but it might also have an email address in its email_normalized field.
This can vary from record to record.

To fix this issue, the _get_seen_list() function was updated to only look at the
email address to which emails have already been sent, rather than trying to
fetch it from the record itself. This ensures that all duplicate emails are
correctly identified and that no duplicate emails are sent in the mass mailing.

Task-3234378

closes odoo/odoo#135081

X-original-commit: 66f9aa25af049aa3faf0f76475a4a2b63b5d0903
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-13 03:37:54 +00:00
Gorash 75a105f46a [REF] base/all: Update modifier syntax: remove 'states' from fields
These changes are made as a result of simplifying attrs and 'states' in
views. However, they should have remained in a separate commit. When
applying the script making the xml changes (used later for the migration
script), the script checked the definition of the python fields in order
to convert the information into a python expression. Therefore, this
commit is not applied when the script is applied to xml changes.

During this attribute deletion pre-existing errors were found. Part of
the code was using the boolean values of 'states' and another part of
the code was not. The behavior could therefore be different (in cases
where readonly on the field had the same value as the ballan in
'states').

Following the deletion of 'states' and without the application of the
view migration, the js tests (tower) were no longer functional. Tests
using the Form view suffered the same effect. There are few tests that
had to be adapted, including two tests in business accounting (updated
by the accounting team). A test for column_invisible did not work. Test
checking if the test system triggers an error if we try to write on an
invisible field. It turns out that Form was testing on the value of
invisible but not taking into account if the column was invisible. The
test system fix is applied separately because there were a lot of tests
that were incorrect.

Part-of: odoo/odoo#104741
2023-08-18 09:49:11 +02:00
Antoine Guenet 234385a7b6 [FIX] mass_mailing: convert base64 background images to inline images
Base64 img src were converted to inline images but background images
were omitted. This commit fixes that.

opw-3374767

closes odoo/odoo#129645

X-original-commit: a10d1d305696f7ece38e7d3446c067338c411ea2
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-07-26 12:00:27 +02:00
Pratik Raval ee31690988 [FIX] mass_mailing{_sms}: fix A/B testing description
Before this commit
- When we were creating an alternative version in the SMS app for A/B
  testing, we were not able to see different options like select
  winner, compare version, etc in it because of ab_testing_mailings_count
  was counting only records with type equal to mail, in method
  _compute_mailing_mail_count. So, count will never increase
  and those buttons will never be visible.
- We were not able to sent the mail manually in auto mode.
- We were able to see the 'Send winner Now' and 'Send this as Winner'
  buttons even if no a/b test mail were send.

So, with this commit
- We have added the ab_testing_sms_count compute field in utm.campaign
  and ab_testing_sms_count related field in mailing.mailing to deal
  with the above problem.
- The auto mode can now send a winner manually.
- We introduce a new compute field is_ab_test_sent for computing
  whether the any sibling mails of a/b testing are sent or not,
  depending on that we hide / show buttons.

TaskId-2713198

Part-of: odoo/odoo#88997
2023-07-17 12:05:48 +02:00
Antoine Guenet 3bfccb19b1 [FIX] mass_mailing: ensure base64 images in mso comments get converted
Base64 images get converted to attachments. However, if they are in a
mso comment, they were not converted.

X-original-commit: 2fa0694227a7beb6a000c2e8219fdd8c073cf348
Part-of: odoo/odoo#124465
2023-06-09 17:01:39 +02:00
Antoine Guenet 897c47a5ac [FIX] web_editor: convert background-images without flattening them
Prior to this fix, elements with background images were converted to
images via the html2canvas library. This made them work in Outlook at
the cost of several tradeoffs:
- the process was slow and asynchronous
- there could be no interactivity (links, buttons, etc.) in the
  converted element
- responsive behavior was wonky: if only a slice of the image was shown
  when it was converted (due to background-size cover behavior), the
  rest was lost so if more width was needed in mobile, we would be
  zooming on that slice, making it sometimes irrelevant and pixelated
This replaces all that with a conversion to VML, which is a vector
format supported by Outlook. This conversion is done only for Outlook,
which means that all other clients are getting the original background
element again.

There is a way to keep the background-size cover behavior in VML, using
the "aspect" attribute with value "atleast" but this only works on
v-fill elements and sadly putting the image on a v-fill element bugs in
Windows Mail (which is the default mail client on Windows 10 and 11) and
this client can't be singled out of mso conditionals. To get around this
issue, since this is only for desktop clients, we assume the width of
the screen to be large and mimick the cover behavior by cropping the
image to the target size. This allows us to put the image on the v-image
element and have proper rendering in Outlook and Windows Mail on
desktop.

Note:

When retrieving the image by URL in Python in order to crop it, we need
to ensure we have an absolute path. This is done - perhaps seemingly
naively - by checking if the URL contains '//'. Here's the reasoning
behind that choice. To check if a URL is absolute, we could use
`urllib.parse.urlparse` and check if it has a scheme but that would lead
to `www.odoo.com/path` being considered relative (and thus we'd add a
host to the URL even though there's already one). Instead, we could
check it it has a netloc but that would lead to the same issue since the
documentation of `urlparse` says:

> Following the syntax specifications in
[RFC 1808](https://datatracker.ietf.org/doc/html/rfc1808.html), urlparse
recognizes a netloc only if it is properly introduced by ‘//’.

Still, it would be more technically correct since `//some/path` would be
considered absolute (which it should be since it resolves to
`<current_scheme>//some/path`).

Base on that documentation, it seems that simply checking if the URL
contains '//' is pretty much equivalent to checking if it has a scheme,
with the double advantage that it's simpler and that it works for
`//some/path` as well. However, note that it doesn't solve the issue of
`www.odoo.com/path`.

In summary, here are the results with the current method:
```
http://www.odoo.com/path -> http://www.google.com/path // OK
some/path -> http://localhost:8069/some/path // OK
/some/path -> http://localhost:8069/some/path // OK
//some/path -> //some/path // OK
www.odoo.com/path -> http://localhost:8069/www.google.com/path // WRONG
```

X-original-commit: 9561ba31917024825705c876442139405e7a7957
Part-of: odoo/odoo#124465
2023-06-09 17:01:39 +02:00
Rémy Voet (ryv) 234db70d86 [IMP] *: Use the new API of _read_group for backend use
Part-of: odoo/odoo#110737
2023-04-19 21:58:27 +02:00
Martin Trigaux 69f911d994 [IMP] *: enforce usage of Markup in mail
When using message_post, the body format must be explicitly specified.
If html is expected, a Markup object should be used.
If text is given, the content will be escaped.

Before this PR:
message_post was unaware if the content of a message was HTML or
text. This lead to multiple situation where the content was
incorrectly considered as HTML and led to display errors.
In
  self.message_post(body="Hello %s!" % self.name)
if the name contained HTML, it would be evaluated.

In
  self.message_post(body="Contact Raoul <raoul@caramail.be>")
the email would not be displayed as considered as unknown HTML and
discarded by the sanitizer

Now each call must explict the type of content.
Use the escape() helper to properly combine Markup and translations.
It would also be acceptable to use Markup() to wrap a static
translation but escape is better as one can not guarantee the content
of a translation.

closes odoo/odoo#111850

Related: odoo/documentation#3612
Related: odoo/enterprise#36728
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-13 16:39:48 +02:00
Mahamadasif Ansari 9b016e828f [IMP] digest, mass_mailing: replace css variable with qweb variable
The digest currently includes a CSS variable for the company's
secondary color, but Outlook does not support it.

This commit replaces the CSS variable in the digest with the QWEB
variable. Apart from that, if the secondary colour of the company
is available, it sets it into the colour property header of the
"mass_mailing_kpi_link_trackers" in email marketing and revert the
changes in commit[1] because border-start/end is an invalid property in CSS.

commit[1] - odoo-dev@1fcd098#diff-faee7192e5f6cf07658d2ceae16380c4b5d54035ecfb9bb4848608db3f429c69L263

tast-2717426

Part-of: odoo/odoo#89549
2023-03-31 15:51:58 +02:00
amdi-odoo 5d0bdd6969 [FIX] mass_mailing: fix mailing model notes
Rewords and fix the typos in the mailing.mailing model notes.

Task-3240405

closes odoo/odoo#116756

X-original-commit: 156b901292b01e6bb6cd430caade3ae95742782b
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-28 09:27:47 +02:00
jorv d10c13bc34 [FIX] mass_mailing: More accurate next_departure taking into account cron.triggers
When the user schedules a datetime for the emailing campaign, it creates
a ir.cron.trigger entry that should run the Mail Marketing: Process queue.
This fix tries to take this into account to calculate a next_departure
datetime closer to the true moment job will be run.

When the schedule datetime is between now() and the next call datetime
for the cron job (nextcall field), current logic will always chose
nextcall given the use of max(). This can be confusing for the end-user
as the information banner in the form view will indicate the nextcall date,
which in some cases can be way farther in the futur.

While a ir.cron.trigger is not a 100% guarantee that the cron job will
run at that specific time, it will give better feedback to the user for
when he should expected his mailing campaign to be send out.

Main changes:

    simplified logic in _compute_next_departure to take into account
    the implicit creation of cron.triggers (methods action_launch and
    action_schedule)

    added test_mailing_next_departure to simulate "Send", "Cancel" and
    "Schedule Date" buttons on mass_mailing form view. Check ir.cron.trigger
    model for presence of triggers for cron job "Mail Marketing: Process queue"
    and assert if cron.trigger was created as expected

opw-3137819
original commit b98494d
some trailing whitespace got linted from commit 4cebf5

closes odoo/odoo#115068

X-original-commit: f82dec9e6433dc027391978420237efaa1d0be7d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-03-17 08:10:45 +01:00
Aaron Bohy 1f52c8edd3 [REF] *: remove form_view_initial_mode context key support
The purpose of this key was to force the form view to be in edit
mode directly when opening a record, in specific actions. This is
now automatically the case since form views are always in edit
mode. This commit thus removes the support of the key, and removes
all occurrences where it was set in the codebase.

Part of task 3179751

closes odoo/odoo#115172

Related: odoo/enterprise#38130
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2023-03-16 14:12:37 +01:00
Renaud Thiry 37348521ce [IMP] mass_mailing: remove A/B percentage limit
A/B testing was used in the past to create mutually-exclusive mailings.
Since then a 100% limit for the recipients of an A/B campaign.

As there is no technical reason for this limit and not having it allows
for a special usecase, it is replaced here with a text warning.
The usecase in question being that as the domain of the different
mailings composing a campaign may be different, users may want to
take advantage of the fact that only 1 email will be sent to each
address to avoid sending 2 mailings when only one or the other should
be sent. Consequently users may want to use 100% of the domain on
every mailing in their campaign.

As the ab_testing_total_pc is only used for that purpose the field
is removed. 'total' field  is not always accurate and is unused so
it is also cleaned up.

task-3008627

closes odoo/odoo#105639

Related: odoo/upgrade#4257
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-02-21 19:08:09 +01:00
Christophe Monniez 7255819659 [FIX] mass_mailing: use a sequence for random sampling
Since Python 3.11, sampling from a set deprecated, the population must
be a sequence.

This commit applies the suggested fix.

Also, the filtering of the deprecation warning about sampling from set
can be disabled when the python version is not 3.9. This warning was
wrongly triggered since 3.9 because recordsets are bot a sequence and a
set.
This was fixed in python 3.10, see https://bugs.python.org/issue42470

closes odoo/odoo#112450

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2023-02-14 08:03:24 +01:00
Renaud Thiry fbb808301a [FIX] mass_mailing: correct 'total' value
The percentage used for A/B test was applied even when
A/B testing was disabled. As that value is 10% by default
the 'total' was innacurate by 90% for most mailings.

task - 3008627

closes odoo/odoo#110677

X-original-commit: eb2271330e7759400dad155b72208cf7677e175e
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-01-23 13:18:59 +01:00
Thibault Delavallée 35762204a6 [REF] mail: better use and update 'auto_delete' composer field
RATIONALE

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

SPECIFICATIONS

Correctly update 'auto_delete' field

  * add missing update in onchange, to either take value from template, either
    fallback on default_get values as other fields;
  * in comment mode, actual value for 'auto_delete' is True by default. Composer
    value was not used and bypassed by a context value being True by default.
    Context key support is removed, correctly replaced by the composer field
    value itself;

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

Part-of: odoo/odoo#99482
2023-01-17 20:58:41 +01:00
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
Jérémy Hennecart (jeh) 348265db3d [FIX] mass_mailing: send at least one a/b test if possible
When there is not enough recipients for the A/B testing percentage,
we pick a minimum of one recipients (if there is at least one) to
avoid sending a/b test to no one.

task-2713198

closes odoo/odoo#107488

X-original-commit: e1fa7b10250efc790452f02490ab84d2183698ff
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-12-08 13:38:25 +01:00
dht-odoo 6bfe126313 [FIX] mass_mailing{_sms}: respect mailing_type when comparing a/b mailings
Before this commit
- When we were comparing versions, there was no such filter as
  mailing type. Due to this it will display both SMS and mail
  type records in it.

With this commit
- We have added '('mailing_type', '=', self.mailing_type)' in domain
  of compare version.

TaskId-2713198

X-original-commit: e8542e24597ad25b68104c03d4d4ed41e1efac82
Part-of: odoo/odoo#107488
2022-12-08 13:38:24 +01:00
Thibault Delavallée efe53fbe88 [IMP] mass_mailing: improve routes naming
Rename main routes, and keep a legacy for the main unsubscribe route to
keep retro compatibility for existing mailings.

Task-2710804 (Mail: Clean MailThread API)
Task-2669037 (Mass Mailing: Subscription page code cleaning)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:21 +01:00
Thibault Delavallée 6185f14807 [REF] mass_mailing: rename hash methods
PURPOSE

Overall cleaning of subscription and exclusion management code from portal.

SPECIFICATIONS

In this commit we rename methods generating tokens (for recipients and report
management). Otherwise it is hard to distinguish them as naming is not really
convenient to use

  * _unsubscribe_token -> was actually generating token for a given recipient
    on a given mailing;
  * _get_unsubscribe_token -> was actually generating token for mailing
    users to deactivate D+1 KPI reporting;

Hash for mail tracking is also moved in its own method to avoid having the
same code twice. Better delegate it to a tool sub method.

Task-2710804 (Mail: Clean MailThread API)
Task-2669037 (Mass Mailing: Subscription page code cleaning)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:21 +01:00
Thibault Delavallée 225b487a3c [IMP] mass_mailing: add helper field when targeting mailing lists
Currently there are several checks on mailed model directly in code due to
mailing list specific behavior. In order to be easier to manipulate and
a bit less low leve, a computed field is introduced for that purpose.

Indeed there are some behavior changes when the mailing runs on mailing lists
instead of directly on records. There are notably some changes in display
(choose mailing lists but mail contact is the real contact model), and in
subscription page (directly unsubscribe from mailing lists).

Task-2710804 (Mail: Clean MailThread API)
Prepares Task-2150462 (Mass Mailing: Unsubscribe flow refactoring)

Part-of: odoo/odoo#106568
2022-11-25 18:55:20 +01:00
Thibault Delavallée 3d5b012501 [REF] mail, various: cleanup usage of options in render mixin
Due to recent improvements (Jinja -> Qweb, safe rendering) rendering API
supports several ways of giving options to the rendering process. Those
have mainly two usage

  * ``preserve_comments`` : keep comments in rendered HTML, used notably
    in mass mailing or digest to keep browser-specific comments;
  * ``post_process`` : perform a post processing on rendered HTML, used notably
    to process local links and add tracking to shortened links;

All those are now given directly inside an optional ``options`` parameter
given to ``_render_field`` and its sub-method ``_render_template``.

They can also be defined as field level, using ``render_options`` field
parameter. Some fields are updated

  * composer mixin body (which impacts all inheriting models, notably
    mail composer, survey and elearning invite wizards as well as appraisal
    and appraisal feedback): post processing is now always done by default.
    It was already done manually in calls that can be simplified;
  * mail template body_html: post processing is now always done by default. It
    was already done manually in calls that can be simplified;
  * mailing body_html and preview are now post processed by default. It was
    already the case in testing wizard. Preview is updated to avoid post
    processing of links, as it was before. Remaining use case is the sending
    which uses the mail composer, therefore was already post processed;

Finally some 'compute_lang' are explicitly added in _render_field calls in
order to be explicit on what we want, instead of being unsure.

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

Part-of: odoo/odoo#106072
2022-11-21 19:55:13 +01:00
Thibault Delavallée 709a65997d [LINT] mail, various: perform a quick code linting
Purpose is to try to have code easier to read and to update by having a
common way of sorting / writing code. Reorder some fields definitions and
dictionaries, update docstrings, ... in mail applications or when invoking
mail thread API.

Additional stuff worth noting here

  * add some tagged in tests helping debugging / choosing tests to execute;
  * in a test about mail generation with server action: correctly check
    body_html field, not body which comes from the mail.message inheritance
    (currently filled due to a side effect but actual field to check is the
    html one);
  * add same check on input for ``_render_template_qweb`` as done on other
    rendering methods (even if rendering on [False] should be supported);
  * move code translation update from specific tests into main test class
    (code update due to new translations, followup of odoo/odoo@f8c2b02abe);

Some test linting done here

  * reorder mail_render tests, remove some duplicated tests;
  * reorder mail_template tests, remove some duplicated tests;

Task-2710804 (Mail: Clean MailThread Posting API)

closes odoo/odoo#106025

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-11-18 14:00:30 +01:00
Pratik Raval cc120c2141 [IMP] various: reduce wizards modal size
With this commit, the size of the following wizards will be reduced to medium:
\1 Schedule mailing (Email Marketing)
\2 Test mailing (Email Marketing)
\3 Lost reason (CRM)

taskID- 2701035

closes odoo/odoo#96500

Related: odoo/enterprise#29746
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-14 19:13:55 +02:00
Pierre-Yves Dufays ac67e6a8df [IMP] base,{fetch}mail,l10n_it_edi,{test}mass_mailing:prevent using arch server
Prevent archiving in-use mail servers by displaying an error message that
lists where it is still used, allowing to easily identify what need to be
updated before being able to archive the mail server.

Additionally,
- prevent the use of archived server as a fall-safe
- when duplicating a mailing with an archived mail server, replace mail
server by the default one

Detailed explanation:
1. A check has been added that raise an exception when trying to connect to the
smtp server or send an email when the server is archived.
With that solution,
- testing the connection of an archived server displays an error telling that
an archived server cannot be used.
- if a mail is still sent with an archived server, mail are in error :
"Connection failed (outgoing mail server problem)"
This fail-safe ensures that no mail will be sent through an archived mail server
and that the user will get some feedback about it.

The same fail-safe for the incoming mail server has been added.

Notes:
- the connection will outlive the archiving of a mail server still allowing
to send email through the archived server until the connection is closed. But
connection are not kept for long so this shouldn't be a problem.
- it cannot be tested because the connect method return immediately in test
mode.

2. When a mail server is archived, an user error is raised if it is in-use.
The implementation relies on each module to override the method
"_active_usages_compute" in "ir_mail_server" to complete the list with
user-friendly message describing the active elements that could send mail
through the mail server. This has been implemented for:
- l10n_it_edi: server used to send e-invoice
- mail: optional server configured for template
- mass_mailing:
-- default mail server
-- active server configured for mailing

Mail server are referenced in other elements but are not active anymore, it is
just for temporary or history purpose. Those references doesn’t prevent the
archiving of the mail server:
- mail_message
- wizard survey_invite and compose_message
- res_config_settings

Task-2821516

closes odoo/odoo#91240

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-01 15:32:44 +02:00
Dharmraj Jhala 3d8faf9b9d [IMP] mass_mailing: do not reset campaign while enabling a/b testing
Right now, on an existing mailing, if we enable the a/b testing and there's
already a campaign set, we remove it and add a newly create campaign that
matches the name of current mailing. Also, while duplicating a campaign, the
`ab_testing_completed` field should not be copied over.

This commit improves the behavior and only creates a new campaign if there's
not one already set on a record, and by preventing `ab_testing_completed`
from being copied.

TaskID-2653806

Part-of: odoo/odoo#77768
2022-08-12 11:28:32 +02:00
Pierre-Yves Dufays da5841ca3a [FIX] mass_mailing: spurious help overlay
When duplicating a mailing with a template already set, especially with a slow
connection, hitting the save button as soon as possible was causing the help
overlay to be superposed with the template. This solves the problem.

Task-2937045

closes odoo/odoo#97930

X-original-commit: 89ecb17f56b34b7e3875fa36cde70a2666dca4d8
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-08-11 11:01:01 +02:00
Fabien Pinckaers 3363e55cac [IMP] cleanup of help messages in all modules
This commit aims at removing unuseful help message to:
1/ reduce translators work, to focus on more useful translations
2/ not sending unuseful information in load_views
3/ reduce help message to useful messages, so that we can mark
   fields having a tooltip in the future UI.
4/ some cleanup of existing messages too

The main use cases:
- REMOVED: help redundant with the field name, providing no extra info
- MOVED TO COMMENT: technical help messages, that should not be in UX

closes odoo/odoo#97279

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-08-02 00:26:53 +02:00
Pratik Raval 992ef282ac [FIX] mass_mailing(_sms): make 'Retry' button generate a cron trigger
When we use the "Retry" button in case of a failed SMS mailing, it puts
the mailing back to the queue, which will be processed when on the next
cron call of `Mail Marketing: Process queue`  (generally on the next
day). However, it should immediately generate a cron trigger in this
case so that SMS(s) can be sent right away.

The same goes for Email Marketing, where it should immediately generate
a cron trigger so the mailing can be sent immediately.

With this commit, instead of simply putting the mailing back to the
queue, we utilize the method `action_put_in_queue` which immediately
generates the cron trigger in both cases.

taskID-2760101

closes odoo/odoo#94269

X-original-commit: 572a7effb271ad134bb936751292668ae7b2b590
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-06-27 10:10:34 +02:00
grzana12 bbf936f40d [FW][FIX] mass_mailing: check fields for seen list are stored before going into SQL
Seen list (aka already mailed records) computation is done in SQL to speedup
computation. It is based on an heuristic to find fields to check (either
a partner, either an email). However it checks fields are present in model
but does not check they are stored. This leads to traceback if fields
are not stored.

Task-2852943

X-original-commit: fa11070d4533475778ea933225e30d06a09406bc
Part-of: odoo/odoo#94532
2022-06-24 15:00:54 +02:00
Sylvain Francis 7b179f411a [FIX] mass_mailing: Allow reply_to mode 'email' for mailing contacts
Before this commit:
When creating a mail template for a marketing campaign targeting mailing
contact, the reply_to_mode would be set to 'thread', and the reply_to
field would be be read-only. Since there is no way to target a mailing
list from a marketing campaign (see the domain on marketing.campaign's
model_id), and there is no default followers mailing.contact, email
responses would be "lost".

After this commit:
The reply_to_mode is set to 'email', and the reply_to is set
accordingly

OPW-2803314

closes odoo/odoo#94507

X-original-commit: f47da5d3183479597b572046566f67621f6db837
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Francis Sylvain (syf) <syf@odoo.com>
2022-06-24 10:30:15 +02:00
Thibault Delavallée 19b02759ca [LNT] mass_mailing(_sms): perform various linting
PURPOSE

Reorganize addon according to guidelines, helping finding and updating code.

SPECIFICATIONS

Perform various code linting and cleanups, line breaks, linter issues...
No code or feature change should occur with this commit.

Task-2864264 (Mass Mailing Module Reorganization)

Part-of: odoo/odoo#92509
2022-05-31 16:02:24 +02:00
MAHAMADASIF ANSARI c297dc8604 [IMP] mass_mailing: improve UX of favorite filter
If you do not have favorite filters available in the mass mailing for
selected model, we display empty drop down, which is not ideal.

This commit improves the behavior with following changes:
- If there is no filter available (for this target) and no condition
  set in the mailing domain, do not display anything
- If mailing domain is set but there is not filter available, show a
  custom label "Save Filter as Favorite" save icon next to it

Ent PR: https://github.com/odoo/enterprise/pull/26308
task-2711258

closes odoo/odoo#87673

Related: odoo/enterprise#26308
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-05-30 12:11:24 +02:00
Raphael Collet 6cf8db906f [REF] *: adapt code to new flush API
closes odoo/odoo#87527

Related: odoo/upgrade#3497
Related: odoo/enterprise#26939
Signed-off-by: Raphael Collet <rco@odoo.com>
2022-05-25 18:00:47 +02:00
Yolann Sabaux aed71fc897 [FIX] mass_mailing: allow duplicate in test mode
Steps to reproduce:
- In Marketing Automation - Campaigns
- Select the demo campaign
- Click on "Launch a test"
- Select Brandon
- Send the two mails from the campaign
- Redo all the steps with a new Test but the same contact

Issue:
- The mails won't be sent

Cause:
- Since for this campaign we already sent these mails to Brandon, the mails will be considered as duplicate in:
https://github.com/odoo/odoo/blob/11b7d89114178fa43545fb8e6224cb4ccbcf8ec1/addons/mail/wizard/mail_compose_message.py#L499

Solution:
We want to make sure that:
- when doing a test, since there is only one linked partner to it, we can send as many mails as we launch tests.
-> repeated tests make sense as we want to fine tune campaigns and maybe get feedback from actual customers
- when launching the actual campaign, there are no duplicates (normal flow) but that eventual test-customers receive the final campaign

In order to do that, we have to filter out from the seen_list
https://github.com/odoo/odoo/blob/9b25a4b5a782146e8c0b41eb75ceea7ac3cd3abf/addons/mass_mailing/models/mailing.py#L736
the test-records.

opw-2810298

closes odoo/odoo#92062

X-original-commit: 4cebf53aa89c21ef255f5d5da450fdf98c4c9ac1
Related: odoo/enterprise#27660
Signed-off-by: yosa-odoo <yosa@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-24 10:40:17 +02:00
Christophe Monniez 65c8814a2f [FIX] various: replace deprecated currentThread method
CurrentThread is now really deprecated in Python 3.10 ... Time to
change.

Part-of: odoo/odoo#91927
2022-05-23 08:29:52 +02:00
Patrick Hoste d041cbe6ab [IMP] mass_mailing: ignore past date when scheduling
PURPOSE

With this commit, when trying to schedule a mailing with a
past schedule_date one will be asked a new date.

LINKS

Task-2833321

closes odoo/odoo#90891

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-16 11:40:50 +02:00
Paul Morelle 19f05de51d [FIX] mass_mailing: ensure test templating is true
When using a template with inline placeholders in the body, the Test
button will replace the placeholders, but they will remain in the final
body when the mass mailing is sent for real.

This commit fixes this issue by using the correct rendering engine for
the Test button too.

OPW-2819032
OPW-2828461

closes odoo/odoo#89346

X-original-commit: b0dcd2fa35d949dd722f1bc70401ceeb7f5d8231
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Paul Morelle <pmo@odoo.com>
2022-04-25 10:27:44 +02:00
Thibault Delavallée 93b6282ed6 [FIX] various: remove unnecessary .id in domains
Even if ORM normally filters them out, no need to specify .id in domains.
This leads to better and easier to read queries / domains.

Task-2816580

closes odoo/odoo#85648

Related: odoo/enterprise#24911
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-04-12 08:21:08 +02:00
std-odoo e0b80ac30e [IMP] mass_mailing: filter the mailing templates based on the target
Purpose
=======
Filter the mailing templates based on the model defined on the mailing,
so the user will see the most appropriate templates.

Task-2593231

Part-of: odoo/odoo#79174
2022-03-16 13:16:13 +01:00