Daily updates from Odoo
Thursday, September 19, 2019
3 changes
Code cleanup and technical improvements
Odoo's mail-related features now use Python's newer email tools, reducing reliance on older components that are being phased out. This helps keep outgoing messages, mailing features, surveys, and related tests compatible with future Python versions without changing the expected user experience.
Original PR description
PEP 594 is depreciating some modules from the python standard library. Among them `email.message.Message` old email API and related modules, `imp` old import logic and the not commonly used `cgitb`…
PEP 594 is depreciating some modules from the python standard library. Among them `email.message.Message` old email API and related modules, `imp` old import logic and the not commonly used `cgitb` exception pretty printer. The legacy `email.message.Message` API has been replaced by `email.message.EmailMessage` API, the later supports automatic header value conversion out of the box which simplify how emails are generated. The `email.utils.formataddr` function is commonly used accros the code base to generate `John Doe <johndoe@example.com>` like strings. As the function has been depreciated too, it has been re-implemented but only to support utf-8 and base64 (other mail supported encoding are not used within the codebase). The `imp` module is used twice, first time to locate and load addons, the second to import handmade modules. The first has been replaced by `importlib.machinery.PathFinder`, the second by `types.ModuleName`. The `cgitb` is only used in order to ease the debugging in internal tools related to the documentation, as their are still in use, the module has been packaged as part of our codebase.
This change updates Odoo's documentation tooling to stop using an outdated Python component that is being removed in newer Python versions. It helps keep the documentation build process compatible with future Python releases without affecting business features or users.
Original PR description
[PEP 594] is going deprecates the `imp` standard modules in PY3.8 in order to completely remove them in PY3.10. The `imp` module provides the `new_module` function. It returns a new module created solely using its name. The `types.ModuleName` is a drop-in replacement. Task: 2003936 [PEP 594]: https://www.python.org/dev/peps/pep-0594/\#imp Was #35929
This update replaces a deprecated email formatting method used when sending appraisal, referral, and signature-related emails. It helps keep these workflows compatible with newer Python standards without changing the business process for users.
Original PR description
[REF] mail: remove deprecated email formataddr [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 function has been re-implemented by Odoo/Odoo#a5ea588e to support the character encoding and binary-to-text encoding used by Odoo. See https://github.com/odoo/odoo/pull/35929