summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_message.py
AgeCommit message (Collapse)Author
2021-03-08[FIX] mail, test_mail: ensure thread name is up to date on messageDidier (did)
When formatting a message, a message could be with an empty or obsolete record_name field. It's better to rely on the relation between the message and the thread and fetch the current thread name. task-2411715 closes odoo/odoo#63000 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-01-28[FIX] mail: make Inbox counters more reliable in mark as read flowsSébastien Theys
- Send the new Inbox counter when marking as read, to guarantee the JS has the correct value (instead of having to guess it which was impossible when an arbitrary domain was given to the method). NOTE: Manual increment is kept on receiving a new Inbox message because that one was reliable and it would have been more tricky to compute the new counter for each target partner (mark as read is one user doing an action for himself, whereas new message is from another user to potentially many different users). Generic counter for threads is also not sent on every change for similar reasons. - Refresh Inbox automatically when some messages are marked as read and there are more message on the server than currently loaded. - Remove confusing (and impossible to maintain) counter on non-origin threads (in particular channel followers). This behavior in JS was not consistent with the server which always counted only origin thread (model/res_id). task-2446302 closes odoo/odoo#65161 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-04-22[REF] test_mail: rename test models to ease understandingThibault Delavallée
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-08[REF] base: Remove deprecated exceptions and osvJulien Castiaux
TL;DR: remember `osv` and `except_orm` ? You can forget about them. * Deprecated `except_orm` dropped. * `UserError` elevated as super type of all user-related errors. * Unused `DeferredException` dropped. * Unused `QWebException` dropped (real one is in `qweb.py`). * `MailDeliveryException` made a python exception. * `name` legacy exception attribute made an alias of the python standard `args[0]` attribute and deprecated. * `value` legacy exception attribute dropped. * `exception_type` RPC error response key dropped. * Deprecated `osv` module dropped. * `--osv-memory-age-limit` cli option made an alias of `--transient-age-limit` and deprecated. The `odoo.exceptions.Warning` have long been a deprecated alias to `UserError`. It is going to be removed in a future version but first we explicitly deprecate it with a warning. The `odoo.exceptions.DeferredException` was a very old internal exception, it has been removed without deprecation notice as it is never raised. The `odoo.exceptions.except_orm` has been a deprecated exception type with deprecation warning for 5 years, it has been removed in favor of UserError which becomes the super class of all user-related errors. The `odoo.base.models.ir_mail_server.MailDeliveryException` was inheriting `except_orm`. As it is not related to a user error but is more of a problem an admin much take care of, the exception has been made a Python error. The `exception_type` JSON key in RPC error responses was holding an hardcoded value derived from the exception type. Its usage has been dropped in favor of the `name` JSON key that holds the precise exception name. Again as it was hardly used in the source code (beside the crash manager) it has been dropped without deprecation warning. Since we are here trying to clean odoo custom exceptions, we are also deprecating the `name` exception attribute in favor of the more standard `args[0]` attribute. The `name` (along with `value`) were two attributes used to raise `except_orm` exceptions before the introduction of `UserError`, `AccessError` and related exceptions. The `name` attribute, at the time, was holding the exception type/title. Nowadays it contains the error message. The `value` attribute, at the time, was holding the error message. Nowadays it is no more used. The `osv` module contains very old deprecated aliases. There is no simple way to log a deprecation warning for osv, osv_memory and osv_abstract but as they have not been in use for ages, they have been removed too. To be consistent, the `--osv-memory-age-limit` cli option has been made a deprecated alias to the `--transient-age-limit`. closes odoo/odoo#45723 Task: 2187728 Related: odoo/enterprise#9162 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-02-06[FIX] mail: fix issue when posting a message on a document whose first ↵helly kapatel
message / parent is not readable How to reproduce ================ Have a portal user commenting a task on the customer portal. He may experience a crash if previous message / first message is not available, for example if it is internal or not published. This is due to reference computation used in outgoing emails as it is based on parent messageID. Accessing it crashes although it should not as it is used only for technical purpose. Fix === In this comme we fix that issue by browsing the reference message as sudo to access its messageID. A test is added to avoid regressions. Task ID 2061760 PR #36845 closes odoo/odoo#44765 X-original-commit: e94349ed65e05a40af6e690e366de81fc5aa6725 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com> Co-authored-by: jpr-odoo <jpr@openerp.com>
2020-01-23Revert "[IMP] test_mail(_full): run tests at post_install"Xavier-Do
This reverts commit 976e560a877bcaf9e769b6005d33bd49833eceb9. Even if it didn't looked like a bad idea, this need some more thinking. This new version of query count creates random failure of runbot builds. closes odoo/odoo#43820 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-22[IMP] test_mail(_full): run tests at post_installSébastien Theys
- take advantage of runbot multi-build capabilities - get similar result when running them locally during dev - better detect when other modules add extra queries Query counts are split in the base value (testing with just test_mail installed) + the extra modules overhead. Part of task-2178641 closes odoo/odoo#43666 Pr: #43666 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-01-10[FIX] mail: mark all messages as read in discuss inboxAlexandre Kühn
Revision on https://github.com/odoo/odoo/commit/a55c78836f172dba1cfa6db3df0e927a9c7e6471 Before this commit, marking all messages as read from Discuss inbox did not update the UI correctly, hence requiring a page reload. This bug comes from a typo in the commit above, which passed a list of mail_notification instead of message ids, so that messages were handled as marked as read by the web client. Task-Id 2158452 closes odoo/odoo#43109 X-original-commit: 3cc03ee3db90c310dc60fe7ea18e0e6abe741ffa Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2019-12-02[REF] mail, various: rename subtype parameter of message_post to subtype_xmlidThibault Delavallée
PURPOSE Clean posting process and improve mail.message definition and comprehension. SPECIFICATIONS In order to be more explicit subtype parameter is renamed to subtype_xmlid. It therefore clearly indicates it should be a valid subtype Xml ID. Support of ill formatted Xml IDs is removed because there is no reason to try to add some random prefix. Give something that exists or go to hell, punk ! LINKS Task ID 2071556 PR #38692
2019-11-20[REF] test_mail: update test mail message to new commonThibault Delavallée
PURPOSE Currently tools and asserts for mail tests are located inside test_mail module. It makes difficult to re-use them in apps tests or force them to write custom quick and dirty tools and asserts. SPECIFICATIONS Update tests to new tools / asserts / helpers / classes defined in mail and test_mail. Notably * ``BaseFunctionalTest`` class is replaced by the new ``TestMailCommon`` pimped one; * ``assertNotifications`` is replaced by ``assertSinglePostNotifications`` (shortcut for a simple message_post) or ``assertPostNotifications`` (complete asserts involving several messages and notifications); * correctly invoke ``mock_mail_gateway`` when mocking email sending; * replace manual check of sent emails or ``assertEmails`` by ``assertSentEmails``; * remove custom mocks / checks and replace them by now standard mocks and assertions (if any); In this commit we update: test mail message LINKS Task ID 2068986 PR #38070
2019-09-19[REF] base,mail,tools: use new python email APIJulien Castiaux
[PEP 594] is going to depreciate the legacy `email.message.Message` API and its related modules: `email.(charset|header|mime|utils)`. The new `email.message.EmailMessage` API exposes a much easier interface to create multiparted emails [1], is capable of doing all the necessary headers value conversion (RFCs [2045], [2047], [2049]) [2] and get/set different flavor of payload (text/bytes) in a straightforward way [3]. All headers are structured in a way to support python native types, i.e. the `Date` header supports `datetime.datetime` objects and automatically performs the required formatting. The same goes for multi-valued headers like the `To` header, one can directly set a python list of values, it will be automatically be formatted according to the RFCs. The dedicated encoding and decoding functions are no more needed thus has been removed has part of the refactor. FTR, [RFC2231] is an update of [RFC2047] and based on tests we've just conducted, both GMail and Thunderbird now support RFC2231 encoding just fine in all headers: attachments names, From, etc. [1]: http://docs.python.org/3/library/email.message.html [2]: http://docs.python.org/3/library/email.headerregistry.html [3]: http://docs.python.org/3/library/email.contentmanager.html [2045]: https://tools.ietf.org/html/rfc2045 [2047]: https://tools.ietf.org/html/rfc2047 [2049]: https://tools.ietf.org/html/rfc2049 [2231]: https://tools.ietf.org/html/rfc2231 closes odoo/odoo#35929 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2019-09-17[REF] mail: remove deprecated email formataddrJulien Castiaux
[PEP 594] is going to depreciate the legacy `email.message.Message` API and its related modules. Among them the `email.utils.formataddr` function, this function takes a `(name, email)` pair and returns a string value suitable for From, To and Cc headers. The stdlib function is capable of handling several character encoding and two binary-to-ascii encoding. Odoo only uses `utf-8` which is compatible with the base64 b2a encoding. The re-implementation of that function has been simplified to only support base64-ed utf-8 and ascii. [PEP 594]: https://www.python.org/dev/peps/pep-0594/\#email-lagacy-api
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[IMP] mail, test_mail: new 'History' mailbox in DiscussNikunj Ladava
This commit adds a new mailbox in the Discuss app called 'History'. Messages that have been marked as read are moved to 'History'. Notifications are required to link history messages to users. So notifications are now deleted after they are more tha 6 months old. This means History mailbox keeps less than 6 months old messages. Note that this feature only works when user notifications are handled in Odoo. This can be set in the user preferences, under the "Notification Management" section. 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] api.py: Rename company_id/company_ids into company/companiesYannick Tivisse
The goal is to be coherent with the user property. Actually, company_id and company_ids on the environment are no fields. Calling env.company_id returns a browse record, not an id.
2019-05-13[IMP] base: Contextualize the multi companyYannick Tivisse
Purpose ======= Allow the user to select the allowed companies for which he wants to see records on top of selecting his current company. It is confusing for users to see the records from the company he is connected to and the records of the children companies. Instead of using the hierarchy of companies to access records across companies, the user can now select (from his set of allowed companies) the companies for which he wants to access records. /!\ This means that the user will interact with records from company A when in company B. Example: a SO has been created and confirmed in A. When in B, I create the invoice from it. Specifications ============== 1/ Deprecate the parent/children hierarchy on the res.company model. The fields are kept on the res.company model to ensure the retro-compatibility, but won't be used accross the standard code anymore. The only functional usage for this mechanism was to allow to see records from several companies by creating a virtual parent company, which will be possible with the new mechanism. 2/ By default, a user will only see the records of the company he is connected to (or records without a company). (It is still editable by the user if needed). For that, put this information in the user context, to allow having different configurations on different browser tabs. Instead of having domains like ['|', ('company_id', '=', False), ('company_id', 'child_of', user.company_id.id)] you'll have something like ['|', ('company_id', '=', False), ('company_id', 'in', company_ids)] Note that the 'company_ids' is a value that is passed in the evaluation context on the record rule, as we already have user, or time. company_ids is a list of the ids of all the enabled companies in the user's context. 3/ Out of the generic improvements brought by this task, this will illustrate issues that could exist since several versions. For example, it should not be possible to create a scrap order for the company A with a package of the company B, or it should not be possible to create an invoice on the company A with payment terms from the company B. Before the version 12.0, it was easy to encounter this kind of issues as the admin was the SUPERUSER_ID. A positive side effect of the fact that the SUPERUSER_ID has become an inactive user was to make it more difficult to introduce mismatch on the records, but haven't solved the issue, as it was still possible to do it with parent companies configuration. Some of these issues have been fixed in this commit, but all the business flows should be re-tested to check if an ir.rule should be introduced (eg: a multi company rule for stock.quand.package), if the company of a record is correctly transfered to another record created from the first record (eg: From a SO, create an invoice and a payment, the company of the sales order should be transfered on the invoice and the payment, even if the company of the sales order is A and I'm logged into the company B with the company A enabled. 4/ Currently, if I click on a button on a notification email (example 'View Task'), I face a traceback if I'm not logged into the company of the record. Now, if you click on a button and if you have access to the record, the correct company will be automatically set. 5/ If I display a kanban view with several records from several companies (and an image), all the images should be displayed. 6/ Currently if you copy paste an url, this will crash if you're not in the correct company. This won't be fixed because it's quite impossible to do it in a clean way. This task brings a workaround. Copy/Paste -> Traceback -> Log into the correct company, re-copy/paste -> Ok. 7/ 2 property methods have been added on the environment to retrieve the company on which the user is logged in and the companies the user enabled, on a specific tab. That way, when creating a record, instead of doing default=lambda self: self.env.user.company_id do default=lambda self: self.env.company_id On the other hand, to retrieve the enabled companies, do companies = self.env.company_ids 8/ Modify the Company Switcher widget to allow to log into another company WITHOUT writing on the res.users (and thus bringing cache invalidation issues and so on). Also allow to enable several companies and see records from several companies, and independantly of the other browser's tabs. 9/ When focusing on a tab, save the current company configuration on the local storage. That way, when doing 'CTRL+T' or a middle click, the context is propagated to the new tab. 10/ Improve the error message in case of multi company access errors. Now, when the user is in debug mode, display the related names of the records and the name of the user who brings the issue. 11/ Remove the context erasing when writing on a res.users This is probably coming from the migration to new API of the base module. The context was not propagated at this moment, which was a common mistake at that time. When migrating the module, probably by using the 'black box' method, as the context was not propagated, it was erased on the new version. This is now an issue because the context (i.e. the enabled companies) was erased when writing on a res.users, leading to tracebacks. See: https://github.com/odoo/odoo/commit/7eab8e26d3d46c53f4be924d6a34e80a66e74960#diff-4c2e738ee8f64f11806c889ea097b5e7R624 12/ Fix the crash manager on redirect warnings. The issue is the following - Create an invoice on a company without a configured CoA. - Set a partner - On the onchange_partner_id, a redirect warning is raised to propose you to configure a CoA - Click on 'Go to the configuration panel' - A generic warning says something like 'Do you want to discard your changes?' - Click on yes, the page refreshes, but not on the redirect action. Now, set correctly the action on the hash, and reload instead. The breadcrumb is lost for example, but you reach the correct action at least. 13/ Introduce a res.group to enable/disable the multi company per tab feature. 14/ To help the users to know which tab is in which company, add the possibility to have a favicon per company. When creating a company, the classical 'O' icon is colored by default in a random color. 15/ Remove the company switcher on the frontend. This was mainly there to allow a user to swicth to the company linked to the website. This behavior is now transparent to the user. If the website A is activated, then the company set on the context is the company of the website. 16/ Deprecated the _company_default_get method on the res.company model. Remove the method _get_company on the res.users model. 17/ Add 'allowed_company_ids' and 'current_company_id' on the pyeval context. You can now use those variables on domains in the views to access directly to the activated company.ies on the current tab. TaskID: 1960971 closes odoo/odoo#32341 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-03-25[MERGE] forward port branch 12.0 up to 11b1e12cde3Christophe Simonis
2019-03-25[MERGE] forward port branch saas-11.3 up to e9068c290b3Christophe Simonis
2019-03-25[MERGE] forward port branch 11.0 up to 0196a6feb5aChristophe Simonis
2018-12-03[IMP] base,stock: Improve company demo datalul-odoo
On test fixes: Because the company now have parenthesis in its name, formatting email addresses adds double quotes around the name. e.g.: "My Company (San Francisco)" <example@exmaple.com>
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-06-06[IMP] mail: add moderation on channelsMathieu Duckaerts-Antoine
Purpose of this commit is to allow moderation on incoming messages in discussion channels. On some channels on which moderation is required messages should be in a pending moderation stage. Moderators can accept or refuse messages as well as always allow or ban messages coming from a given set of emails. Channels now have an option to be moderated. Moderators can be added on channels. They have access to a specific UI in Discuss to see and take action on messages waiting for moderation. Concerning mail.thread message that are pending moderation are not notified. It means nobody receives a notification about them. Moderation process calls the notification once the message is validated. Various features included in this commit : * a model is added to store the decision about emails, allow or ban; * access rights are updated so that only moderators can modify moderation fields on message; * specific bus notifications are send to moderated people as well as to moderators on incoming emails as well as when a decision is taken; * options are added on channels to send explanations to moderated emails; * options are added on channels to write and send guidelines explaining why and how moderation is performed; * a reminder is send daily to moderators with remaining messages to moderate; * discuss UI is adapted and a new channel is added below Inbox and Starred giving access to moderation tools; * chanenl UI is adapted allowing to moderate directly inside channels; This commit is linked to task ID 29521. Closes #21921.
2018-03-08[FIX] test_mail: make some tests independent from other module demo dataThibault Delavallée
There is a test checking message access rights and search results. It searches for messages created in the test class having a subject like Test. However this search may return more results than expected. For example project create messages containing Test. As we want to keep tests independent let us rename the test data to ensure everything works as intended.
2018-02-09[MERGE] forward port branch 11.0 up to 20e4cd5bcd1Christophe Simonis
2018-01-22[MERGE] forward port branch 11.0 up to 950d9b23690Christophe Simonis
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.