summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_message_compose.py
AgeCommit message (Collapse)Author
2019-09-06[MOV] test_mail: split post and composer testsThibault Delavallée
PURPOSE In order to rewrite some tests, remove low-level tests and add coverage first step is to reorganize a bit test_mail content. Several tests cases are spread among several files and finding back some feature coverage tests is not easy. SPECIFICATIONS Reorganize tests, notably * put message_post related test in test_message_post; * have only composer related test in test_message_compose(r); * put alias tests in test_mail_gateway; * move some discuss tests to post tests as they are linked to notification details, not really Discuss features. LINKS Task 1958697
2019-09-06[REF] test_mail: lessen data created by defaultThibault Delavallée
PURPOSE In order to rewrite some tests, remove low-level tests and add coverage first step is to reorganize a bit test_mail content. Several tests cases are spread among several files and finding back some feature coverage tests is not easy. SPECIFICATIONS Quickly clean common class and lessen data creation by default. Offer some tool methods, notably to create portal users used in some tests but not all, or to create mail templates. LINKS Task 1958697
2019-08-05[REF] mail, test_mail, *: rename needaction_partner_ids to notified_partner_idsXavier-Do
,*:crm, website_blog The mail.message needaction_partner_ids meaning changed over time, and doesn't actually reflect the list of partner in needaction. More than that the message_format needaction_partner_ids used by js began to diverged from mail.message field since 19fb650863f11172c8a6839fcc10919e9ca9977b To avoid any confusion, renaming it to notified_partner_ids will help to avoid confusion between python and js meaning, and reflect the actual content of this field : a list of partner that where notified once on this message. This field is mainly usefull for testing. Task-ID 402597
2019-07-04[FIX] *: sudo() -> with_user()Raphael Collet
2019-06-05[REF] *: removes datas_fname from ir.attachmentThanh Dodeur
This commit removes the field `datas_fname` from `ir.attachment` as it was unnecessary and most of the time the duplicate of `name` or `url`. Task #1909865 closes odoo/odoo#32976 Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-05-29[IMP] mail: reduce message_post query count and clean codeXavier-Do
Purpose of this commit is to improve performance of post and notify through various code improvements. Containing * making of _notify_customize_recipients a mail.thread method; * _message_auto_subscribe_followers optimized; * renaming and optimisation of _notify_partners; * message_post_attachements optization; * remove unused mail_post_autofollow_partner_ids context key; * minimize message create queries; * only check record related access right for thread messages not in pending moderation; * get attachements from values instead of db; * storing lang in ctx from the beginning; * don't track on write on attachments; Related to task 1943901 Linked to PR #32404
2019-05-29[REF] mail, various: apply light code cleaningXavier-Do
Purpose of this commit is to clean some bits of code, notably calls to message_post/log as well as notification methods. It will ease performance improvement work. Small optimization: account: read content after extension check Parameter cleaning * use message log with kwargs instead of args; * remove message post after hook useless parameters; * remove _notify_email_recipients useless message parameter; * remove message_notify useless send_after_commit parameters; * remove message post params matching default values; Other improvements * remove message_post commands support for partners and channels; * only calls message_post with ids list for channels and partners. We don't support mix of ids and command anymore to simplify code; * remove support of private discussion in mail.thread adding partners as recipients, as there is no use anymore; Related to task 1943901 Linked to PR #32404
2019-05-29[IMP] mail: improve user notification model in mail.messageXavierDo
Currently if a message has a res_id and a res_model it appears in the matching record's chatter. Its access rights are computed based on this record. This is the standard behavior of mail.message model. User notifications are currently built on messages not having model and res_id in order to avoid appearing on chatter. This has several drawbacks notably access rights, redirection to the record, systray, finding back records, ... This commit solves those issues by adding new message_type 'user_notification' that should be as a classic mail.message with model and res_id but without the whole notification mechanism and without being displayed in the chatter. An user notification is now a classic message pushed to a given partner only and not displayed in the chatter. Related to task 1943901 Linked to PR #32404
2019-04-26[IMP] test_mail: add tests for mail gateway and perform light cleaningThibault Delavallée
This commit add some tests related to the mail gateway: more bounce management tests and some additional thread formation tests. Some test asserts about bounce / blacklist management are commented as they are not completely working currently. This will be improved in master soon. Some cleaning in also done in all mail gateway tests. Notably some call to tool methods are cleaned / simplified, duplicate tests are removed. Some low-level checks are removed. A new test model is added for mail gateway: mail.test.gateway. It is a chatter model with blacklist enabled on it. It allows to tests the various blacklist-related overrides and features as well as all basic mail gateway features. Sub-part of task 1853147 (pre-cleaning before implementing mail gateway improvements) Linked to PR #32974
2018-10-18[REF] test_mail: use odoo test helper method to create test usersThibault Delavallée
Purpose of this commit is to use the newly introduced helper to create test users in a quick way and reduce code duplication. A mail specific helper tool function is defined based on the standard one defined in test allowing to pass a custom context. It bypasses mailing features in order to speedup the creation. This commit is linked to task ID 1889703 and PR #27526.
2018-07-11[FIX]: mail: storing add_sign on mail messageXavierDo
Only the add_sign from notif_values is usefull for a resend. We can consider that a mail on resend can be delete in every case, and we can find the model_description from model since a resend can only be performed on message linked to a model. The other notif_values are now parameter in order to ease the understanding of what can transit through this flow. Task: #1860054 PR: #25622
2018-04-03[REF] mail: improve implementation of message subscribeThibault Delavallée
This commit refactors mail.thread message_subscribe method. It is done for two purposes. First one is to optimize performance by using the new followers computation methods introduced recently. Second purpose is to clean the API of message_subscribe to make it simpler to use. This commit splits message_subscribe in two main parts : * _message_subscribe is a private method calling the follower new subscription methods and updating the record set; * message_subscribe is a public wrapper on _message_subscribe that adds access rights checks; Simplification comes by removing message_subscribe_users that was a shortcut to message_subscribe. Having a method to subscribe partners and channels is sufficient as we would like to avoid bloating the public API of mail.thread. A force parameter is also removed from message_subscribe as this implementation detail can be induced in the computation. Various addons using the removed methods are updated in order to use the new subscription API. They have the same functional behavior. This commit has a great impact when subscribing several followers. In a more general way all code using message_post is also optimized as posting a message generally implies subscribing followers. It also improves activity use as posting a message and subscribing new followers are common process in activities.
2018-02-20[IMP] mail: add method to notify recipients of content not related to a documentThibault Delavallée
Mail API contains a message_post method allowing to post a message on a document. In some cases we would like to push notifications to recipients that are not necessarily linked to a document. For that purpose we introduce message_notify. It is a shortcut that prepares the message and speeds up the computation by pre-computing message values. This method calls message_post and therefore the whole notification process. It means no custom code for pushing inbox or email notifications is necessary.
2018-02-20[IMP] mail: update _notify APIThibault Delavallée
Purpose of this commit is to allow to give additional values when rendering notification emails and to make some parameters explicit. This commit updates the _notify API. It allow to propagate a dictionary containing values given to the rendering of the notification template. This allow to have more complex templates and/or to control the rendering depending on some parameters. Indeed currently only some fixed values and values coming form the message to notify are given to the rendering context. First use will be soon when pushing notification emails not necessarily linked to documents. In this process some values will be given by the caller and not only by the message context anymore. This commit also moves some context key used to control the notification process directly in values given to the _notify method. It allows to make those parameters explicit and rely less on context. The _notify method now takes a values dictionary that may contain * add_sign: add user signature to notification email, default is True. It replaces the ``mail_notify_user_signature`` context key; * mail_auto_delete: auto delete send emails, default is True. It replaces the ``mail_auto_delete`` context key; * other values are given to the context used to render the notification template, allowing customization. It allows to remove some context switch notably in the composer. A values dictionary is computed and given to message_post and then propagated to the notification mechanism.
2018-01-30[IMP] mail: introduce _message_log as shortcut when logging notificationsThibault Delavallée
This commit introduces _message_log to use when logging notification-based notes on a document. Its main purpose is to provide a shortcut to the complex mechanism of message_post. As it is a lighter code and as it performs less checks and value computation it allows to clearly gain queries when logging notes. It does * skip the notification process completely. Side effect is that followers following note subtype are not notified of document created and pure note tracking. This is considered more as a fix than a feature change. Indeed following notes means that followers want to receive notes logged by other users. The fact that system notifications without a specific subtypes are also notes is a side-effect of the current implementation; * support only notification-based notes and should not be used currently when logging real notes as those could trigger the notification process; * skip access rights checks as it creates the message as superuser. It is therefore defined as a private method and should be called within a method where access rights are already granted; On community runbot installing all 203 modules takes 580K queries instead of 690 at the time of testing. It is a 15% performance increase based on the 'all modules installation' metric. In a distant future message_post and message_log could be merged after some cleaning but it is easier currently to have this shortcut available. Moreover as there are clouds on the mail module some developers prefer to already have some optimization and code cleaning done to avoid loosing all their hair. This commit includes a small test. In a same distant future more tests will probably be added depending on how mail API evolves.
2017-11-29[MOV] (test_)mail: move tests into their dedicated moduleThibault Delavallée
Purpose: avoid having useless tables for test models in a production environment.