summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_performance.py
AgeCommit message (Collapse)Author
2019-04-03[IMP] mail: remove inheritance of composer on messageThibault Delavallée
Base issue: unnecessary inherit of composer on mail.message. Indeed there are a lot of unused fields coming from mail.message as well as message specific behavior (notify, check access, various business methods) not relevant for composer. Specifications * remove inherit from mail.message; * re-define used fields; * ensure everything still works; Commit linked to task ID 1907153 and PR #28464 Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
2019-04-03[IMP] test_mail: update countersThibault Delavallée
Some counters are not up to date notably taking in to account community-only and test-mail with enterprise only counters. Those are used notably when developing to ease quick check of counters. closes odoo/odoo#32370 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-03-29[IMP] mail, *: don't track fields at createXavierDo
*: project, crm, maintenance, helpdesk, It is useless to track fields during create since they have no initial value and future tracking message will show changes on tracked field. We can log a default creation message instead (as it is now if there is no mail_create_nolog context key) This change will implies - less queries when creating record - cleaner creation messages - less occurence of mail_create_nolog ctx key Removing tracking at create could break the creation subtypes mechanism (example: following task creation subtype on project) Instead of using _track_subtype to give a subtype at create, a new _creation_subtype method can be override. If a creation subtype is set on a specific modlel, creation messages will be create by message_post instead of _message_log. We also need to adapt the message_track_post_template in order to keep this feature whithout tracking. Task: #1916916 closes odoo/odoo#31945 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-02-22[MERGE] forward port branch saas-12.1 up to 0f4abc5c228Christophe Simonis
2019-02-13[IMP] mail: allow tracking on groups protected fieldsLucas Lefèvre
Purpose ======= Currently fields with a `groups` attribute can't be tracked. Otherwise changes would be visible by all in the chatter, including users which normally don't have the access rights because they are not members of `groups`. Specification ============= Filter tracking field values according to the `groups` attributes. Users without the access rights should not see them. If a message is only composed of tracking values and the user doesn't have the rights to see them, an empty message should not be displayed.
2019-02-11[REF] account: prepares hooks for reconciliation requestsThanh Dodeur
This commit changes some methods so they can be used in the account_documents enterprise bridge and adapts activity tests for the new request on upload_file feature. task: #1928404 related to: odoo/enterprise#3607 closes odoo/odoo#30950
2019-02-15[FIX] mail: non translated field when posting emails from cronsJulien (juc) Castiaux
1) Configure both an incoming mail server and an outgoing one. 2) Install CRM. 3) Create a sale team, use the incoming mail address as mail alias. 4) Add a user with a valid email as follower of that team in the chatter. 5) Enable developer mode, become super user via the developer tools. 6) Change the language of the super user to french. 7) You may want to modify the default gather/post time interval. to receive/post email more regulary in the scheduled action. 8) Using an external mail client, send a mail to the incoming mail address. 9) Let the two scheduled actions run by themselves. 10) The mail sent to the user has the "Lead/Opportunity" in english wheras the rest of the email is in french. opw-1917993 closes odoo/odoo#31034
2018-12-10[FIX] mail: model descriptionNicolas Martinelli
Do not use the model `_description` field which cannot be translated. Use the `display_name` of the corresponding model instead. Moreover, `<t t-esc="'%s' % model_description or 'document'"/>` gives `'None'`, while `'document'` is expected. This adds a query to some tests, which is expected since `display_name` requires information stored in the DB, while `_description` is defined at the Python level. opw-1908420
2019-01-24[IMP] mail, snailmail, snailmail_account: improve error managementAntoine Prieels (ANP)
When a letter is sent through snailmail and encounter an error, it used to create an activity to the user to notify him that there was an error with its letter. When a user had this activity, he didn't have any clues of what was the error and how to manage it. So we decided to better handle snailmail errors and give the possibility to the user to easily fix the source of the snailmail errors. First to give a better feedback on the letters in errors, we've made features similar to ones existing for emails: - We add a mail message on the document that sent the letter, and put a small paper plane icon, which is red when an error occurs (like the envelope for email) - As letters can be sent in batch, we've also added an entry in the systray to easily manage the different documents having snailmail errors like for emails. Then we identified, the most common errors encountered with the snailmail letters and give proper way to let the user fix them: - Missing Required Field: - The address is not complete, some of the fields are empty. - We open a wizard allowing the user to modify the partner address and we try to resend all letters having this error on the modified partner. - We also try to avoid this error, by opening the wizard before sending the letter, but it only works for single documents, not for batch. - Trial/Credit Error: - The user has not enough credits to send letters anymore. - We open a wizard that give a redirection lnk to add credits on its iap account. - No Price Available: - The destination country is not supported by any of our providers, and we cannot do anything to send this letter. - Format Error: - The format of the pdf report send by the user is refused by our providers, because some visual stuffs are not respected, for example blank zone to print barcode or margins. - We show a wizard to the user letting him check a setting option that add a cover page in the envelope and the documents will be send with this extra page containing the address. - Unknown Error: - This is not one of the listed error above. - A wizard suggesting the user to contact support is displayed. The cron that try to resend letters on error, has been addapted to only try to send the error of type Trial/No Credit, because the account might have been reloaded, and other errors, won't change if they have not been fixed locally. closes odoo/odoo#29685
2019-01-17[IMP] mail: upload a file to mark activity as donejem-odoo
This commit introduces the "upload file" activity type category. For an activity of that time, uploading a file will mark the activity as done (and maybe create the forced next activities). This activity type is seen as a shortcut to upload a file with a reminder. Task-1915004 closes odoo/odoo#29861
2019-01-09[MERGE] forward port branch saas-12.1 up to 8aa8548d8abChristophe Simonis
2018-12-13[IMP] test_mail: update counters to current runbots stateThibault Delavallée
Some counters are a bit higher than real counters; test_mail help counters are not up to date in some cases. closes odoo/odoo#29518
2018-12-12[IMP] mail: clean activities access rightsSébastien Theys
This commit improves code of access rights checks when creating or updating activities. Several points triggers this commit * we would like to use _filter_access_rules and override it on activities model in order to be more standard; * we would like to get rid of sudo used in various CRUD overrides as using standard ORM method allows to correctly use current user; * we would like to get rid of create_user_id field once we can keep the current user as create_uid; Access rights are a bit updated. They are now the following * you can create activities for documents like posting messages (using _mail_post_access attribute; if not defined, write access on document is required); * you can read activities for documents you can read; * you can write and unlink activities either following the defined access rule (created OR assigned), and otherwise like posting messages ( using _mail_post_access attribute; if not defined, write access on document is required); In this commit we also hide edit / mark as done / cancel buttons for activities the current user cannot modify. This commit is linked to task ID 1856417 and PR #27619. Co-Authored-By: Sébastien Theys <seb@odoo.com> Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2018-11-02[FIX] mail: access error when reading a channelNicolas Seinlet
When a record inaccessible by the user is linked to a message in a channel accessible to the user, Avoid to raise an access error due to this linked record. Also need an aditional query in test query_count. closes odoo/odoo#28312
2018-10-23[IMP][FIX] test_mail: correctly simulate email send in performance testsThibault Delavallée
Commit 356a42166082f9448b7e82393caeb00839be8c8f introduced a hook to avoid sending emails while installing application data. However we have to carefully re-activate email sending in tests that depend on them especially performance tests. This commit also update performance counters to match the current state of counters as it was not totally updated. Commit linked to task ID 1902307.
2018-10-22[MERGE] forward port branch saas-11.4 up to 3c108977c1eChristophe Simonis
2018-10-19[FIX] test_mail: bump query count marginChristophe Simonis
Needed to make test pass with `mail_push` (enterprise module) installed.
2018-10-12[FIX] mail: avoid concurrent update of notificationsThibault Delavallée
When sending notifications by batch one notification email can be send up to 50 people. For one mail_mail entry to handle 50 emails can be sent as those are sent independently for each recipient. In some cases a bounce may occur while the whole batch of recipients is not completely mailed. In that case the mailgateway will update the notification status to bounced. When the cron finishes to send the whole batch of emails it tries to update the notifications of all recipients. However as a notification has already been updated due to the bounce we face a concurrent update, meaning the transaction is rollbacked. Emails have been sent but notifications are not considered as sent as they have not been updated accordingly. Next time the cron runs it will send the same batch again, with probably the same bounce and rollback. We could therefore face an email loop. This commit fixes that by setting notifications to a transient exception state. Notifications are locked, meaning bounced will have to wait for the transaction to finish before updating them. That way the cron can run safely on the whole batch and we avoid having emails loop. It has an impact on query count as a search and write is performed in the send process. This commit is linked to task ID 1893054. Done in collaboration with @Xavier-Do .
2018-10-11[FIX] mail: avoid sending mail when creating record from dataXavierDo
Before this fix the creation of task assigned to admin was leading to the creation of mails. This is a generic fix to avoid to notifiy a user when he is add as a follower when creating data from odoo data files. closes odoo/odoo#27682
2018-09-14[IMP] mail: add main attachment support on mail.threadOlivier Colson
This is done by adding a new field on mail.thread objects and setting it when posting a message with attachments on a model inheriting from mail.thread. Was part of PR #26740 Was part of task #1880089
2018-08-23[IMP] base: add regular user admin as uid 2Raphael Collet
User 1 simply becomes a technical user (inactive, no password).
2018-08-22[REF] test_mail: update counters due to enterprise ocn_client addAdrien Dieudonne
This commit is related to enterprise commit that replaced mail_push. It is about: [MOV] ocn_client: Odoo Cloud Notification for mobile push notifications odoo/enterprise@7587be4663c39f6388d752c0eb5f81f53a1ba9f8 Indeed counters are impacted by code located in enterprise because those are "maximum queries" counters. As ocn_client is an auto-install module enterprise runbot would be broken if the counters weren't updated.
2018-08-21[IMP] core, test_mail: improve query count assertionsXavierDo
-remove margin With the spirit of making tests determinists, we can remove margins to have a real test of query count. -mock random on assert query count bus gc is triggered using random. Therefore, when send_many is called, we have 1% chance to have more query. Mocking random.random to 1 will disable gc during query count tests (not during warmup). Could be interresting to put gc collection in a cron latter -add more info on querycount Adding file and line number on query count failure/info will help to update the query counts. -update query count based on enterprise Update all query count with enterprise values (exactly) -normalize query counts with enterprise voip module add a read on activity type (during create) in enterprise, leading to one more query but also more information in cache. Therefore, the next assertion will need one more query to access this data in community. Adding an access to activity type in the first assertion will allow to have the same cache state in community and enterprise. Task: #1878588 PR: #26476
2018-08-14[FIX] test_mail: update query count 2XavierDo
Update the query count to avoid the runbot to be randomly red Temporary fix!!!!! Will need to check with in details what is the cause of this. Those are the changes for the second part of test
2018-08-14[FIX] test_mail: update query countXavierDo
Update the query count to avoid the runbot to be randomly red Temporary fix!!!!! Will need to check with in details what is the cause of this.
2018-08-10[MERGE][IMP] mail, mail_bot: improve Discuss onboarding and add your new ↵Thibault Delavallée
best friend Purpose of this merge is to improve onboarding of Discuss. This is done via a wow effect and a bot to test the Discuss app; otherwise you have nobody to talk to. Purpose is also to improve retention as "the best way to increase retention is this: when the user invites someone, when this guy activates its account, the user gets a push notification from the invited user that just logged in; that way he will come back to Odoo and start discussing with its colleagues. Concerning your new best friend: it is not a dog but Odoobot. See sub commits for more details. This merge is linked to task ID 1838588 and closes PR #25075.
2018-08-10[MERGE] forward port branch saas-11.4 up to edd586002e9Christophe Simonis
2018-08-10[ADD] mail_bot, im_livechat_mail_bot: add Odoobot, your new best friendXavierDo
Purpose of this commit is to improve onboarding with a wow effect and a bot to test the Discuss app. Otherwise new users have nobody to talk to. Retention will be improved by both increasing interactions and onboarding of Discuss features. This commit adds a simple bot in discuss. It answers some questions, helps users getting their hand on discuss and eases the onboarding. In this version, the flow is quite simple, and only im_livechat adds some logic in order to show canned response. The logic is contained in new modules: mail_bot and im_livechat_mail_bot in order to keep everything well separated. It also allows users to remove the mailbot if they do not want to keep this functionality. Odoobot will only answer if he is in the onboarding conversation (alone with a user in a channel of type chat) or if a user pings odoobot. Odoobot logic applies to both standard chatter / channel messages and also transient messages (like help commands). Specifications * 2 minutes after first sign in, users will receive a direct chat from Odoobot; * make Odoobot an archived partner; * scenario * Odoobot: "Hello, I'm here to help you discover chat features. Try answering me with an emoji :)"; * User: Send emoji * Odoobot: "Great! :) Did you notice that you can also send attachments, like a picture of your cute dog? Try it!" * Odoobot: "Not a cute dog, but you get it :) To access special features, start your sentence with "/" (I.E. /help)"" * User: /help * Auto message then Odoobot: "Wow you're a natural! As a channel usually contain a lot of users, you can grab the attention with a ping. Try to ping me with @Odoobot!" * User: @Odoobot lorem ipsum * if Livechat installed * add 2 demo canned response so it does not look weird (like "Hello, how may I help you?" and "Have a nice day!") * Odoobot: "Perfect! <br> Try to type ":" to use canned responses." * User tries canned * Odoobot: "Good, you can customize your canned responses in the live chat application. <br><br> + réponse suivante" * Odoobot: "There's 3 different ways in Odoo to interact with your colleagues: via this chat window, [img of chat window] via the Discuss application [img of Discuss app + icon on it] or via the chatter [img of the chatter]. Aaaaand that's it! Enjoy discovering Odoo! :)" * random answers to ping/bad answer * "Mmmmh I'm not sure what you mean.. Can you try again?" * "I'm afraid I don't understand. Sorry!" * when someone pings @OdooBot with no reason: Odoobot: Yaaaay that's me! [party emoji] * fun stuff to add for some answer * User: i love you / love * Odoobot: Aaaaaw that's really cute but, you know, bots don't work that way. You're too human for me! Let's keep it professional <3 * User: Fuck * Odoobot: That's not a really nice thing to say, you know? I'm a bot but I have feelings, ok?! </3 This commit is linked to task ID 1838588 and PR #25075.
2018-08-09[MERGE] forward port branch saas-11.3 up to af35aea6b0dChristophe Simonis
2018-08-09[FIX] test_mail: bump query countChristophe Simonis
An extra query is made because of new group added to fields in 57ea939edac7ae4fa19306bf827231027f3c245c.
2018-08-09[IMP] mail: do not subscribe inactive partnersXavierDo
We do not want inactive partners to be added as followers. Indeed this may lead to unwanted notifications send as inactive partners are not easily found in the various widgets. It also creates unnecessary data and computation. This commit has a small impact on performances as we choose to do it in message_ subscribe method. Private _message_method is left untouched as parameters given to this method are left to caller control. This commit is linked to task ID 1838588.
2018-08-07[REF] mail: propagate recipient data through notification processThibault Delavallée
Purpose of this commit is to avoid browsing and prefetching data about recipients when notifying a message to partners and channels. Mail message _notify computes all necessary data in a single query. This commit allow to re-use this data by propagating it through the call chain. Addons inheriting from classification methods used when sending notification emails are updated accordingly to the API and data update. This commit is linked to task ID 47934 and PR #24033. No functional change should occur with this commit.
2018-08-07[REF] mail: clean code related to notification email generationThibault Delavallée
This commit cleans code about sending email notification to recipients. Purpose of this code is to prepare notification emails, group recipients and finally send emails. In this commit we clean and optimize a bit by * propagating some additional parameter to simplify code, like record on which the notification process runs; * inlining some code currently located in sub-methods. It eases code understanding as there are less code jumps. As those methods are not inherited inlining them can be done; * simplifying a bit notification emails preparation and computation; It allows to save a few query by avoiding to fetch and browse again some data that were already computed. This commit is linked to task ID 47934 and PR #24033. No functional change should occur with this commit.
2018-08-07[REF] test_mail: update counters due to enterprise mail_push updateThibault Delavallée
This commit is related to enterprise commit that updated mail_push. It is about [REF] mail_push: optimize mail.message notification process override It updates code of mail_push to lessen its impact on mail-related code. It allows to change a few counters in test_mail. Indeed counters are impacted by code located in enterprise because those are "maximum queries" counters. As mail_push is an auto-install module enterprise runbot would be broken if the counters weren't updated. This commit is linked to task ID 47934 and PR #24033. No functional change should occur with this commit.
2018-08-07[REF] mail: optimize notification recipients data fetch through SQL queryThibault Delavallée
In this commit we update _notify method of mail.message to fetch most data related to notification process in a single query. Indeed posting a message can be a costly process, especially when involving several partners, channels, depending on their notification status, user groups, ... Most of the required data can be fetched in a single hand-tuned query. Purpose is to lessen query count. Side effect of this commit is that code is less recordset based and therefore more low-level. It is also harder to customize the behavior through inheritance as it implies rewriting a bit more of code. This query is located in a private method on follower model. It takes parameters allowing to either fetch data related to followers of a given subtype, either related to some partners and channels. First use case is related to the process of posting a message with a subtype that triggers notification of followers. Second use case is related to notifying some specific partners or channels of a given message. It takes notably into consideration internal subtypes and active field of partners, allowing to correctly handle corner case for deactivated followers and portal / share partners. Notification process is divided into two steps. First one is to compute recipient data. Second one is to apply the result of this computation and call the various notification mechanisms accordingly. Doing so allows to easily re-call notification process or compute some data differently if necessary. API of notification methods is updated to allow passing notably the values used to create the newly-posted message. It allows in some simple case to avoid browsing message and partners when no notification is necessary. It saves some queries in simple case like posting messages with specific subtypes not often followed or logging notes without mentioning people. This commit allows to save a few queries on several performance tests as indicated by updated performance counters. Future commits will gradually propagate the use of this data to further lessen query count. This commit is linked to task ID 47934 and PR #24033. No functional change should occur with this commit.
2018-08-01[IMP] mail: create tracking value using the insert multiThibault Delavallée
Purpose of this commit is to speedup tracking values creation by manually creating them using the newly-introduced multi create. As tracking values creation is already done manually as sudo when creating mail message we just update the code to directly insert them as multi. This commit is linked to task ID 1870656 and PR #26068. No functional change should occur with this commit.
2018-08-01[IMP] test_mail: update countersThibault Delavallée
Commit 896e36edab137f3ec0c8da3b140e805b11ba5512 added support of multi insertions when creating new records. This had a great impact on mail-related tests involving several followers update. This commit updates the counters to match the current runbot state on master. This commit is linked to task ID 1870656 and PR #26068. No functional change should occur with this commit.
2018-06-08[IMP] test_mail: add a tag on performance testsThibault Delavallée
It allow to easily recompute performance-related tests when working on mail thread features. Tags are awesome.
2018-05-16[FIX] mail: correctly filter needaction on unread notifications in ↵Xavier Dollé
message_format Previously to this commit needaction used by JS was not taking into account read notifications. It means notably Inbox counter could be higher than expected as taking into account read messages while Inbox displays only unread messages. This commit fixes that by checking notification state when giving needaction_partner_ids to message_format result. This fix has a small impact on performances as message_format is used in notification process for chat or push. A better implementation of message format and its postprocess could probably lessen this fix impact. As we target stable version we avoid rewriting other part of the code. Optimization will be done in development version. Related to task ID 1841243. This is a manual forward port of commit 69714fbeee479cd3e0f89de39b3687c183791fc0 done in saas-11.2.
2018-05-16[FIX] mail: correctly filter needaction on unread notifications in ↵Xavier Dollé
message_format Previously to this commit needaction used by JS was not taking into account read notifications. It means notably Inbox counter could be higher than expected as taking into account read messages while Inbox displays only unread messages. This commit fixes that by checking notification state when giving needaction_partner_ids to message_format result. This fix has a small impact on performances as message_format is used in notification process for chat or push. A better implementation of message format and its postprocess could probably lessen this fix impact. As we target stable version we avoid rewriting other part of the code. Optimization will be done in development version. Related to task ID 1841243. This is a manual forward-port of commit 69714fbeee479cd3e0f89de39b3687c183791fc0 done in saas-11.2.
2018-05-07[REF] mail: make notification methods semi-genericThibault Delavallée
mail.thread mixing class defines several methods used in notification process that are not specific to mail.thread enabled models. It means some models could override it while some other models do not even have a direct access to that method. When calling those methods we have to manually check for method being available on a record or call a default implementation from mail.thread even if the model does not inherit from the mixin. In this commit we propose to hide this check in generic wrappers located in mail.thread class. It checks for method existence on record and call the model-specific implementation or falls back on standard behavior. It allows to be sure the right method is called. Functionally behavior should stay globally the same. However when updating some addons code has been updated. Previous code could lead to records not having correct alias which should not be the case anymore. This commit is linked to task ID 47934.
2018-05-02[IMP] mail, mass_mailing: clean mail body processing and mail sent post ↵Thibault Delavallée
processing Purpose is to lessen query count by avoiding to browse and/or fetch data when not necessary. This commit does two main things * first one is to avoid checking for existing statistics in mass_mailing where only checking existing of a mass_mailing on a mail to send is sufficient. It allows to avoid fetching data from statistics table; * second one is to rewrite part of the post_process code called after sending emails. Using list comprehension and mailing_id existence on mail_mail allows to save several queries on standard post flows; Most tests benefit from this code update. On overall community runbot about 3K queries are saved with those small optimizations.
2018-05-02[IMP] test_mail: update top counters due to enterprise update.Thibault Delavallée
mail_push module in enterprise was adding too much extra queries. mail_push being auto-install in enterprise mail performance tests were done with its overhead taken into account. Commit done in enterprise cleaned a bit the code to lessen mail_push impact allowing to lessen some top counters. Community runbot counters are now nearer enterprise-based counters. This commit is related to enterprise commit https://github.com/odoo/enterprise/commit/0a3ba658f18e03fd76caba86cba7be32d047f0a9 .
2018-05-02[REF] mail: shortcut chat notification if no one to notifyThibault Delavallée
Well, it seems we gain a lot of query when avoiding to format a message we actually don't have to send on any bus. Cheers. Formatting message for bus notification is quite costly as it has to fetch data from message, partner, attachments, subtypes, ... meaning a lot of queries. With this commit we avoid calling that method when not necessary. It allows a gain of queries in simple cases when no-one has to be notified as shown in the performance counters. On overall community runbot about 9K queries are saved which is not bad for a 2-lines commit.
2018-05-02[IMP] mail: update subscription instead of unlink / create new followersThibault Delavallée
In some cases when subscribing followers code may ask to force subtypes of the subscription. It means existing followers should have only asked subtypes independently from existing subtypes. Previously it was done by unlinking and creating new followers for same partner or channel. This commit proposes to instead update missing subtypes and remove extra subtypes. It has a small impact in real life as forcing subtype is not done often. Some tests are improved thanks to this commit. This commit is linked to task ID 1839043. Closes #24417.
2018-04-11[IMP] test_mail: follow activities in performance testsThibault Delavallée
Commit 07ae0ccc4e4b4f79cf299f2a54ad3ee5e3a250af set activities as not followed by default on records. However this has an impact on performance test that should not happen. Indeed performance tests should be based on technical decisions, not business decisions. We therefore set activities as followed by default in some advanced performance tests to always have results that can be compared.
2018-04-10[FIX] test_mail: add forgotten margin on activity testThibault Delavallée
Those are notoriously prone to have a one query more-or-less behavior.
2018-04-10[IMP] mail: limit cache invalidation when managing messagesThibault Delavallée
This commit proposes to limit cache invalidation at some cases that will trigger some behavior change when dealing with mail messages : * creating messages linked to a document; * update model or res_id of a message; * updating notifications, as notified people could change some computed fields on the record; This commit also invalidates only mail-related fields as updating messages should not invalidate other things than some computed fields linked to mail.
2018-04-10[IMP] mail: limit cache invalidation when subscribing followersThibault Delavallée
Cache invalidation when subscribing people has been added at e6f038a8216c249a3ce7d9f490010d9f666f3375. Indeed subscribing partners to a record may lead to an access right update as some of them are based on followers. This is why a cache invalidation is necessary to avoid access rights issues. However subscribing people to a record should change their rights only on the records involved in the subscription mechanism. We can therefore give ids to the cache invalidation to limit to updated records. Cache invalidation is also limited when writing on followers if writing on model, res_id or partner_id fields. Indeed changing subtypes or channel of a subscription should have no impact on cache and access rights. Cache invalidation done manually in _message_subscribe is not necessary as subscription create or update mail.followers records since f9c210923d89aeabfc358fdc7b8bd76df8c23ce8. Create and write of mail.followers records already ask for cache invalidation. It is therefore not necessary to invalidate cache twice. This commit allows to save a few queries on some tests, notably about activities that deal with subscription and messages. As cache is now kept it is not necessary to refetch some data, leading to a few query gain. We gain about 1K queries on com runbot. A side effect of limiting cache invalidation is that some unit tests require a manual cache invalidation to have up to date results. Indeed record not being up to date in cache was hidden by the invalidation we just removed.
2018-04-10[IMP] mail: remove cache invalidation when notifying a message with a parentThibault Delavallée
When notifying partners or channels of a message, a cache invalidation is currently done if the message has a parent. This invalidation has been done when migrating the mail module at the new API at 4b122ad41d873febe288ab1f8c6cdc078ca2a479. In that time notifying people of a message lead to the creation of notifications of the parent message, if any. It was due to the chatter being threaded and therefore displaying message with their header message. Adding notifications for the parent was necessary to avoid access rights issues when fetching parent message data. Indeed as being notified is one of the rule to see a message record adding notifications was done. A cache invalidation has therefore been added to clean the message cache and ensure everything was fine. Commit 88b8cd058713bfad2942f7e7434c34b6c1a6e7da changed the way notifications are modeled in Odoo. Notification on parent message was removed and access rights changed. Threaded mode for Chatter has also been removed. However cache invalidation has been kept probably by fear of removing it. It does not seem to have any viable reason to invalidate cache when a message has a parent. Posting a message does not push other messages in users's Inbox meaning there should not be any issue with the cache preventing to see messages. Removing this cache invalidation allow to gain queries in performance tests. It has an impact on each process involving message creation which is quite common in Odoo.