Commit Graph
438 Commits
Author SHA1 Message Date
Raphael Collet e8f7cfd00a [FIX] core: cursor hooks API and implementation
Python 3.8 changed the equality rules for bound methods to be based on
the *identity* of the receiver (`__self__`) rather than its *equality*.
This means that in 3.7, methods from different instances will compare
(and hash) equal, thereby landing in the same map "slot", but that isn't
the case in 3.8.

While it's usually not relevant, it's an issue for `GroupCalls` which is
indexed by a function: in 3.7, that being a method from recordsets
comparing equal will deduplicate them, but not anymore in 3.8, leading
to duplicated callbacks (exactly the thing GroupCalls aims to avoid).

Also, the API of `GroupCalls` turned out to be unusual and weird.  The
bug above is fixed by using a plain list for callbacks, thereby avoiding
comparisons between registered functions.  The API is now:

    callbacks.add(func)     # add func to callbacks
    callbacks.run()         # run all callbacks in addition order
    callbacks.clear()       # remove all callbacks

In order to handle aggregated data, the `callbacks` object provides a
dictionary `callbacks.data` that any callback function can freely use.
For the sake of consistency, the `callbacks.data` dict is automatically
cleared upon execution of callbacks.

Discovered by @william-andre

Related to odoo#56583

References:

* https://bugs.python.org/issue1617161
* python/cpython#7848
* https://docs.python.org/3/whatsnew/changelog.html#python-3-8-0-alpha-1
  (no direct link because individual entries are not linkable, look for
  bpo-1617161)

X-original-commit: d4b2e9224839aed8fc160ebe5a89e0f7d4c6a5bb
2020-09-03 14:29:39 +00:00
Thibault Delavallée cfbbc229d8 [IMP] test_mail_full: add mass_mailing test, notably for preview / browser view
Purpose of this commit is to add some mass mailing tests in test mail full
(with all community mailing capabilities installed). In this commit we notably
tests unsubscribe and view URLs computation in sent emails, as well as
the invisible preview block for email clients.

Task ID-2239327
Task ID-2239327
PR #49886

Related: odoo/enterprise#10091
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-08-05 13:55:04 +00:00
Xavier Dubuc c767df5e97 [FIX] mail: set full composer subject and recipients
task-2291887
task-2291893
task-2291898

closes odoo/odoo#54531

X-original-commit: 26170ad9ab09d75de2e0af98fb7daedc2ed57e50
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-07-15 16:18:53 +00:00
Thibault Delavallée 4a2ac044f8 [IMP] (test_)(mass_)mail(_full): rename and reorganize mail related test classes
Modules holding tests and helpers

  * link_tracker: mainly mock, asserts and tools for link tracker tests
    (MockLinkTracker);
  * mail: mainly gateway mock and base for mail tests
    * MockEmail -> mocks for mail gateway;
    * MailCase -> tools and asserts for mail tests;
    * MailCommon ->     base for mail functional tests);

  * sms: mainly SMS gateway mock and base for sms tests
    * MockSMS -> mocks for SMS gateway;
    * SMS Case -> tools and asserts for mail / SMS tests;
    * SMSCommon -> update of MailCommon with SMS capabilities);

  * mass_mailing: mainly asserts and tools for mass mailing tests
    * MassMailCase -> update of MailCase for mass mailing tools and asserts;
    * MassMailCommon -> update of MailCommon with mass mailing);

  * mass_mailing_sms: mainly asserts and tools for mass SMS tests
    * MockMassSMS -> update of MockSMS for mass SMS tools and asserts;
    * MassSMSCommon -> update of MassMailCommon with SMS capabilities);

Modules for tests

  * test_mail: module for mail app tests (TestMailCommon);
  * test_mass_mailing: module for mass mailing app tests (TestMassMailCommon);
  * test_mail_full: tests integrating all discuss features, currently mainly
    mail and SMS (TestMailFullCommon);

Enterprise: update test_mail_enterprise and test_marketing_automation

Task ID 2247037
Community PR odoo/odoo#50384
Enterprise PR odoo/enterprise#10266
Upgrade PR odoo/upgrade#1122
2020-05-26 10:35:58 +00:00
Thibault Delavallée 5a3fc46847 [FIX] mass_mailing: correctly consider replies for traces
Consider an email going through the mail gateway. Its headers References
and In-Reply-To are used in mail gateway to find if it is an answer to an
existing discussion thread.

Notably in mass mailing it is used to set mailing traces (called statistics
before 13.0) as opened and replied. However currently only the References
header is used.

In this commit we now use References or In-Reply-To like what is done in
mail gateway.

== 13.2 FORWARD PORT SPECIFIC ==

Code in tests has been updated to use new mockups tools and variables available
in test_mail

LINKS

Task ID 2257717
PR #51445

Forward-port-of: #51319
Forward-port-of: #51247
X-original-commit: 9921e38692e7dc4547afc34acc395da340eca410
2020-05-18 17:14:41 +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
Thibault Delavallée 6e347b196d [MOV] (test_)mail(_full): redispatch some tests and split test mail models file
PURPOSE

Have a cleaner test_mail addons

SPECIFICATIONS

Keep only mail-related tests, move odoobot in test mail full, send "update
notification" tests in mail (specific to mail). Merge some test files to
lessen number of files, perform light file renaming.

Split test mail models file to prepare some cleaning in those models and tests.

LINKS

Prepares Task ID 2238597 (clean notification models)
Prepares Task ID 2083854 (improve mass mailing technical flows)
PR #49891
2020-04-22 08:00:29 +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
Thibault Delavallée 6e25a510b3 [REF] base, mail: improve partner creation from name / email
Rewrite code parsing name (_parse_partner_name) to make it easier to
understand. Tweak find_or_create to return directly a recordset with the
found partner / new partner instead of a name_get result.

Also inherit Partner.find_or_create() in mail in order to benefits from
email_normalized field, allowing to improve the search on matching emails
and avoid duplicates.

LINKS

Task ID 1963529
Community PR odoo/odoo#32397
2020-03-24 10:24:14 +00:00
Thibault Delavallée de6e980f59 [IMP] mail: slightly improve tool to call mail gateway in tests
We now also support formatting a return path when emulating incoming emails.
Purpose is to integrate some more tests in a near future about incoming
emails, notably in CRM.

This commit is a preliminary cleaning coming from task 2088565 about CRM
onchange to compute methods update.

LINKS

Task ID 2088565
Community PR #42344
Enterprise PR odoo/enterprise#7403
2019-12-24 13:14:02 +00:00
Thibault Delavallée c3be4c3bc6 [IMP][MOV] mail: move / pimp test tools and asserts to mail
PURPOSE

Currently tools and asserts for mail tests are located inside test_mail
module. It makes difficult to re-use them in application tests or force them
to write custom quick and dirty tools and asserts. Purpose of this merge
is therefore to move tools classes and mocks to mail directly and use them
in various sub modules.

SPECIFICATIONS

Have class, mocks, tools and asserts available in mail so that all modules
below from mail can use them.

Including

  * mock mail gateway in a clean way: mock server connection, email building
    and sending;
  * allow to simulate errors while sending emails to test corner cases;
  * provide tools to insert emails in mail gateway;
  * mock mail application to check record creation (message, notifications,
    mails, ...);
  * mock bus notification;
  * provide clearer assert methods for bus and mail notifications;
  * provide clearer emails sending and content methods;
  * provide a with_user tool context manager for tests allowing to quickly
    change current user given a login;

Most of those tools, asserts and mocks come from test_mail/tests/common.py.
They have been partially rewritten to be easier to use or to perform tests
more cleanly.

Future commits will gradually update existing tests in test_mail, test_mass
mailing and test_mail_full.

LINKS

Task ID 2068986
PR #38070
2019-11-20 16:00:32 +00:00
Thibault Delavallée d040bfde89 [MOV] (test_)mail: move tests into their dedicated module
Purpose: avoid having useless tables for test models in a
production environment.
2017-11-29 10:11:15 +01:00
Thibault Delavallée 7a136d6acc [REM] mail: tests: remove unnecessary common data 2017-11-29 10:11:14 +01:00
Thibault Delavallée 32c08fd73c [IMP] mail: tests: add activity tests 2017-11-29 10:11:14 +01:00
Thibault Delavallée 2b6d840822 [IMP] mail: tests: clean test mail template 2017-11-29 10:11:14 +01:00
Thibault Delavallée ac9103adbd [IMP] mail: tests: clean mail gateway tests
Purpose is to lessen noise and make tests less low-level. Including :

 * use of new models and data;
 * lessen low level tests;
 * some light cleaning;
2017-11-29 10:11:13 +01:00
Thibault Delavallée 53d65ed71a [IMP] mail: tests: clean and improve mail tracking tests
Purpose is to lessen noise and make tests less low-level. Including :

 * clean and remove most of old tests, low-level and not very useful;
 * add tests for several cases, like simple tracking, tracking linked to
   a mail.message.subtype, trackink automatically sending emails based
   on some template;
2017-11-29 10:11:09 +01:00
Thibault Delavallée 99ee2f344a [IMP] mail: tests: clean and improve mail followers tests
Purpose is to lessen noise and make tests less low-level. Including :

 * add test for the various auto subscription cases, notably through
   umbrella (like project -> task auto subscription);
 * remove low-level tests; there is no need to test the output of add
   followers method as it is only an implementation details;
2017-11-29 10:05:01 +01:00
Thibault Delavallée f8118d8c8b [IMP] mail: tests: clean mail message tests
Purpose is to lessen noise and make tests less low-level. Including :

 * move mail_mail model specific tests to its own file;
 * move feature specific tests to its own file;
 * add missing loggers to lessen noise;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 846352f00d [IMP] mail: tests: clean and improve mail channel tests
Purpose is to lessen noise and make tests less low-level. Including :

 * tests should be more about channel listeners than followers as
   channels should not have followers;
 * test email_send that trigger the mailing list behavior;
 * currently add some join and leave channel methods are those are
   missing in the base model:
 * test joining and leaving channels that should not change
   followers but members;
 * use less preconfigured data;
 * add some mute loggers to lessen noise;
 * remove some old code about patching that is not necessary anymore and
   could actually create funny bugs;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 9150443465 [IMP] mail: tests: clean server actions tests
Purpose is to lessen noise and make tests less low-level. Including :

 * remove unnecessary fail string;
 * remove unnecessary method return value test as this is low level;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 15e131907f [IMP] mail: tests: clean invite wizard tests
Purpose is to lessen noise and make tests less low-level. Including :

 * remove test of emails content as this is too low-level and not really
   interesting. Purpose of test is to check followers have been added
   and not the content of a template;
 * remove unnecessary fail string;
 * remove unnecessary low level checks;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 12fd198bcf [IMP] mail: tests: clean test discuss and test message compose
Purpose is to be less low level and improve code coverage by adding
tests if required. Duplicated or redundant tests are removed to lessen
number of tests. Notably content of notification emails, recipients and
specific chatter control through context keys are more tested.

Some more tests about buttons present in notifications emails should be
added. Maybe in a near future. I hope so.
2017-11-29 10:05:01 +01:00
Thibault Delavallée 50aaaa69be [REM] mail: tests: remove test message read
This is some remains of old message_read / message_fetch tests linked to
the old chatter using threaded display. Tests have been removed when the
feature was changed. Only the setup was left. Let us get rid of it.
2017-11-29 10:05:01 +01:00
Thibault Delavallée de25767ffc [IMP] mail: tests: improve / add common classes and data for mail tests
This commit improves common classes and add helpers for mail tests.
Future commits will use this new stuff to improve the tests.

 * improve existing models and add some of them. There are now several
   models

  * mail.test.simple: chatter-enabled record without any really advanced
    feature. Can be used everywhere standard chatter and communication
    tests are required;
  * mail.test.track: chatter-enabled record with basic value tracking
    and responsible tracking;
  * mail.test.activity: chatter-enabled record using activities;
  * mail.test.full: complete chatter-enabled record with advanced
    tracking, automatic subscription and automatic email send based on
    templates and tracking;
  * mail.test: chatter-enabled record having an alias. It can be used
    where umbrella record like projects or teams has to be used in
    tests;

 * add MockEmails test class: this class mocks the mail gateway so that
   tests can work on emails without actually sending them. It is taken
   out of TestMail class to clearly separate features from class;
 * improve created data in the various classes and prepare work to
   lessen created data during tests;
 * add helpers on base test class, notably

  * sudoAs: context manager to run a code snippet using a given user;
  * assertNotifications: assert notification content, aka Inbox or email
    notification and their content; may be subject to change depending on
    mail evolution;
  * assertEmails: check content of sent emails;
2017-11-29 10:05:01 +01:00
Thibault Delavallée 2a3ac4ce22 [MOV] mail: reorganize content of tests, separate tests from models and data
Purpose of this commit is to reorganize the mail tests. Containing

 * move test models into mail/tests/models/;
 * move data into mail/tests/data even if it is python code, as it is
   likely that some additional data will appear soon;
 * split test_mail_features into test for discuss app and test related
   to message post and composer, to better identify test target;
 * split and remove test_portal, those tests are now integrated in the
   other tests;

There is no change in this commit. Only some renaming and file move or
split.

mergeup: remove / split test portal
2017-11-29 10:05:01 +01:00
Thibault Delavallée 1fbc29a641 [MOV] base: move ir_* models into models/ 2017-11-27 11:15:03 +01:00
Christophe Simonis a094f6318b [MERGE] forward port branch saas-16 up to 745d00362a 2017-11-16 12:40:36 +01:00
Christophe Simonis 5877b7b38c [MERGE] forward port branch saas-15 up to 73e4dacf78 2017-11-15 15:50:36 +01:00
Christophe Simonis 73e4dacf78 [MERGE] forward port branch saas-14 up to 0bf7ab4511 2017-11-15 15:20:52 +01:00
Christophe Simonis 0d0dd0c866 [MERGE] forward port branch 10.0 up to a8b72d764e 2017-11-14 11:27:04 +01:00
Christophe Simonis a8b72d764e [MERGE] forward port branch 9.0 up to d07f9c5ef5 2017-11-14 11:26:02 +01:00
Manuel Vázquez Acosta d6c2906d44 [FIX] mail: access the super of TestMailGroup
Instead of the parent of TestMail class

Closes #20728
2017-11-13 16:41:03 +01:00
Raphael Collet 36141931bf [FIX] mail: remove field res_model_id for performance reasons (#19744) 2017-09-27 16:58:19 +02:00
Thibault Delavallée 0296f198b2 [IMP] mail: tests: add a new simple base model for testing
Purpose: have simple test models to use in various modules and be
independent from standard models behavior / tweaking.
2017-09-15 15:56:23 +02:00
Raphael Collet 55549f1e61 [ADD] base: direct support for binding an action to a model 2017-08-28 09:53:23 +02:00
Christophe Simonis 017ee5eab3 [MERGE] forward port branch saas-17 up to 877e709871 2017-08-24 13:17:53 +02:00
Xavier Morel 200612ca1e [FIX] P3: text model in various mail bits
No formal decision there, and the stdlib API seems like a PITA as it's
based around native strings, not bytes and not text.

* try to use cross-model API instead of random encode/decode
* unicode all the mail_template things
* formataddr *requires* a text tuple now

  In P2, formataddr((False, False)) "worked" (generated "False
  <False>"), in P3 it will fail and blow up.
* attachments are quite definitely bytes
* remove try_coerce_ascii because it's garbage
2017-08-20 23:25:54 +02:00
Xavier Morel 3824b5dcc1 [FIX] P3: fix base64 and StringIO uses
* StringIO removed from stdlib, replace with io
* try to correctly handle BytesIO/StringIO (one is for bytes the other
  is for text)
* fix base64: Python 3 removed bytes-encoding and bytes-bytes
  codecs (via #encode) so replace all calls to str.encode('base64'),
  also b64encode is a bytes->bytes conversion so attempt to properly
  handle that

issue #8530
2017-08-20 23:25:54 +02:00
Thibault Delavallée ee4cf1eae3 [MOV] website_portal: move mail portal tests directly to mail
Those belong to mail, not website_portal.
2017-08-08 15:05:11 +02:00
Christophe Simonis 4f501348c4 [MERGE] forward port branch saas-16 up to 46e1104ce1 2017-07-26 19:55:44 +02:00
Christophe Simonis 46e1104ce1 [MERGE] forward port branch saas-15 up to 681f03e309 2017-07-26 19:41:57 +02:00
Christophe Simonis 681f03e309 [MERGE] forward port branch saas-14 up to c4e9b854ff 2017-07-26 18:47:54 +02:00
Christophe Simonis c4e9b854ff [IMP] core: log bad queries as ERROR
Also adapt default config and config mapping.
2017-07-26 17:46:20 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Aline Preillon 2950ffaa86 [IMP] mail: improve notification management, either email either inbox
Currently partners have a boolean field to choose whether to receive
notifications only in their Odoo inbox or to receive them in their inbox
and by email. This leads to several issues :

 * if a customer is configured to not receive emails he will not receive
   any notification on sales orders, leads, ... This is not clearly
   indicated to the salesman and it is not easy to know how to change
   that behavior
 * if an user chooses to receive emails and does not use its inbox a lot
   of notifications stay in Odoo. The user has to manually set them as
   done to make them disappear which is redundant.

This commit changes that behavior. From now on customers will always
receive all notifications by email. Indeed Odoo is not a customer oriented
mailbox. Moreover sales orders or discussions on leads send to customers
should always be sent by email as it is the standard communication
mechanism. Users will be able to choose to receive notifications in Odoo
or by email. The choice is no longer inbox or inbox + email, but inbox
or email. Choosing one option or the other one depends on the way the
user wants to work.

Technically the field is moved on the users model and selection keys
are renamed. Notification process is modified

 * notified_partner_ids contains as before specified recipients as well
   as followers matching the subtype
 * customers and users working with emails are notified. During that
   process customers notifications are marked as done to be able to
   track the email state without having needaction. Users notifications
   are currently deleted as we do not track their email state.

The removal of partner field implies changes in various addons that
define partner data with this field set in the values.
2017-02-21 16:42:11 +01:00
Thibault Delavallée eb3a531666 [IMP] mail: small code linting in notification methods
This commit cleans code to separate recipients computation in mail
message from notification mechanism in partner. There is no functional
change. Some variables have been renamed notably to know that
some of the record sets are sudoed during computation.
2017-02-21 16:41:15 +01:00
Thibault Delavallée 927fbe8845 [IMP] mail: make tests less dependent on mail.channel model
Currently almost all mail tests run on mail.channel model. Indeed it is
the only model inheriting from mail.thread and mail.alias when having only
mail installed. However channel model have several specific features and
is not totally a standard mail.thread model. For example notification
recipients are computed a bit differently.

Since 4f9105a4ef mail module has a test
model allowing to perform tests on a very simple mail.thread-like model.
This commit make mail tests use this test model instead of mail.channel
everywhere it is possible. Channel model should be used only when tests
are channel-dependent.
2017-02-21 16:41:14 +01:00
Thibault Delavallée 80d26e26bb [IMP] mail: notify author of internal notes when replied through gateway
Currently if an user mentions someone in an internal note he is not
notified of any reply as replies create internal notes. This commit
ensure the author of the first note is notified of the reply even
if it is still an internal note.

Tests have been updated accordingly.
2017-02-21 10:39:43 +01:00