Commit Graph
13 Commits
Author SHA1 Message Date
David Beguin 46d6c09c75 [IMP] mass_mailing: avoid to activate generic merge on mailing.list model
As the mailing.list model has his own custom merge method, this model should
not be candidate to activate the generic merge method comming from data_merge
module.

This change is done here to avoid creating a bridge module in enterprise
only to add this flag. We can consider that the flag is linked to the custom
merge method itself. If a model has a custom merge method, it should be marked
as 'having a custom merge method'.

Task ID: 2459416
Linked ENT PR: odoo/enterprise#17553
2021-06-01 13:34:53 +00:00
Thibault Delavallée ed508ee1bd [REF] mass_mailing: move mailing capability on model
PURPOSE

Remove hardcoded list of models on which mailing is possible. Indeed it is
not modular and not really smart with enterprise code not being reachable
in community.

SPECIFICATIONS

Replace hardcoded list of models on which mailing (both mail or sms) is
possible by a computed searchable field on ``ir.model`` based on a class
attribute.

It allows to cleanly define models having mass mailing capabilities and add
this attribute in bridge modules (when existing) or directly on base model
definition to avoid bridge modules.

In this commit we introduce a basic ``_mailing_enabled`` class attribute
activating mailing on model.

Mailing models may also have a ``_mailing_get_default_domain`` method allowing
to define a custom default domain when sending a marketing mailing on records
on this class.

Mailing models can now define a ``_mailing_get_opt_out_list(_sms)`` method
allowing to define custom behavior to fetch opt-outed records. Instead of
defining a model-based behavior on Mailing itself, it now calls the model
defined one. We still have two methods, one for mailing and one for SMS
opt out computation as it relies on different underlying models and fields.

LINKS

Task ID-2431217
COM PR odoo/odoo#67322
ENT PR odoo/enterprise#16876
UPG PR odoo/upgrade#2236
2021-05-26 07:57:47 +00:00
Thibault Delavallée dce3fa2fec [FW][FIX] mass_mailing: correctly update list subscriptions when updating contacts
There is a missing depends on subscription_ids fields, meaning it is not
correctly refreshed when contacts are updated. When dealing with m2m using
the o2m model as relational table, depends have to be specified on field
itself to allow recomputing the fields.

Task ID-2431217
COM PR odoo/odoo#71140

X-Original-Commit odoo/odoo@11ffeddf23

X-original-commit: 37bad522bcaf9a6db2f676286fb9ceb1a188dcab
2021-05-25 14:20:08 +00:00
Dharmraj Jhala 9ef6cc2663 [FW][FIX] mass_mailing: show correct recipient count in merge wizard
Right now, when o2m/m2m are set from default_get from web client,
the compute methods from the records being set yield `NewId` when
we try to get ID for the record, even if the records are existing.
It can result into wrong computation when the ids of the records
are used in preparing the data.

The same thing happens in the wizard that is used to merge mailing
lists. When we select multiple mailing lists and open the wizard
to merge them, they are set in the `src_list_ids` of wizard, but
number of recipients are always zero for them, because the method
that computes `contact_nbr` (recipients) on mailing lists fetches
data from the query, but we can't match (or find) the stats from
query result because we don't get the actual ID in recordset for
existing records.

This commit fixes the behavior by using `_origin` on the records
while finding data in the compute method, and thus getting the
correct recipient count.

Task ID-2471692
COM odoo/odoo#67213

closes odoo/odoo#69820

X-original-commit: 71430334bffa4b5da3f9374c734e6231cb42a7c7
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-26 09:03:10 +00:00
nounoubensebia 52df97e4f3 [IMP] mass_mailing: improve list duplication and protect "opt-out-ness" of contacts
Before this commit, on duplication, the contacts who opted-out from the
original list have the opt-out field set to False on the duplicated list.

After this commit, on duplication, for a contact who has opted-out from the
original list,the opt-out field will be set to True on the duplicated list,
Because when a recipient opt-out from a mailing list, chances are high that he
does not want to be included in the new duplicated list.

This commit also brings some fixes to the update and create methods on the
mailing_contact_subscription model so that

- The unsubscription_date is set to now only when no unsubscription_date is
  given, because when another value for unsubscription_date is given by the
  user it should be applied

- The opt_out field is set to True when the user sets an unsubscription_date,
  because when a date is set for unsubscription_date, it means that the user
  has opted-out from the list

We also update name of mailing list when duplicating it, adding a copy
mark to it.

Finally we also avoid copying mailing_ids through m2m relationship as it
may impact existing mailings.

Task ID-2431383

closes odoo/odoo#65277

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-03-02 14:19:34 +00:00
Aurélien Warnon 8cd623e1d5 [IMP] mass_mailing[_sms]: pimp mailing list views & demo data
PURPOSE

Improves various views related to the mass mailing lists to help the user to
check the "health" of its lists at a glance.

SPECS

Introduce statistic fields on mailing.list:
- Total number of contacts (replaces the previous number of valid emails)
- Number of valid email contacts
- Number of valid SMS contacts
- Number of mailings sent using the list
- Percentage (and total count) of opted-out contacts
- Percentage (and total count) of blacklisted contacts
- Percentage of contacts having at least one bounced message

The statistics are shown on the kanban and also on the form view where they are
used to quickly reach the associated mailings / contacts.
Demo data were slightly adapted to show more interesting demos on views.

On a technical point of view, the various counts of contacts are made in a
single query using CASE WHEN syntax.
We need some entry points in the query to be able to dynamically add fields and
joins in the mass_mailing_sms app, but it's better than copy/pasting multiple
times a very similar query.

LINKS

Task 2182622
UPG PR odoo/upgrade#1990

closes odoo/odoo#53221

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-12-02 09:39:59 +00:00
Mariska Archielli (ram) a2e77a8419 [FIX] mass_mailing_sms : traceback on create contact list
Fix traceback when creating a new contact by checking the id list is not empty.

Task ID : 2302578

closes odoo/odoo#58681

X-original-commit: 31f2bb5e494965d31f5e49d47908fd4b5eb64077
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-09-28 13:16:07 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +00:00
Thibault Delavallée bea9bc3d6c [IMP] mail, mass_mailing, phone, survey: call toggle_active / action_(un)archive when possible
Purpose of this commit is to call toggle_active or archive / unarchive methods
instead of manually writing on active field. Indeed this allows to trigger
business code related to archive / unarchive which is normally located
in toggle_archive (called by action_archive and action_unarchive).

Task ID 2170708
Community PR odoo/odoo#46563
2020-04-03 12:59:28 +00:00
jvm-odoo 1a7e0fb01b [FIX] mass_mailing: remove inactive lists from mass mailing
Issue

	- Install Mass Mailing
	- Create 2 mailing list (x & y) with differents
	  contacts
	- Create a mass mailing with x & y, send it

	Ok, sent to everyome

	- Archive mailing list y
	- Duplicate the last mass mailing, send it

	Not ok, sent to y contacts too

	When a list is archived, I can't manually
	remove it from the mass mailing (it disappears)

Cause

	When archiving a list, it still remains in
	contact_list_ids

Solution

	Prevent archiving a mailing list if any mass mailing
	using it exist with state != 'done'

	Re-evaluate the domain field at copy

OPW-2202111

closes odoo/odoo#47094

X-original-commit: 4346f1da7a26a11f49c8e76f6ed8d6d6078a1d8a
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-03-06 14:27:02 +00:00
Raphael Collet 9920f20e4c [IMP] models: ORM speedup
This branch is the combination of several optimizations in the ORM:

* store field values once in the cache: the cache reflects more
faithfully the database, only fields that explicitly depend on the
context have an extra indirection in the cache;

* delay recomputations by default: use method `recompute` to explicitly
flush out pending recomputations;

* delay updates in method `write`: updates are stored in a data
structure that can be flushed efficiently to the database with method
`flush` (which also flush out recomputations);

* make method `modified` take advantage of inverse fields to inverse
dependencies;

* filter records by evaluating a domain on records in Python;

* a computed field with `readonly=False` behaves like a normal field
with an onchange method;

* computed fields are computed in superuser mode by default.

Work done by Toufik Ben Jaa, Raphael Collet, Denis Ledoux and Fabien
Pinckaers.

closes odoo/odoo#35659

Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
2019-08-20 12:43:59 +00:00
Thibault Delavallée c7a14e9109 [REF] mass_mailing: prepare mass_sms
PURPOSE

SMS are a powerful marketing tool. For instance it is perfect to announce a
sale or to communicate a coupon code, to welcome a new customer in a fidelity
program, ...

Purpose of this task is to integrate SMS sending in batch in mass mailing. It
will use same mailing objects but sending SMS instead of emails. Some metrics
and flows will have to be slightly updated at the same time.

SPECIFICATIONS

Prepare mass mailing module to addition of mass_mailing_sms.

Mailing model: mailing type
  * add a mailing_type selection field;
  * mass mailing contains only 'mail';
  * synchronize medium accordingly;
  * update actions of mass mailing application to add a domain on mailing
    type being 'mail';

Mailing contact
  * remove is_email_valid field as its purpose is achieved by email_normalized
    field coming from address mixin (added by blacklist management);

Mailing contact subscription
  * clean a bit fields and views as this should stay a technical model;

Trace model and report: trace type
  * add a trace_type selection field;
  * mass mailing contains only 'mail';

Various
  * clean some bits of code in views, remove old code bits;
  * add anchors to ease view inheritance to be able to customize views for
    SMS mailings;
  * ensure all views in mass mailing filter content on mail type (mailing
    and traces being type mail only);
  * rename some methods to be more updated with current guidelines, notably
    main action methods;

LINKS

Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
2019-08-12 12:00:22 +00:00
Thibault Delavallée 772e1c0cc4 [REF] mass_mailing: rename mail.mass_mailing.{.contact{_rel}, list{.merge}} models
PURPOSE

Mass mailing is currently a bit messy. As SMS will be added as a way to notify
people in mass through SMS let us take this opportunity to somehow clean this
application: organization, light code cleaning, model renaming.

SPECIFICATIONS

Rename mail.mass_mailing.list and mail.mass_mailing.list to mailing.list
and mailing.list.merge. Rename mail.mass_mailing.contact to mailing.contact.
Rename mail.mailing_list.list_contact_rel to mailing.contact.subscription.
Rationale :

  * those new names are easier to understand: mailing.list and mailing.contact
    are less mail-related, especially taking into account that SMS will allow
    to be less mail-oriented;
  * those names are easier to read / find / understand;
  * align wizard and sub-models naming with the main naming;
  * have a mailing as first part of namespacing;

MIGRATION

mail.mass_mailing.list model -> mailing.list
mail.mass_mailing.list.merge model -> mailing.list.merge
mail.mass_mailing.contact model -> mailing.contact
mail.mass_mailing.list_contact_rel model -> mailing.contact.subscription
mail_mass_mailing_contact_list_rel table -> mailing_contact_list_rel (specific
case of a decorated m2m)

fields updated (no column change)
  * mailing.list: subscription_contact_ids -> subscription_ids

LINKS

Task ID 2037906
Preparing task ID 1997464 (SMS addition in mass mailing)
PR #34938
2019-07-17 15:50:33 +00:00