Commit Graph
23 Commits
Author SHA1 Message Date
Abdelouahab (abla) f69f3623d9 [FIX] sms: use partners on record to send sms
To reproduce
============
- create sms template and apply it to a module different than `res.partner`
for example Tasks
- add context action
- create a task and select a customer that has a phone number
- from action try to send the sms, an error is displayed

Problem
=======
when computing the receipient info, the partner on the record is not taken
into account.

opw-3475456

closes odoo/odoo#137014

X-original-commit: 6e6a8c24c3ab1a6b3ff27564f4244ed3d6b4c022
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-29 08:07:04 +00:00
Chong Wang (cwg) 13957b6281 [FIX] core: support cr.execute_values
psycopg2.extras.execute_values was introduced in PR #101237
however it pypasses the override logic for cr.execute. As a result
1. --log-sql cannot log these queries
2. assertQueryCount cannot notice these queries
...

This commit create a new api cr.execute_values to support the same SQL feature
without losing the override logic for cr.execute

closes odoo/odoo#131190

Related: odoo/enterprise#47374
Signed-off-by: Rémy Voet (ryv) <ryv@odoo.com>
2023-09-14 11:22:42 +00:00
Thibault Delavallée a4b2ee67a9 [FIX] various: update query counters
According to last runbot.

Part-of: odoo/odoo#130468
2023-08-02 18:50:18 +02:00
Thibault Delavallée adfdf5ab33 [IMP] phone_validation: add a phone formatting tool on model
RATIONALE

Simplify field management for mail / phone / sms flows. Make it working out
of the box, easier to use and tweak.

SPECIFICATIONS

Add a '_phone_format' tool method on BaseModel. It allows to format a number
either directly, either from a field available on the model. It allows to
ease number formatting. It uses available helpers to find numbers using
'_phone_get_number_fields' and '_phone_get_country_field'. With default
generic behavior this allows to simplify most calls to phone number formatting.

Having it available at BaseModel level allows to remove some custom code,
calls to phone_validation API, ...

Task-3422449 (Mail, Phone: Move and improve field helpers)

Part-of: odoo/odoo#130468
2023-08-02 18:50:17 +02:00
Thibault Delavallée 626557147c [REF] various: remove duplicated sms helper tools
RATIONALE

Simplify field management for mail / phone / sms flows. Make it working out
of the box, easier to use and tweak.

SPECIFICATIONS

Simplify model custom code when dealing with phone and sms by using helpers
and standard behavior defined on all models.

'_sms_get_partner_fields' was introduced at odoo/odoo@bdebcab0ce to have a generic
implementation of finding partners on a record. Since then another version
has been added directly in 'mail' module, using '_mail_get_partners'.

'_sms_get_number_fields' was introduced at the same time to have a generic
implementation of finding numbers on a record. Since then a generic and
improved version has been added directly in 'phone_validation' module, see
'_phone_get_number_fields'.

Those method can therefore be removed, and replaced by the generic ones
available on BaseModel.

Task-3422449 (Mail, Phone: Move and improve field helpers)
Prepares Task-36879 (Mail: Support MultiCompany Aliases)

Part-of: odoo/odoo#130468
2023-08-02 18:50:17 +02:00
Eteil Djoumatchoua(etdj) 16bb22f5fc [FIX] sms: send SMS on transfer without traceback
Steps to reproduce:
- Create a SMS template with the 'Applies to' property set to
  Transfer (without this the action will never appear)
- Go to Transfer, pick one, open action and try to send a SMS

Issue:
Traceback

Cause:
When sending the SMS we try to modify the 'mobile' attribute of
'stock.picking' but it doesn't exist.

opw-3286153

X-original-commit: c84f952824bea4c1e0d5dcc7450d5e48a5637db8
Part-of: odoo/odoo#123716
2023-06-12 10:02:22 +02:00
Thibault Delavallée c1a6ef5d0d [IMP] test_mail(_sms): update counters to latest runbot
Update counters to match current runbot state. Several changes (ORM, mail
code organization) lead to some counters being obsolete.

Task-3322905

Part-of: odoo/odoo#121104
2023-05-16 15:55:16 +02:00
Thibault Delavallée c7af3b7c09 [REF] test_mail_sms: simplify SMS-based test class usage
'TestSMSCommon' was useless and is replaced by the 'SMSCommon' class defined
directly in SMS addon, easing inheritance and imports. See community PR for
more details.

Task-3263512

Part-of: odoo/odoo#117606
2023-04-04 20:08:37 +02:00
Thibault Delavallée c9848bbf58 [REF] test_mail(_*): simplify Mail-based test class usage
'TestMailCommon' was useless and is replaced by the 'MailCommon' class defined
directly in Mail addon, easing inheritance and imports.

Task-3263512

Part-of: odoo/odoo#117606
2023-04-04 20:08:37 +02:00
Eteil Djoumatchoua (etdj) f8071dc521 [FIX] sms: fix traceback clicking on Send SMS button
Steps:

install calendar app.
enable sms template of calendar.
go to calendar event form view.
try to send SMS.
Issue:

traceback clicking `Send SMS' of Send SMS wizard.
Cause:

trying to write on field even though field does not
exist in model.
Fix:

check field exist in model before write on it.
task-3084701

closes odoo/odoo#114824

X-original-commit: b773006055f0c29e56b2719621e2abd80af6b9e7
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-29 10:37:19 +02:00
Eteil Djoumatchoua (etdj) 6186dc2266 [FIX] sms: don't get error when sending an sms on sale order
steps:
- Go to Rental app
- Open a rental Order
- Click on Action
-  Send an SMS text message
-  Fill phone number and message
- Sens SMS
Issue:
Traceback

Cause:
Sale order doesn't have a phone or mobile field so the sms.composer tries to write on it use "False"

Solution ensure the field name isn't false before writing

opw-3103232

closes odoo/odoo#110038

X-original-commit: 70a9995c9e02f36dc15d2723151ef0a205ebc12b
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-01-25 09:16:47 +01:00
Kamlesh Pathekar 02067a3342 [FIX] sms: fix recipient of SMS wizard
Prior to this commit, the recipient in the SMS wizard
shows The name of the record.

In this commit, we make the partner the recipient instead
showing The name of the record itself.

task-3000243

closes odoo/odoo#110801

X-original-commit: 16e25edaf5c589046d42c62a2c32d337504d9e37
Signed-off-by: Xavier Bol (xbo) <xbo@odoo.com>
2023-01-24 13:47:18 +01:00
Thibault Delavallée 9a5046ba0a [FIX] phone_validation: correctly support phone/mobile search parameters
Currently the search method defined on 'phone_mobile_search' supports either
a boolean (is set / is not set) search, either considers all searches to be
"like TERM". This is coming from the main usage that is the search view
that sends domains like "[('phone_mobile_search', 'ilike', term)]".

In this commit we improve the method to correctly support

  * direct check (=)
  * negative operators (not (i)like)
  * like / ilike (previously like were considered as ilike)

Idea is: a positive operator check that any of the phone fields respects the
domain (phone or mobile is TERM). A negative operator checks that all phone
fields respects the negative domain (both phone and mobile do not contain TERM).

Tests are added.

Task-3012789

X-original-commit: 8e905343f38a4dae828ccaddc62ce5c6a2f754db
Part-of: odoo/odoo#104111
2022-10-26 00:55:05 +02:00
Abdelouahab (abla) 897eedf22e [FIX] phone_validation : filter by phone/mobile is set
To reproduce
============

Go to Contacts and try to filter by phone/mobile is/not set. A traceback is
raised.

Problem
=======

The search method responsible for this field didn't take into account Value
to filter by to be a boolean.

Solution
========

Correctly support this case in search method.

Add unit test.

Task-3012789
opw-2980542

X-original-commit: 62b7da527c6ddb4654fbccf5c6d8c94158915ebc
Part-of: odoo/odoo#104111
2022-10-26 00:55:04 +02:00
Thibault Delavallée 47f08bf9d3 [FIX] phone_validation: correctly use phone fields when searching on phone/mobile
Currently the search methods defined on ``phone_mobile_search`` field forces
the usage of ``phone`` and ``mobile`` fields on model. This currently works
on models using by default this search field (lead and partner). However this
breaks on any model not having those two fields and inheriting from the
'mail.thread.phone' mixin.

In this commit we use the result of ``_phone_get_number_fields`` to know which
fields to use in the SQL query.

Tests are added to ensure it works as intended.

Task-3012789

X-original-commit: 6b235868da6fed1b2a0eaa7a25dc2202c6fefaa0
Part-of: odoo/odoo#104111
2022-10-26 00:55:03 +02:00
Thibault Delavallée aeeb10ad37 [IMP] test_mail_full: improve test models to ease future tests
In order to better reflect real models, let us have phone and mobile fields
being computed either by hand, either based on customer on 'mail.test.sms.bl'
test model.

Done in its own commit to ease discovering of side effects in tests, which
does not seem to be the case.

Task-3012789

X-original-commit: 71e2b8713bc83ed999ab2e2839edc56804a0fe54
Part-of: odoo/odoo#104111
2022-10-26 00:55:03 +02:00
Chong Wang (cwg) f8c2b02abe [FIX] *: adapt code to jsonb translations
Website: the context install_filename='dummy' is used to prevent
arch_updated from becoming True while updating translations of
ir_ui_view.arch_db (if arch_update becomes True, test_inherit_specific
fails)

Fuzzy search for jsonb translated fields has been adapted in the case of
website.  It may require some refactoring later.
2022-09-15 22:37:50 +02:00
std-odooandThibault Delavallée 9b11a9d82b [IMP] mail: schedule emails and notifications
Purpose
=======

Currently, only email sending can be scheduled with the `scheduled_date` field
defined on on <mail.mail>. It's not possible to delay the sending of
notifications.

We want to be able to delay the sending of the emails, but also the inbox
and bus bus notifications.

Technical
=========

For that purpose, we created a new model which stores the message we need to
notify with the scheduled date. When a scheduled_datetime is given we skip the
notification process. Instead an entry in that new model is created. A cron
regularly polls the scheduled message and launch the notification process on
messages that are ready to be sent.

Task-2207626 (Rating: Delay rating notification to ease feedback)

Part-of: odoo/odoo#95623
Co-authored-by: Thibault Delavallée <tde@odoo.com>
2022-08-25 19:57:16 +02:00
Thibault Delavallée edb4cb6f8c [REF][IMP] crm, event, test_mail(_full): make performance tests post-install
PURPOSE

Have more reliable tests.
Better spot side effects coming from sub addons.
Lessen non deterministic counters due to local db.

SPECIFICATIONS

Make crm, event and mail performance tests post install.

Update query counters with
  * local values (install module only with enterprise activated);
  * community / enterprise runbots (if value is different);
  * some notes on non deterministic issue if known;

Task-2925606

closes odoo/odoo#96446

Related: odoo/enterprise#29726
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-08-18 21:08:50 +02:00
Thibault Delavallée db54f5eff1 [IMP] sms: add options for sms server actions
After updating email server actions we can improve SMS server actions the
same way. We can now post on documents using SMS notification mechanism
in addition to pure mass SMS sending.

A new field is added to handle the way of sending SMS, like we do for
email actions.

Task-2613245 (Server actions mail update / cleaning)

Part-of: odoo/odoo#75906
2022-08-12 23:37:03 +02:00
Thibault Delavallée 6ca272aa05 [FW][FIX] sms: correctly render body in mass sms
When sending SMS on several records in comment mode (aka: post sms message
in batch) the body is sent as it is. This does not happen frequently as
default usage is either

  * comment on a single record -> body is rendered by onchange / compute;
  * mass SMS on several records -> body is rendered for all records then
    sent to all recipients;

Using comment mode in mass is not common, and is mainly achieved through
handcrafted actions. However this can be fixed by correctly rendering the
body before posting on all records.

Use addition of records instead of OR to keep ordering of created
messages when using SMS composer.

Spotted during Task-2613245 (Server actions mail update / cleaning)

closes odoo/odoo#97787

closes odoo/odoo#97890

closes odoo/odoo#97931

X-original-commit: odoo/odoo@1778a2c1b2
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-08-11 17:56:59 +02:00
Thibault Delavallée ab97d81620 [FW][FIX][IMP] test_mail_full: improve tests for rendering in mass mode
Purpose is to enable dynamic rendering in mass comment mode. This highlights
an issue, as currently when using the comment mode on several records body
is not rendered, just sent as it is. This means raw dynamic code could be
sent.

Also cleanup some invalid setup (not enough records for mass) that skipped
some tests.

Spotted during Task-2613245 (Server actions mail update / cleaning)

X-original-commit: odoo/odoo@d5a1c5768b
Part-of: odoo/odoo#97931
2022-08-11 17:56:59 +02:00
Thibault Delavallée 039c63cf6e [REF][MOV] test(_mass)_mail(_sms): move sms tests in their own addon
In this commit we introduce a new module ``test_mail_sms`` that holds the
tests for sms application, like ``test_mail`` does for mail. Currently all
sms tests are inside ``test_mail_full``. After this commit code is moved
from ``test_mail_full`` into that module. Full testing module should be used
mainly to test integrations with a lot of submodules and for performance
tests, not testing details of SMS implementation.

We also add ``mass_mailing_sms`` as dependency of ``test_mass_mailing`` so
that both mailing types are tested in the same module. It eases maintenance
and writing of tests. Mass mailing SMS tests  from `test_mail_full`` are
therefore moved in ``test_mass_mailing``.

This commit also allows some cleaning in classes used in tests, to have
classes in ``test_mail_sms`` and ``test_mail_full`` that contain everything
necessary to test mail features.

Task-2890111 (Test Mail/Mass Mailing: SMS tests reorganization and move)

Part-of: odoo/odoo#96223
2022-07-19 11:51:12 +02:00