summaryrefslogtreecommitdiff
path: root/addons/mass_mailing/models/mail_thread.py
AgeCommit message (Collapse)Author
2020-05-19[IMP] mass_mailing: propagate UTM on repliesSébastien Mottet (oms)
USE CASE Send a mailing to some recipients. Set reply-to of this mailing to an alias creating records on a model inheriting from utm.mixin. UTM informations on mailing are not propagated to the newly-created records. SPECIFICATIONS When an user answers to a mail of a mailing with an alias creating records on an UTM enabled model, propagate UTM from the mailing to the new record. In order to set UTM informations during record creation, "message_new" has been overridden in mass_mailing. That way it is automatically available on all models inheriting from utm.mixin. A test simulating this scenario has been added. It checks if UTMs info are correctlwy set on the created record by comparing them to the mailing's UTM info. Task Id 2210334 closes odoo/odoo#48602 Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-05-18[FIX] mass_mailing: correctly consider replies for tracesThibault Delavallée
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-01-09[FIX] mass_mailing: set bounced mail as bouncedNicolas Lempereur
Fix a mixup between `bounced_msg_id` that is sometimes tought as a list of string or directly as a string. Now `bounced_msg_id` is always a list or `False` if there is no bounce. opw-2157793 closes #43084 closes odoo/odoo#43091 X-original-commit: b0e0cee9f9623d972c4dee26d3536600dc95f276 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
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-08-21[IMP] mail: remove unnecessary decoratorsThibault Delavallée
Purpose of this commit is to lessen complexity of stack chain in mail main methods. Removing decorators is a good start for this. LINKS Task 1919267 PR #30597
2019-08-09[IMP] mail, mass_mailing : reset bounce on mail receptionDavid Beguin
PURPOSE Add some improvements in mail gateway: remove private discussion, improve bounce management, allow resetting bounce counters, improve automatic set or reset of blacklists and ease mass mailing inheritance. SPECIFICATIONS The number of message bounce is incremented each time the email bounce on a specific email address. To have a correct information, we should reset to zero this counter if we receive a mail from this address. Indeed, if we receive an email from an email address, this email is active and the message bounce number (if > 0) is not relevant anymore. Only models inheriting form blacklist are impacted by this improvement in order to limit a bit side effect. Also, add a check in autoblacklist rule. No need to check the stats if message_bounce is < 5. This commit introduces * ``_routing_reset_bounce`` routing method managing the bounce reset; * ``_message_reset_bounce`` model method that resets bounce counter in blacklist enabled models; LINKS Related to task ID : 1893155 Linked to PR #33340
2019-08-09[REF] mail: move and improve bounce management in mail gatewayDavid Beguin
PURPOSE Add some improvements in mail gateway: remove private discussion, improve bounce management, allow resetting bounce counters, improve automatic set or reset of blacklists and ease mass mailing inheritance. SPECIFICATIONS Purpose * move bounce information detection in message parsing. It allows to have this information available in various steps of routing instead of having to manually re-compute them; * handle bounce in specific methods allowing easy override; * improve bounce management, notably when detecting a bounce not linked to the bounce alias configuration; * better integration with blacklist mechanism; Specifications * compute bounce information in ``_message_parse_extract_bounce``.It parses bounce information and returns a dictionary allowing to update parsed email values; * remove override in mass_mailign that basically does what mail already does; * manage bounce in ``_routing_handle_bounce``; * when detecting a bounce, correctly call the bounce management method on all models inheriting from blacklist; * correctly update bounce counter; * bounced mailing traces and automatic blacklist in mass mailing should be done in ``_routing_handle_bounce``; * add some tests; LINKS Related to task 1893155 Linked to PR #33340
2019-07-17[REF] mass_mailing: rename mail.mail.statistics and reporting modelThibault Delavallée
PURPOSE Mass mailing is currently a bit messy. As SMS will be added as a way to notify people in mass through SMS let us take this opportunity to somehow clean this application: organization, light code cleaning, model renaming. SPECIFICATIONS Rename mail.mail.statistics to mailing.trace and mail.statistics.report to mail.trace.report. Rationale : * mail.mail.statistics is linked to mail.mail model. Soon this model will hold data related to SMS sending. It makes sense to be broader in the naming; * mailing.trace is more inlined with marketing.trace model that is the marketing automation model using it in marketing automation (enterprise application); * mailing.trace is shorter to write; * mail.statistics.report model should sense to be updated at the same time; MIGRATION mail.mail.statistics model -> mailing.trace mail_mail_statistics table -> mailing_trace mail.statistics.report model -> mail.trace.report fields updated (w column change) * link.tracker.click: mail_stat_id -> mailing_trace_id fields updated (no column change) * mail.mail: statistics_ids -> mailing_trace_ids * mail.mass_mailing: statistics_ids -> mailing_trace_ids LINKS Task ID 2037906 Preparing task ID 1997464 (SMS addition in mass mailing) PR #34938
2019-07-17[REM] *: calls to @api.multiAdrian Torres
Multi is the default api for methods, it is not necessary to explicitly decorate methods with it, adds clutter and most people use it because they see that the rest of the code uses it. Done with `find . -type f -name '*.py' | xargs sed -i '/@api.multi/d'`
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-13[REF] mail, various : make message_receive_bounce from mail.thread privateDavid Beguin
Purpose: make some methods from mail.thread mixin private and update their naming if necessary. Some methods prepare data for business flows and deal with internal information. Public methods should either use of give some access to those methods. Computation itself should be keps internal. In this commit we put message_receive_bounce as private. Future commit(s) will probably rewrite part of the bounce logic. Some addons are updated accordingly to the method change. Related to task ID 1911679 Linked to PR #29483
2018-10-05[FIX] mail, mass_mailing: remove implicit dependency on mass_mailinglen-odoo
Fix to commit: a1d6064dcc6d349c02556453e1aa052e60db41c0 Which erroneously put a mass_mailing method in mail, as mail.mail.statistics is defined in mass_mailing. Since it does not depend on the records, it been extracted from the loop. opw 1890461 closes odoo/odoo#27431
2018-08-14[MERGE] forward port branch saas-11.4 up to dabe59df9c8Christophe Simonis
2018-08-13[FIX] mass_mailing: bounced statisticsNicolas Martinelli
A mass mailing can be considered both as bounced and opened. This can occur with some email providers, such as Gmail. Indeed, Gmail sends out-of-office replies to the `Return-Path` address, which is also used for bounced emails. Therefore, it is not possible to determine accurately if a message sent to to the `Return-Path` is a genuine bounced email, or an out-of-office reply. However, if the recipient opens the email, it is possible to determine that the bounce was counted incorrectly. In this case, we empty the `bounced` field. Similarly, we only write on the `bounced` filed if the `opened` field is empty. This could occur if the recipient opens the email before the out-of-office reply is received. As a bonus, we also make sure to avoid updating the status if no route was found. No route means that the email was bounced, so no reason to set it as opened. opw-1869957
2018-08-10[IMP] mass_mailing : include invalid emails into ignored stateDavid Beguin
If the email is invalid (incorrect pattern), the mailing status is set to canceled and will be flaged as ignored in the mail.mail.statistics
2018-08-10[IMP] mail : auto-blacklist rule when too much email bouncedDavid Beguin
In order to avoid sending mail indefinitely to a wrong email address, Take the mail statistics for the recipient of the last 3 month : if more than 5 mails bounced (with interval of more than 1 week) the email is blacklisted.
2017-09-15[IMP] mass_mailing: consider replying to an email imply opening itThibault Delavallée
Currently when people answers an email its statistics are set to replied updating its replied field. However if the blank gif used to track the opening fails for whatever reason we could have mail considered as replies but not opened. We consider that it is not common to reply to an email people did not open. Let us therefore set a replied email as also opened.
2017-07-19[MERGE] forward port branch 10.0 up to 11270336fa7Christophe Simonis
2017-07-18[FIX] mass_mailing: avoid creating mass mailing for messages postsChristophe Simonis
In case a default value is set for the field `mass_mailing_name` of the mail composer, the automatic messages sent via message_post_with_* are considered as a mass mailing. It may also create an AccessError if the current user is not a mass mailing user. In the case of the "assign user" email (for auto-subscribed users), the url wasn't shorten, which resulted in invalid links (opw-752941) (fixed by 3228694bddff75a9c04504f09b6da56c5f5a5647)
2017-01-03[IMP] base, *: tighten `ir.config_parameter` access rightsRaphael Collet
Add `base.group_system` on existing parameters: - `auth_signup.allow_uninvited`, - `auth_signup.reset_password`, - `auth_signup.template_user_id`, - `google_redirect_uri`, - `mail.bounce.alias`, - `mail.catchall.alias`, - `mail.catchall.domain`.
2016-09-01[IMP] mail: bounce managementThibault Delavallée
Handle bounces using bounce alias directly in mailgateway. Previously bounces were used only in mass mailing to update campaign statistics. Now the mailgateway tries to find data from standard delivery status emails. This data is used to update state of emails sent to customers, to display it in the Chatter. It is also used to increment the message_bounce counter on the bounced partner and bounced record, if any and if the field exists. Previous more generic code that detect bounces is kept. This code is more specific to standard delivery failure notifications by parsing its content.
2016-09-01[FIX][IMP] mail, mass_mailing: improve making of Return-Path aliasThibault Delavallée
Previously Return-Path were composed using bounce_alias-<mail_id>-<model>- <thread_id> . However this may lead to return adresses not supported by the incoming mail server. We now form the bounce alias using bounce_alis+ <mail_id>-<model>-<thread_id>. Using a + indicates that the right part of the address is for information and used to manage the bounce. Only the left part is used for the email routing, allowing the return email to effectively land in the alias mailbox.
2016-09-01[CLEAN] mail, tools: factorize decode email toolsThibault Delavallée
mail.mail and mail.thread have methods to decode headers. This commit move them in mail tools. It is indeed simplier to have all email tools in the same file. Moreover they have been renamed to avoid confusion with standard library methods: decode and decode_header already exist. * decode in mail_message is now decode_smtp_header * decode_header in mail_thread is now decode_message_header A method to data from references is also moved into tools. A regex was already defined in tools. Now the method using it is already put in tools. Mailgateway will now simply call this method.
2016-08-09[MIG] mass_mailing: Remaining self.pool in 'message_route_check_bounce'Yannick Tivisse
2016-06-17[MIG] mass_mailing: code migration to new apiKeyur Gajjar
NB: A controller in website_mass_mailing has been migrated too. It's not a real issue as this module will also be migrated in the days to come
2015-10-26[MERGE] forward port of branch saas-6 up to ↵Denis Ledoux
20dba161d022f8c818f1ab4800b5631c75afc2a4
2015-10-06[FIX] mass_mailing: Check if bounce_alias is not NoneDanimar Ribeiro
If the parameter mail.bounce.alias is not found
2015-06-02[LEGAL] Use global LICENSE/COPYRIGHT files, remove boilerplate textOlivier Dony
- Preserved explicit 3rd-party copyright notices - Explicit boilerplate should not be necessary - copyright law applies automatically in all countries thanks to Berne Convention + WTO rules, and a reference to the applicable license is clear enough.
2015-04-27[MOV] mail: moved files according to the new module organizationThibault Delavallée
2014-11-04[IMP] use model._fields instead of model._all_columns to cover all fieldsRaphael Collet
The old-api model._all_columns contains information about model._columns and inherited columns. This dictionary is missing new-api computed non-stored fields, and the new field objects provide a more readable api... This commit contains the following changes: - adapt several methods of BaseModel to use fields instead of columns and _all_columns - copy all semantic-free attributes of related fields from their source - add attribute 'group_operator' on integer and float fields - base, base_action_rule, crm, edi, hr, mail, mass_mailing, pad, payment_acquirer, share, website, website_crm, website_mail: simply use _fields instead of _all_columns - base, decimal_precision, website: adapt qweb rendering methods to use fields instead of columns
2014-08-11[FIX] mail: fixed bounce email recognition + invite email headers + mass ↵Thibault Delavallée
mailing statistics not lost anymore - [FIX] bounce regex: too many emails were considered as bounce and therefore not displayed in the chatter and lost for the communication history. The regex was not correctly looking for the bounce alias in the email_to. - [FIX] invite email: replying to the invitation email (invitation as new follower) now replies to the user sending the invitation. - [FIX] mass_mailing: added a column to store the id of the original email in addition to the many2one column. The many2one is set to null when deleting the original email. As the information is necessary, it is saved on another field. The many2one is necessary for indexes purpose as the inverse of a one2many.
2014-04-16[MERGE] Sync with trunkThibault Delavallée
bzr revid: tde@openerp.com-20140416082925-eph1x8vnwj6o31rt
2014-03-17[REF] mass_mailing: moved files in models/data/views directories.Thibault Delavallée
bzr revid: tde@openerp.com-20140317143231-4jp3egoqvolenwxs