Commit Graph
15 Commits
Author SHA1 Message Date
Thibault Delavallée cd69ea8f9a [REM] crm, project: remove support of mail-based record update
Currently crm and project parse incoming email body following an old
syntax to find some "set field - value" lines in the email content. It is
used to update the record linked to the discussion directly from the email.

However this feature is undocumented and not really supported anymore.
Moreover we don't think being able to update records from emails is a
reliable way of working. Moreover those update is limited to

 * revenue and probably for leads; this should totally be managed from
   the pipeline view by lead / opportunity responsible;
 * priority update coming from a "priority" entry in the incoming email;
   this code seems strange as priority is probably not standard in email
   headers;
 * planned hours for project; this should be managed by project user
   and managers through dedicated views in Odoo;

Let us remove that old feature and let people use desktop or mobile
interface to update their records.
2018-03-16 11:00:35 +01:00
Adrian Torres 2f0435f081 [FIX] tools: bad regex in mail.py
Before this commit, if comments were found inside the body of a mail
template sent through mass_mailing, the regex in append_content_to_html
that converts possible uppercase tags to lowercase tags would replace
comments by broken html elements, this would break the in-browser parser
and thus would show partial content or no content at all, depending on
the positioning of the comments.

i.e. from <!-- This is a comment --> to <this -->

The regex in question is r'(</?)\W*(\w+)([ >])' which basically matches
opening and closing tags (this was a bad idea from the beginning btw),
the \W* will match any non-alphanumeric chars (so !-- in the
case of comments) and this would be completely discarded since it's not
a match group and when replacing we only use match groups.

This is fixed by simply stripping the \W* since it's discarded anyway,
an alternative fix would be to put it in a match group and add it when
replacing as well, but I don't know if we purposefully discard it or
not.

Neither fix is the good one, the good fix is to replace all the re.subs
by lxml which is much easier and more concise.
2017-10-27 13:32:15 +02:00
Olivier Dony 695716efb0 [FIX] P3: remove pycompat.{keys,items,values} helpers
Now that we're closer to switching to P3 for good, these helpers have
outlived their usefulness, and mostly add noise.

All remaining dict.iter*() or dict.view*() must be converted to the
normal keys(), values() or items() calls.

Whenever the result is likely to be used for more than the scope of a
loop, or when the dict needs to be modified during iteration, the calls
must be wrapped in a ``list()``, to protect the new P3 semantics.
Those cases are very exceptional.

Also removed some dead code or improved the API to remove unnecessary
conversions.
2017-08-20 23:25:54 +02:00
Xavier Morel 200612ca1e [FIX] P3: text model in various mail bits
No formal decision there, and the stdlib API seems like a PITA as it's
based around native strings, not bytes and not text.

* try to use cross-model API instead of random encode/decode
* unicode all the mail_template things
* formataddr *requires* a text tuple now

  In P2, formataddr((False, False)) "worked" (generated "False
  <False>"), in P3 it will fail and blow up.
* attachments are quite definitely bytes
* remove try_coerce_ascii because it's garbage
2017-08-20 23:25:54 +02:00
Xavier Morel 1328416959 [FIX] P3: hash randomisation in XML/HTML stuff
* Have the cleaned up style attributes be dumped in the same order
  they were originally so that we can easily validate against text
  content.
* While lxml's attributes are stored in an ordereddict, namespaces are
  not and thus when comparing text serialisation of namespaced
  documents the ordering of namespaces can differ between runs.

  Fix by comparing the LXML trees directly.
2017-06-12 11:04:23 +02:00
Xavier Morel b897dcde15 [FIX] P3: import pattern which doesn't seem to work right
``import odoo.addons.foo as bar`` doesn't seem to properly trigger the
import hook in Python 3 (it blows up on decimal_precision and
base). Thus convert *all* examples of that pattern to the more
sensible ``from odoo.addons import foo as bar``.
2017-05-22 13:30:50 +02:00
Xavier Morel e2f1af78c4 [FIX] P3: remove cgi.escape uses
cgi.escape is unsafe (quote=False by default) and deprecated in Python
3. We already have an openerp.tools.misc.html_escape version which
forwards to the (modern and safe) werkzeug.utils.escape, just use that
everywhere, and convert extant uses of werkzeug.utils.escape to
utils.html_escape as well so that we do the same thing everywhere.
2017-05-15 12:26:31 +02:00
xmo-odoo fffaf735f5 [FIX] P3: list -> iterable builtins (#16811)
In Python 3:

* various builtins and dict methods were changed to return
  view/iterable objects rather than lists
* and the separate Python 2 view/iterable builtins and methods were
  removed altogether

This is problematic when using these items as list (which the happens
repeatedly in Odoo), but more viciously when iterating *multiple times*
over them (which also happens, which I've messed up multiple times while
writing this, and which is a pain to debug even when you've just created
the issue).

Convert all code using these to semantics-matching cross-version
helper functions to get the LCD behaviour between P2 and P3, and
forbid the builtins via lint.

issue #8530
2017-05-10 09:39:55 +02:00
Xavier Morel 3979f6802e [#8530] convert exception handlers to except..as syntax
Futurize fixers:
* lib2to3.fixes.fix_except
2017-04-11 14:53:29 +02:00
Olivier Dony 2d3a4a5d0c [FIX] tools: generate message IDs with unique prefix
For the purpose of fighting spam, many abuse/spam-fighting
services provide redacted message IDs. Because we use a UNIX
timestamp as the prefix for all message IDs, a redacted
message ID of the form 1234XXXXX@domain.com is generally
useless to find a `flagged` message's origin, because it
matches most of the messages sent that day.

Narrowing it down with the help of the approximate time
of delivery does not help much, as there will still be
dozens/hundreds of possible matches on a busy server.

By swapping around the random token and the timestamp in
the message ID, we should improve the uniqueness and
"greppability" of our message IDs, once redacted.
2017-03-07 19:53:06 +01:00
Olivier Dony a7ff8364ea [FIX] mail sanitize: allow extra common style attributes
Without allowing these harmless style attributes, sending
mass mailing emails with the new snippets produced an ugly
dumbed-down version.
2017-03-07 16:04:33 +01:00
Nicolas Lempereur b51d21c5b8 [FIX] tools: nbsp+sanitize = write
lxml.html.clean module we are using to sanitize html takes either a
tree/element or string, and return us an element of the same type.

We are passing it an unicode string, and it gives us back an unicode
string and if it is possible convert entities to utf-8.

This lead to an issue in html inline fields containing an `&nbsp;`
entity, the entity was converted by the sanitizer to its unicode
character (U+00A0).

Then, when the field value is loaded to be displayed, the internal
value contains U+00A0 characters, but when it is inserted in the page
the browser converts them to `&nbsp;`. Hence in this instance, the
internal value is never equal to the displayed value and a write is
always triggered even without editing.

This commit simple modify the sanitizer so value saved in database
contain `&nbsp;`.

closes #14569
opw-689274
2016-12-06 18:54:46 +01:00
Christophe Simonis 7d4ac39c4c [MERGE] forward port branch saas-12 up to d853d3c 2016-11-24 18:35:42 +01:00
Raphael Collet 4a700d0ad9 [FIX] odoo: rename imports and adapt import hooks 2016-09-02 17:28:12 +02:00
Raphael Collet 9e64f9f951 [REF] openerp: move openerp to odoo 2016-09-02 17:28:12 +02:00