Commit Graph
54 Commits
Author SHA1 Message Date
Thibault Francois 3af61a49f4 [FIX] sms: fix name_search
Problem
-------

_search_is_mail_thread_sms is looking for ir.model
in the database and then fetch them from the registry
without verification. This can lead to key error
when a model is present in the database but not in
the python anymore. This situation can happen
after a migration.

Solution
--------
Check the model is present in the registry

closes odoo/odoo#60001

X-original-commit: 448626d86a1f06b9f8a7a88111f7cb01600488cd
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-10-14 13:33:49 +00:00
Thibault Delavallée fcd10b3691 [REF] iap, various: reorganize IAP module organization
PURPOSE

Clean and improve IAP tools integration in Odoo. Introduce bridge modules
to extract common features, notably for CRM and Partner.

SPECIFICATIONS

In this commit we reorganize IAP module to better understand its content
and ease future cleaning

  * have models separated from tools;
  * rename some tools to find their grep. An iap_ prefix is added to ensure
    we don't clash with other global functions or methods;
  * perform some linting;

To provide backward compatibility support we keep some import in init file of
IAP addon. Standard code is about to be updated but we want to avoid too
much issues when migrating code to 13.5 . Compatibility layer will be removed
after v14 final freeze.

LINKS

Task ID-2248367
Community PR odoo/odoo#53214
Enterprise PR odoo/enterprise#11258
Upgrade PR odoo/upgrade#1363
IAP PR odoo/iap-apps#191
2020-08-18 11:41:59 +00:00
Swapnesh Shah a49e38879f [IMP] sms: do not copy error
Error message should not be copied for obvious reason.

closes odoo/odoo#55644

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-07 16:46:19 +00:00
Dharmraj Jhala 0e57bfd453 [FIX] sms, test_mail_full: make contextual action work for sms templates
While creating contextual action for an sms template, the composition mode
may be decided on the fly, based on number of records and on context the key
`default_composition_mode`, which is set to 'guess'.

It used to work before a recent refactoring[1], because the composition
mode was changed in the default_get, and was being set to appropriate
value instead of 'guess'.

After this refactoring, the composition mode is not being set in the
default_get but is being computed, so the key `default_composition_mode`
tries to set the composition_mode selection field to 'guess', which is not
available in the selection values, resulting into traceback.

This commit fixes the issue by renaming the context key(removing 'default'
prefix) to avoid setting the mode directly and instead let the compute method
decide the composition mode based on context key and number of records.

[1] - https://github.com/odoo/odoo/commit/e02137c48562d824e3e01054e31dae383e5843e2

TaskID - 2286959

closes odoo/odoo#54938

X-original-commit: 2b9ea3d93445e05cb0440aab33f2bf9e066b0fa5
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-07-27 07:27:18 +00:00
Xavier Morel 0d6bb14cfd [IMP] base, sms, mail: change calling conventions of server action runners
Taking a self and a separate action seems unnecessary given self *is
an action*.

Only do this change for the "new" naming scheme, so the old one keeps
working as-is.
2020-06-17 11:28:54 +00:00
Xavier Morel 5f310366a0 [IMP] base, sms, mail: make server action runners not public
There is no reason to call these directly, in fact it's not really
possible to do so as they expect an `action` object as first
parameter.

* warn against the presence of rpc-public runners
* move runner selection outside of ``run``
* improve doc a bit maybe
2020-06-17 11:19:27 +00:00
Martin Trigaux ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
std-odoo 3a8166d74a [FIX] sms: fix empty phone number in the mass SMS composer
Bug
===
Go to CRM, in the lead list view and select a lead without
phone number. Then, click on the action "Send SMS Text Message".

Then, enter in debug mode and go to the SMS form view. The
number will be "0" instead of being empty.

Task-2244195

closes odoo/odoo#51389

X-original-commit: 8805c16bfb1bfb001e674d9a2755ad0e98fcb834
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-05-18 08:26:50 +00:00
Rémi Rahir 7287800101 [IMP] sms: Add new failure status for unregistered accounts
Since January 2020, users are required to validate their IAP account via
SMS code validation. This new behaviour needed to be properly ported to
the client to correctly inform the user.

This commit adds support of a new failure_type: 'Unregistered Account'.

Task #2209567

closes odoo/odoo#48512

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-05-12 16:39:40 +00:00
Thibault Delavallée c5c7a02302 [FIX][IMP] sms: create failed notification when SMS-ing record without any phone number
When no valid phone number was found on a record, and when using _message_sms
directly, no SMS and no notification was created. You could therefore think
everything was ok while it was actually not.

Instead we now create failed notifications. It allows to be notified of it
and fix numbers through cancel / resend wizards.

Task ID 2244192

closes odoo/odoo#50486

X-original-commit: baecdfaa2d31714a20d1fb8af7799af1805cd939
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-04-30 14:47:49 +00:00
Thibault Delavallée 9a3581d925 [FIX] sms: fix crash when using composer on a record without valid phone number
When no valid phone number was found on a record, and when using the composer
in single recipient mode, you had a crash at sending as composer tried to
write on a field called False.

Instead we just take the first available phone field of the record. As they
are all void we can update them safely.

Task ID 2244192

X-original-commit: 2306d7d79d8e64597912f15365cede7473589731
2020-04-30 14:47:49 +00:00
Thibault DelavalléeandRémy Voet 42b5ec0384 [LNT] mail: lint and reorder mail_notification files
In this commit we order fields more logically to ease reading and prepare
future modifications. We also rename the class and some field strings to
be more user friendly.

LINKS

Prepares Task ID 2238597 (clean notification models)
Prepares Task ID 2083854 (improve mass mailing technical flows)
PR #49891

Co-Authored-By: Rémy Voet <ryv@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2020-04-22 08:40:04 +00:00
Sébastien Theys dea52493b8 [IMP] mail, sms, snailmail, test_mail_full: adapt mail.notification
The purpose is to have more common code for failure and notifications, with less
override in `sms` and `snailmail`.

task-2176017

closes odoo/odoo#44170

Related: odoo/enterprise#9140
Related: odoo/upgrade#918
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-04-17 12:17:57 +00:00
Adrian Torres 1daf8eb127 [FIX] *: set ondelete policy of required Selection fields
With this commit, Selection fields with `required=True` which are
extended via `selection_add` are given proper ondelete policies to
ensure the cleanup of records containing these extended options during
uninstall of the extending module.

This commit also cleans up leftover uninstall hooks that were being used
to handle the same set of problems prior to the ondelete mechanism being
implemented for Selection fields.

closes odoo/odoo#46325

Related: odoo/enterprise#9117
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-03-30 13:42:04 +00:00
Thibault Delavallée 2835e0ba38 [MOV] mail, sms: move language computation in render mixin directly
PURPOSE

Merge rendering tools used in mail and sms templates as well as partially
in mailings and move them directly in mail.render.mixin.

SPECIFICATIONS

Move tools related to language computation from mail.template model to the
mail.render.mixin. It allows to update both

  * mail.template: simply update calls accordingly;
  * sms.template: remove code doing what is now available through mail.render
    .mixin inherit;

Lang field is moved to mail.render.mixin as it is used notably for the language
computation. It therefore adds the field on mailing.mailing model although
not used currently.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
2020-03-24 10:24:42 +00:00
Thibault Delavallée 822f468059 [MOV] mail: move rendering code to mail render mixin
We also have to update code calling directly the rendering itself. Indeed
some code bits does some rendering directly on jinja-enabled input and not
through templates. Those calls have to be updated accordingly.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
2020-03-24 10:24:19 +00:00
Thibault Delavallée aa31e67716 [REF] mail, sms: reorganize {mail.sms}.template and mail.render.mixin fields and add docstrings
PURPOSE

Clarify mail.template, mail.render.mixin and sms.template code organization.

SPECIFICATIONS

Reorganize fields according to their main use.

Remove an unnecessary onchange in mail template model. As "model" field on mail
template is a computed field its computation is sufficient.

Add some docstrings and code separations.

Prepare future code change.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
2020-03-24 10:24:16 +00:00
Florimond Husquinet (fhu)andThibault Delavallée f685e70616 [IMP] sms: allow to edit number when sending an SMS to one recipient
After this commit

  * the SMS button is visible next to a phone number in mass_mailing, and
    mass_mailing_sms
  * when sending an sms to a single contact, its phone number is now an
    editable field in the wizard and there is a warning if the number is
    invalid;
  * if operator updated the recipient number, update record number according
    to the new number only in single recipient mode (aka, solving number
    issues directly from interface);

LINKS

Task ID 2088303
Community PR odoo/odoo#40482
Upgrade PR odoo/upgrade#873

Co-Authored-By: Florimond Husquinet <fhu@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2020-03-05 11:27:01 +00:00
Thibault Delavallée e36661ecd9 [REF] sms: improve _sms_get_recipients returned information
Purpose is to improve information given back, adding notably

  * whether the value comes from the customer (partner_id field) or directly
    from the record we are looping on;
  * the actual field used when no specific field is enforced;

LINKS

Task ID 2088303
Community PR odoo/odoo#40482
2020-03-05 11:04:49 +00:00
Debauche Stéphane 991eb9a17b [FIX] sms: ensure chatter / SMS have the same content
When we send a SMS in the contact form view, exact body is sent by SMS and
displayed in chatter. If some manual HTML is added chatter will display it
as HTML while sms receive HTML tags.

We want that the SMS content in the chatter is the same as the SMS sent and
that HTML tags are removed to avoid being interpreted.

To achieve that goal we call html2plaintext in ``_message_sms`` and in
``prepare_log_body_value`` that are two entry points to send SMS.

We also update ``html2plaintext`` to strip result in order to avoid having
unnecessary spaces left.

Task ID 2126123
PR #40441

closes odoo/odoo#46362

X-original-commit: 4b7b14a5ea5e6ab521838c01813fa478154682fd
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-02-26 15:12:03 +00:00
Jason Van Malder ee8a30a19b [FIX] sms: fix context action not deleted when unlink template
Issue

    - Install Calendar
    - Technical > SMS templates > Calendar reminder > Add context action
    - Calendar > Tree view > meeting > action is there
    - Delete SMS template and/or uninstall calendar_sms

    Template deleted but action still there with a traceback
    when you click on it.

Cause

    The action is never deleted.

Solution

    Delete the action when the template is deleted.

OPW-2161653

Closes #42328

closes odoo/odoo#43984

X-original-commit: eb95f06f19c60babc775de57813a293ffc35c581
Signed-off-by: Jason Van Malder (jvm) <jvm@odoo.com>
2020-01-27 09:06:19 +00:00
shivam shah 92cf2474a2 [IMP] base_automation,sms: Improve the interface of automated action
Below points are improved in automated action
- Set no_create on model_id, crud_model_id, partner_ids, and channel_ids
- Set widget many2many tags and change string for trigger_field_ids
- Rename 'Trigger Condition' to 'Trigger'
- Change on_change_fields into a many2many to ir.model.fields
- Set 'Hours' as default of field trg_date_range_time
- Rename label of crud_model_id to 'Target Model'
- Rename label of sms_mass_keep_log to 'Log as Note'
- On creation of template set the default model
- Hide the 'Security' tab
- Set no_create on fields resource_ref and col1
- Make 'value' readonly when col1 is not set
- Rename 'Link using field' to 'Link Field'

Task-2082503

closes odoo/odoo#39622

Closes: #39622
Related: odoo/enterprise#6515
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-11-26 07:35:34 +00:00
laa 72aa049844 [IMP] mail, mass_mailing: add dynamic placeholder mixin and use it in mailing and templates
PURPOSE

Upgrade the "mass_mailing" and "mass_mailing_sms" modules with a dynamic
placeholder generator as it already exists in "mail module" as depicted in
https://www.screencast.com/t/cnFA0gIY.

SPECIFICATIONS

As duplicated code already exists for that and that a third version of this
code has to be added, instead create a mixin for this dynamic placeholder
generator to avoid code duplication.

Thereby

  * a mail.render mixin for the dynamic placeholder generator must be
    created in mail;
  * dynamic placeholder generator code present in mail.template.py must be
    moved to that mixin and replaced by a simple inherit;
  * use the mixin in

    * mail templates: mail.template.py (mail module);
    * mass mailings: mailing.py (mass_mailing module);
    * sms templates: sms.template (mass_mailing_sms module);

In a near future, some code will be added in this mixin, notably the template
rendering that could be moved outside of mail.template core model and moved
in that rendering mixin.

LINKS

Task ID 2070612
PR #36722

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-11-07 16:19:37 +00:00
Adrian Torres 3da477dfc5 [FIX] *: adapt code to comply with new ondelete policy
The ondelete policy must be explicitly set for m2o fields whose inverse
is a reflection model (ir.*)
2019-11-07 08:39:17 +00:00
Thibault Delavallée 31aa195efa [FIX] sms: set correct value of batch when contacting IAP sms
Batch of 10 text messages was ok for testing. Production environment should
be able to handle more of them.

LINKS

Task 2076366 (send now)
Task 2067873 (template access)
PR #37298
PR odoo/enterprise#5750
2019-09-25 11:12:51 +00:00
sri-odoo ec9eadc352 [REF] sms: replace mail/systray fail icon
Use SVG format to improve rendering in HiDPI display while keeping tiny
the file size.
2019-09-22 09:33:17 +00:00
Remy Voet 428da3d539 [FIX] sms: number is actually not really required
sms, in the form view of sms composer (mass composition) : we got a blocking
message when we validate the composer sms with records which doesn't have a
phone number.

However we generally explicitly handle void numbers: in composer in comment
mode there is an User Error, and mass mode has specific error code to put on
sms records telling number is void (and sms is in error, meaning it will not)
be sent.

As sms record is required notably for mass mailing traces and marketing
automation traces we have to keep sms records with void numbers. We therefore
remove the required attribute on sms record.

Task ID 2073016 (sms fixes)
PR #37185
2019-09-20 13:44:09 +00:00
ryv-odoo 8e2da3b4d6 [IMP] (sms_)mass_mailing: improve interface
- Change the name of "Mass SMS" by "SMS Marketing"
- Improve the Mass Mailing views (kanban, form)
- Improve the Mass SMS views (kanban, search, form)
- Hide the sanitized numbers from views (sometime replace by mobile)
- Fix demo data of sms
- Explain the language field of sms template
- Improve the render of the sms composer wizard

TASK_ID : 2053631
2019-09-12 14:53:44 +00:00
ryv-odoo e4afa5d6d0 [IMP] sms: allow to create a sms context action
In the SMS template, we add the ability to create (and remove)
a contextual action on the targeted model from a sms template.
We change the sms composer to guess the composition mode,
and then to be usable by contextual action. The guess compostion mode
works differently if there are multiple target
selected (mass) or a single target (comment).

TASK_ID : 2053631
2019-09-12 14:53:44 +00:00
ryv-odoo 8ef1543908 [FIX] sms - mass_mailing: fix some bugs
- Cancel button in the sms form view not related to a action :
When we click on the cancel button of the sms form view, get traceback.
Fix the issue by adding the cancel action in sms model.

- Mass mailing contact - False as the display name :
The display name was the mail address but when the contact didn't have
mail address a ugly False was print to described the contact (form view).
Then change the _rec_name to print the name as the display name.

- Fix SMS composer for the res.parnter tree
Only the first record was truely selected when open the sms composer
(mass) from the tree view of partner. Fix that by bind the actives_ids
in the context and also fix the names of related actions.

TASK_ID : 2053631
2019-09-12 14:53:44 +00:00
Raphael Collet 8918bbbb5e [IMP] fields: do not trigger recomputations on transient models from regular models
This is a performance optimization: modifying a regular record will not
trigger some recomputation on a transient record.  Most transient
records are simply waiting to be garbage-collected, so there is no need
to keep their fields up-to-date.

closes odoo/odoo#35909

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-08-22 10:05:52 +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 e7cd604afa [IMP] sms: add a is_mail_thread_sms field allowing to filter models
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

Limit use of templates to models that are really capable of sending
SMS. Templates are now available on models that inherit from mail.thread
and effectively have fields used in SMS sending.

Technically this is done through a not stored field on ir.model that is
searchable. SMS sending capabilities is based on

  * having fields holding phone numbers, as defined on mail.thread in SMS;
  * having fields holding partners, as defined on mail.thread in SMS;

This implied some code rewriting notably about finding default SMS
recipients on a given model, in order to have fields instead of directly
returning partners.

LINKS

Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
2019-08-12 12:00:22 +00:00
Thibault Delavallée 5450415354 [REF] sms: improve onboarding and user experience of SMS composer
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

Clean the use and options of sms composer after FP feedback :

  * see https://s.nimbusweb.me/share/3167586/ap1xpy95rz29a5cys576 as basis;
  * globally, do not display invalid recipients, only valid / invalid count
    as well as current selection / active domain counts;
  * consider logging a note as default behavior when using the composer;
  * simplify code: when doing a mass SMS, send SMS and attach a simple note
    to the document;

Some other points

  * make name of sms templates translatable;
  * improve various wording, notably in sms widget;
  * display error code in sms list view;
  * update sms composer actions accordingly by correctly setting active id
    or ids;

LINKS

Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
2019-08-12 12:00:22 +00:00
Thibault Delavallée 5d1f08a012 [IMP] sms: integrate duplicate / blacklist into composer in batch mode
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

Purpose of this commit is to support blacklisted and already-done numbers
when sending SMS.

  * blacklist support: necessary to avoid sending SMS in batch to people that
    asked to stop being spammed;
  * already-done support: when performing mailing in batch or doing A/B testing
    we may have already-done SMS;

When sending SMS in batch, already update state and error code of SMS that
should not be sent

  * blacklisted number: set to canceled, with blacklist error code;
  * duplicated number: set to canceled, with duplicated error code;
  * invalid number (cannot sanitize): set to error, with either missing number
    if void or wrong format if not void;

Support of blacklist / duplicated / invalid will notably be used when
performing SMS marketing (mass SMS) and marketing automation using mass
SMS.

LINKS

Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
2019-08-12 12:00:22 +00:00
Thibault Delavallée 7e8a02cd6e [IMP] phone_validation: add blacklist mechanism
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

Purpose of this commit is to add a blacklist mechanism for phone numbers
used to send SMS like what already exists for email addresses when sending
emails.

Define a new phone.blacklist model, holding a number and the state of the
blacklist (active field), as well as tools methods to access it. Make it
as private as possible, accessing it in sudo once access are granted.

Also clean phone validation tools: lessen number of tool functions and update
caller to simplify code readability. Some fixes are also included in this
commit, notably blank spaces cleaning in phone numbers.

Improve phone.validation.mixin to add a tool method computing a sanitized
number, in addition to formatting it to national / international.

Define a new mail.thread.phone mixin computing the blacklist status of a
record. This mixin

  * inherit from phone.validation.mixin in order to have access to some
    base phone number parsing capabilities;
  * computes a sanitized phone number based on ´´_phone_get_number_fields´´.
    It takes first sanitized value, trying each field returned by the
    method. That means one sanitized phone number is available per record
    even if several fields are available;
  * compute blacklist state of records. It is based on phone.blacklist
    model and give an easy-to-use field and API to manipulate blacklisted
    records;
  * give some API methods :

    * ``_phone_set_blacklisted``: set recordset as blacklisted;
    * ``_phone_reset_blacklisted``: reactivate recordset (even if not blacklisted
        this method can be called safely);

Put menus in technical in order to have access to it. Add a Phone / SMS
menu below "Email" and use it to store SMS / Phone actions.

Finally prepare tests addition by performing some light cleaning while adding
blacklist tests. Purpose is to ease future tests related to SMS.

LINKS

Task 1997464
PR #34424
Original SMS addition: Task 1922163 (4287481)
2019-08-12 12:00:22 +00:00
Thibault Delavallée f7a17c2380 [FIX] sms: correctly take mobile or phone as valid number fields for partners
Partner / Contact model may hold valid mobile numbers in mobile or phone
fields.

LINKS

Task 1997464

closes odoo/odoo#35599

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-08-09 11:49:39 +00:00
mreficent 355a5dfc36 [IMP] *: fix typos in comments
closes odoo/odoo#35404

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-08-07 10:28:33 +00:00
Remi Rahir 4968eb7c83 [FIX] sms: update and fix returned IAP state about badly formatted numbers
PURPOSE

Followup of merge 4287481 .

SPECIFICATIONS

wrong_format_number is actually now called wrong_number_format. This commit
propagates this renaming through SMS code and tests.

LINKS

Task 1922187

closes odoo/odoo#35025

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-07-23 08:29:15 +00:00
Remi Rahir e20c1b6eff [FIX] sms: fix some typos
PURPOSE

Followup of merge 4287481 .

SPECIFICATIONS

Notification type is now a selection -> use 'sms' instead of True;
Fix typo in method renaming not correctly propagated to its view;

LINKS

Task 1922187
2019-07-23 08:29:15 +00:00
Thibault Delavallée 46f2f04b85 [FIX] sms: use right has_sms_error field on message
closes odoo/odoo#34992

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-07-18 14:21:35 +00:00
Thibault Delavallée 16b3bf78a0 [IMP] sms: allow to send SMS from server (and automated) actions
PURPOSE

Send SMS from server/automated actions. Indeed we can already send emails from
server actions. The goal is to have the same thing for the sms.

SPECIFICATION

Purpose of this commit is to add support of sending batch SMS through
server actions. This means sending SMS will be available also for
automated (base automation) and scheduled actions (cron).

A new type of server action is added: sms. User choose an sms.template
to use to send SMS in batch. An option allow to choose to keep archive on
selected records. If no archive is kept, a batch of sms is created. With
archive a _message_sms is performed with note subtype, allowing to have
a discuss messages with only sms customer being notified.

Linked to task 1935280
Part of PR #34864
2019-07-18 09:57:47 +00:00
Thibault Delavallée 2b7ad217f1 [FIX] mail, sms: post sms message as a note on related document and apply various fixes
PURPOSE

Improve use of SMS. Followup of merge 4287481bf0 .

SPECIFICATIONS

Currently when sending an SMS through the UI a message is posted using the
comment subtype. However it is better to lessen number of notifications
and log using the note subtype as it is mainly a log to know something has
been sent.

Order SMS by ID desc to ease finding them in technical menu.

Mail, sms: fix wording of mail / SMS failures

Linked to task 1925950 and 1935280
Part of PR #34864
2019-07-18 09:20:06 +00:00
Thibault Delavallée ac212ae65d [IMP] sms: improve composer behavior
PURPOSE

Purpose of this commit is to add options and improve sms composer behavior.
Followup of merge 4287481bf0 .

SPECIFICATIONS

  * mass mode: add an option to keep archives when doing mass sms. This mode
    is actually a _message_sms in batch using the note subtype to speedup the
    process;
  * improve _message_sms_schedule_mass to allow more fine-tuning of options
    when calling it;
  * do not block sending SMS in batch if some recipients are invalid. Indeed
    using notifications there will be traces of failed SMS;
  * avoid reload of form view;

Linked to task 1925950 and 1935280
Part of PR #34864
2019-07-18 09:19:04 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
Multi is the default api for methods, it is not necessary to explicitly
decorate methods with it, adds clutter and most people use it because
they see that the rest of the code uses it.

Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
2019-07-17 14:13:12 +02:00
Thibault DelavalléeandPierre Rousseau 423cf93eb3 [IMP] sms: add UX elements to use SMS notifications
Purpose of this commit is to allow users to have a feedback on SMS
notifications status in chatter. This commit contains notably

  * an update of systray widget that now handles SMS failures. Those are
    displayed in another item of the systray and redirect to documents having
    an SMS failure;
  * an update of chatter widgets to support SMS notifications in messages.
    Failed notifications appear in red and allow to use the SMS resend
    wizard;

Mail message model gains a new has_sms_error computed and searchable field
allowing to filter on messages having failed SMS notifications. Mail thread
model gains a new message_has_sms_error computed and searchable field, based
on the one on mail.message. It allows to filter on records with failed SMS
messages directly from the systray. That way clicking on the systray entry
redirects to the right records.

Related to task 1922163
Linked to PR #33510

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-12 14:54:11 +00:00
Thibault DelavalléeandPierre Rousseau 45555bdd1f [IMP] sms: allow to resend and cancel SMS notifications
Purpose of this commit is to allow SMS notification management. It is based
on what has been done in mail for notification: resend and cancel.

In this commit we add wizards allowing users to resend and cancel failed
SMS notifications. Resend allow to change the contact number, as well as
resending only a subset of notifications.

Future commits will improve the UX itself.

Related to task 1922163
Linked to PR #33510

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-12 14:54:11 +00:00
Pierre RousseauandThibault Delavallee 9ad7a88a08 [IMP] sms: add SMS template and its support in SMS composer
Purpose of this commit is to provide users templates to use when sending
SMS. It is inspired from what already exists for mail templates. This commit

  * adds templates for SMS

    * users can now create template for SMS Text messages similar to mail
      templates;
    * jinja syntax is supported for body like mail templates, which is why
      templates are linked to a given model;

  * refactor the SMS composer

    * templates are supported in composer like the message composer. This is
      supported only in mass mode to avoid bloating the interface in standard
      composition mode;
    * composer code is rewritten to support various use cases (comment, mass
      sms, numbers, ...) and better fits all use cases;
    * composer is extended to support notably mass SMS without posting messages;

Templates will also be used in a near future in mass sms sending (mass
mailing application improvement) and in marketing automation (for enterprise).
Tests are updated and added to ensure feature works.

Related to task 1922163
Linked to PR #33510

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-12 14:54:11 +00:00
Thibault DelavalléeandPierre Rousseau bdebcab0ce [REF] sms: refactor message_post using SMS notifications
Purpose of this commit is to better include SMS notifications when posting a
message. SMS is now just another way of notifying people along with Inbox and
email. Following recent mail merge improving notification mechanism [1] we
have to define a _notify_record_by_sms method on mail.thread.

When a message_post is done using message_type being ``sms`` notification type
of customers is set to sms. Customers can be computed on model (generally based
on partner_id field) or directly set usign partner°ids. Notification model is
updated to store this information directly inside the notification itself.

An new ``_message_sms`` helper method is introduced in SMS module allowing
to send messages using sms type and notification with a reduced parameters
number. It is just a shortcut to message_post, easier to use. Either it
computes default recipients on the record set, either it is based on given
partners and numbers to notify.

The following use cases are notably supported

  * default computation: find customer, notify by sms;
  * force recipients to notify by sms (partner_ids);
  * give a set of numbers to notify by sms (sms_nubmers), not necessarily
    linked to existing partners;
  * force number / customer relationship independently of mobile number defined
    on customer (for example when sending an SMS directly from a mobile field
    on a lead linked to a customer);

Tests are updated accordingly. Performance tests are added in order to have
some insights on queries generated when sending SMS, like already done for
mail.thread alone.

Related to task 1922163
Linked to PR #33510

[1] see be27955136: performance and notification code improvements

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-12 14:54:11 +00:00
Thibault DelavalléeandPierre Rousseau db17763654 [IMP] phone_validation, sms: improve phone validation and SMS sending API
Purpose of this commit is to support more formatting options in phone tools,
to provide new API methods for phone numbers validatio. It also introduces
a method on sms.api to send SMS in batch. This one uses a new route given
in IAP services that send a batch of SMS instead of sending them one by one.

Concerning phone validation, tools are updated to correctly handle all
format supported by phonenumbers library. Indeed in addition to national
and international formatting phonenumbers library also supports E164
(international without spaces) and RFC3966 (beautification of phone numbers).
Let us support them and ease the use of our small tool methods in various
addons, notably sms.

Cleaning / check tools methods are added in phone validation module. Various
methods allow to sanitize phone numbers according to a context record and/or
some parameters. Those tools will be used in upcoming sms refactoring.

Another purpose of this commit is to add phone_validation in dependencies
of SMS application. Phone_validation module adds tools to parse and format
phone numbers and allow to replace the manual check done currently. Adding
it in dependencies of SMS does not change anything functionally as

  * library is still optional. If phonenumbers library is not installed the
    features are skipped without crashing;
  * no model is modified as it introduces only tools and a mixin. Models are
    updated in crm_phone_validation that updates lead and partner models;

Related to task 1922163
Linked to PR #34516

Co-Authored-By: Thibault Delavallee <tde@odoo.com>
Co-Authored-By: Pierre Rousseau <pro@odoo.com>
2019-07-02 10:40:46 +00:00