Commit Graph
49 Commits
Author SHA1 Message Date
Pierre-Yves Dufays c069cf75c7 [IMP] hr,{test_}mail{_group}: warn user when alias model creation fails
Warn user and alias responsible when model creation fails on incoming
message due to alias mis-configuration.

Alias custom default values that references archived or deleted records can
prevent the record to be created when receiving an email.
Unfortunately, correcting values on the fly has too many downsides:
- as the value cannot come from nowhere, we would probably end up with
corrupted record like a task without a project
- as errors are silent, lots of suboptimal record could be created before it
is corrected
- as the code would have to deal with different kind of updates, it would be
heavily depend on the framework meaning additional maintenance cost
- the attempt made had also a performance cost by using savepoint which we
want to avoid

For all those reasons, we have decided to warm the user rather than trying to
solve the problem automatically.
The users are warned:
- through a bounce email sent to the sender and alias responsible
- in the alias interface through an alias status present in the list and the
form view

Technical notes:
- They are multiple kind of errors: error in the message (ex.: user not
authorized to send to a specific alias), error in the alias (ex.: dangling
reference in alias_defaults), other error (ex: technical error like a
service unavailable when receiving the message). Here, we want only to detect
alias error and skip other errors. So rather than doing a big try except around
_message_route_process, we have selected the spot where we should detect alias
error:
-- in _alias_get_error_message where we distinct a message error from an alias
error
-- in inside _message_route_process where record are created using
alias_defaults (custom values with reference to record that might have been
deleted since the alias creation)
- In test, we call mail.thread message_process with sudo as it is the case in
real use case (processed when fetching mail). It is needed as in some test
alias status are modified.

Task-2675209

closes odoo/odoo#101019

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-12-06 09:25:50 +01:00
Gorash 880954ebfc [IMP] *: remove _render from ir.ui.view and simplify report
There were inconsistencies in the calls to `_render`.
* the view context could contain information that misled developers.
Indeed, the context and value of the view are not supposed to be found
in the rendering. Thus by calling `ir.qweb` with the name of the
template, we ensure that there is no unwanted information and in
addition the cache key is that of the name of the template which saves
a query.
* the context used for rendering was modified by a method on
`ir.ui.view`, except this is not information used by this model. There
is now a `_prepare_environment` method residing on `ir.qweb`. This
method allows to modify the value dictionary as well as the context in
which the rendering will be done. This preparation of the data as well
as my security check is done only once per rendering. This also saves
some queries
* Freeze options for rendering were inconsistent. It could be that
options on which rendering depends were not part of the cache key. Thus,
depending on the user who generated the generation of the rendering
function, there was or was not information in the template. For example
for automatic branding. This is no longer possible, because it is the
context that is used. The options serving as a cache key are only
recorded for information (for the profiling system for example). A
simplification of the `ir.qweb.field` models could be made.

The report rendering and call `ir.qweb` instead of `ir.ui.view`.

Part-of: odoo/odoo#85110
2022-03-29 10:56:15 +02:00
William Braeckman 13084f0faa [FIX] account,mail: fix no depends not computing field
Computed fields with no depends are not computed before record creation
rendering those fields empty instead of being computed on the first
request.
By adding a depends (the field does not actually depend on it) the field
is computed correctly and may be used directly.

TaskId-2647225

closes odoo/odoo#76744

X-original-commit: f03e74317a40957a355235b92dacff6310fbdd5b
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-09-17 18:52:49 +00:00
Thibault DelavalléeandVictor Feyens e87b46864c [IMP] mail(_*): improve compute in batch and remove unnecessary defaults
Purpose of this commit is to clean field definitions by

  * doing compute in batch: especially when the loop can be reduced to a single
    computation / batch assignment (based on groups or config parameter for
    example);
  * remove default when having a compute as computes should completely define
    the field value at any time;

Some side dish code cleaning is performed at the same time: unnecessary
import or dead code removal.

Task-2638444
PR odoo/odoo#76005

Co-Authored-By: Thibault Delavallée <tde@odoo.com>
Co-Authored-By: Victor Feyens <vfe@odoo.com>
2021-09-08 07:56:02 +00:00
Thibault Delavallée 76616dc888 [IMP] mail: improve default bounce message
Current bounce message is not very user friendly. Purpose of this commit
is to improve it, by improving wording and overall phrasing used in it.

Form view is improved so that bounce message takes all available width in
form view.

Some tests are added, notably to detect pseudo-void content from editor.

Task ID-2532529
PR odoo/odoo#71793

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-07-07 06:29:01 +00:00
Thibault Delavallée c47b0054b8 [FIX] mail, hr, test_mail: correctly Markup-ize bounce notification email content
It is currently escaped as it is not Markup-ed and not considered safe.
It means raw content is currently displayed in sent emails, which is not
really what we expect.

closes odoo/odoo#71911

X-original-commit: 62e6bc216aefe93c4cd1cca8e39f124a8a298386
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-06-09 11:43:11 +00:00
Julien Castiaux e08ee893d1 [FIX] mail: sanitize dots in generated mail alias
Create a company whoose name ends with a dot like "Bidule Inc.", change
the company of the user to that new company, head to the Accouning
module and create a new journal of type purchase. Traceback because the
generated mail alias for that journal uses the company name and that the
local-part of an email cannot ends with a dot.

From the RFC standpoint, the local-part of an email address (the part
before the @, `john` in `"John Doe" <john@example.com>`, cannot begins
with, ends with or contain following dots.

The email sanitizing function have been updated so it takes care of the
above requirement.

See also #61811
opw-2448692

closes odoo/odoo#69864

X-original-commit: f0e840ae6db387e1dfc99cc21e09d84eb126e7b9
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2021-04-26 16:31:19 +00:00
Dharmraj Jhala ebc49bc143 [FIX] {test_}mail: set bounced alias in bounce autoreply
Before this commit

When someone tries to send a mail to a restricted alias (which can be
anywhere in 'To', 'CC' or 'BCC') and if the sender is not allowed to do
so, the mail bounces. However bounced mail shows info as if it bounced due
to address provided in 'To', even though it is not always the case.

Example you send a message to

  * 'To': 'valid@gmail.com' (okay)
  * 'Cc': 'myalias@odoo.com' (not allowed for you)

Mail bounces because you are not allowed to send a mail to alias provided
in 'Cc', but it shows the message that: `The following email sent to
valid@gmail.com cannot be accepted because [...]`.

After this commit

Boucing alias is shown in message body. Above example becomes `The following
email sent to myalias@odoo.com cannot be accepted [...].`

Note: Because the alias can be present in `Bcc` too (which will not available
in the message values we get in `message_route_verify` method), we simply use
display name of the alias instead of finding mail address matching with alias
from the message values.

Task ID-2390310

closes odoo/odoo#69788

X-original-commit: 15325b19c15a649041db75bacbe8409ae4c58df7
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-23 16:29:59 +00:00
Lavish Chhatwani e145f737f5 [IMP] mail: display proper warning message if alias already exists
Currently, when new alias with an already used prefix is created, it shows the
warning stating "The e-mail alias is already used. Please enter another one."
It does not help much because the user do not know where the alias is used.

This commit improves the warning message by including the document name and
parent model name (if available) if the alias is linked to any model, or it
shows if alias is already used for handling bounce/catchall if that is the
case.

Task Id-2375552

closes odoo/odoo#62367

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-02-02 16:40:33 +00:00
Victor Feyens 18b49836b7 [REF] mail: make alias creation work in batch
In this commit we rewrite part of alias name uniqueness check as well as
alias mixin alias creation to enable batch create of

  * alias records (mail.alias);
  * records using aliases through mail.alias.mixin;

See merge commit for more details.

Task ID-2330149
COM PR odoo/odoo#61246
ENT PR odoo/enterprise#14561
2020-12-03 10:18:50 +00:00
Victor Feyens 8d32f8724e [FIX] *: adapt python constraints to support multi recordsets
Otherwise, they may crash or be incorrectly verified when
creating/updating recordsets containing multiple records.

Also improve the constraint error messages to be more detailed.

When possible, use a sql constraint instead to speed up the records
validation.

Task Id: 2328664
COM PR: https://github.com/odoo/odoo/pull/55525
ENT PR: https://github.com/odoo/enterprise/pull/12250
2020-11-20 10:04:27 +00:00
Julien CastiauxandThong Le 33bd1a951a [FIX] account,mail: default purchase mail alias non-ascii
* Change the `addons/account/i18n/vi.po` PO file to replace the
translation of `Vendor Bill` like msgids from `Công nợ nhà cung cấp`
to ` by `Hóa đơn Nhà cung cấp`, there should be 3. What's matter is
the `đ` character.
* Create a brand new Vietnamese database (using `-l vi_VN` and
`--load-language=vi_VN`)
* Install Invoicing (`account`), an email alias constraint is raised.

> You cannot use anything else than unaccented latin characters in the
> alias address.

During the installation of the invoicing module, an email alias is
created for every journal account of purchase type. The alias is created
using the current journal name. Here the journal name is `Hóa đơn Nhà
cung cấp`, as mail aliases should only contain ascii characters, we
attempt to remove the accents. The `tools.misc.remove_accents`
successfully remove most of them but the `đ` character is left as-is,
the final alias is `hoa-đon-nha-cung-cap` which is invalid as it
contains some non-ascii characters.

The `remove_accents` function uses the [NFKD] Unicode Compatibility
Decomposition Normalization Form. This normalization process unify all
abstract equivalent characters, i.e. characters only different by font
or rotation. While this normalization process helps to transcript a lot
of characters to their ascii compatibility equivalent, some 118,230
other non-ascii characters (mainly from the Chinese and Japanese scripts)
are left as-is as they lack an ascii compatibility equivalent.

The solution has been to not use the journal name but rather the journal
code or journal type as email alias when the name is unsafe. The journal
code is a short version of the name, the journal type is not
translatable so is always ascii.

One additional watchdog has been added to the sanitization function of
email aliases so non-ascii characters are replaced with a '?' which is
an authorized character in emails local-part.

[NFKD] https://unicode.org/reports/tr15/

Closes #55492
Closes #55493

closes odoo/odoo#58279

X-original-commit: 8dc85be3821cf26226cd0bf4ce2b6739e68fc66f
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
Co-authored-by: Thong Le <thongthele@users.no-reply.github.com>
2020-09-22 19:21:08 +00:00
Julien Castiaux f1215389e8 [FIX] mail: prevent international char in alias
Create a mail alias with non-ascii characters like 'foß', send an
email from your personal email account to that alias. The delivery fails
because Odoo SA servers don't support the SMTPUTF8 extension which is
required to parse the local-part ("display" <local-part@domain>) part of
a From header.

While external providers may create international, very weird, emails
and we should support receiving/sending emails from/to them. Our policy
is to only create very basic email addresses. That is all ASCII,
letters, digits and a limited set of punctuation characters.

Restricting what aliases can be created, we ensure no advanced extension
should be enabled on SMTP servers.

opw-2293336
Closes #53403

closes odoo/odoo#55166

X-original-commit: 4db3f21f52fa774ec651fc0b6eaa9a8652b2ae4c
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2020-07-29 23:44:47 +00:00
Martin Trigaux 400cc4f14e [FIX] *: correct all or improve code translation lookup
This commit fixes all issues detected by the new pylint
gettext-variable test.
It converts some calls to the new syntax
  _("Foo %s", bar)

to progressively migrate the code to the new syntax.

A few calls were not technically incorrect but still detected by the
linter.

  _("Foo" +
    "Bar")

has been converted to

  _("Foo"
    "Bar")

as it has the same effect and make sure the argument is of type
asteroid.Const instead of BinOp).

closes odoo/odoo#53683

Related: odoo/enterprise#11467
Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
2020-06-30 10:19:59 +00:00
Martin Trigaux d9287caf94 [IMP] *: convert to private methods
render, render_template, load, activity_schedule_with_view,
get_website_pages should all be private:
It should not be possible to render an aribtrary template only with
its name or id

Still need to render some qweb views from js so the method
render_template is kept public.
This explains why the website editor still need read access on
ir.ui.view as we want to allow any snippet to be rendered.
2020-05-14 13:59:10 +02:00
ryv-odooandThibault Delavallée 186cfb5ebd [REF] mail: make alias mixin multi-enabled
Purpose of this commit is to allow multi-create in alias mixin by correctly
creating / updating aliases in batch.

Task ID 1919277
Community PR odoo/odoo#41160
Enterprise PR odoo/enterprise#6983
Upgrade PR odoo/upgrade#872

Co-Authored-By: Rémy Voet <ryv@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2020-04-17 06:52:09 +00:00
Thibault DelavalléeandRémy Voet 7cfd364db5 [REF] mail, various: clean usage of mail alias
Clean the usage of mail aliases and more specifically its associated mixin
`mail.alias.mixin` .

Stop using context for model of aliases, and correctly give model_id and
parent_model_id to the call chain through a cleaned code easier to override.

We also merge methods get_alias_model_name and get_alias_values in single one
called before record creation (alias first values) and right after (to have
values depending on actual record).

LINKS

Task ID 1919277
Community PR odoo/odoo#41160
Enterprise PR odoo/enterprise#6983
Upgrade PR odoo/upgrade#872

Co-Authored-By: Rémy Voet <ryv@odoo.com>
Co-Authored-By: Thibault Delavallée <tde@odoo.com>
2020-04-17 06:51:46 +00:00
Thibault Delavallée 0abe4437dc [MOV] mail: split alias model from its mixin
Purpose is to ease module understanding.

Task ID 2160070
2020-03-30 12:50:26 +00:00
Siddarth Gajjar a1b01751b5 [IMP] mail: prevent from re-using aliases
PURPOSE

Make aliases usage more unique, prevent re-using bounce or catchall aliases
and remove auto-uniqueness of aliases.

SPECIFICATIONS

Before this commit, user could create an email alias having same name as
catchall/bounce email alias, which should not happen. Also, while creating
or duplicating alias, if the same name was already available, a new unique
name was generated by adding a sequence number to existing name.

This behavior is not considered as a good one as it magically creates aliases
different from what user expects. User could even not own the newly-created
alias, leading to a broken mail gateway.

In this commit we improve that behavior by ensuring that no duplicate alias
name should be entered while creation / updation for both catcall/bounce and
mail alias. Also, while duplicating an alias, name will now be blank by default
to force user to enter the name. Finally when creating an alias an error is
raised if the name is already taken.

Task ID 2160070
2020-03-30 12:50:26 +00:00
Rémy Voet (ryv) c5e6511e8d [IMP] mail: ease bounce email content update based on alias security
PURPOSE

When incoming emails bounce due to alias security bounce email is quite
generic. Purpose of this task is to ease its customization and update.

SPECIFICATIONS

In order to improve the flexibility of alias, add a customizable html field
on the alias model. This html content will be send as bounce email core content
in case of bounced/unauthorized mail received for this alias,

Obviously it has no effect on 'everyone' security setting as no email will
bounce due to that issue.

If it is not set a default generic mail will be send depending on security
setting. It allows to keep void html fields when no specific bounce content
is required

In HR, an old template allowing some light customization for employee based
security option is removed as it is completely replaced by the new feature.

Also add references message-id of the mail received to the answer so that
threads are correctly set.

LINKS

Task ID 2126509
2020-03-12 13:54:32 +00:00
Martin Trigaux a74a648030 [IMP] *: use ast.literal_eval
When simply need to parse a domain, it is easier

Add .strip() on ir.ui.view as ast.literal_eval produces an syntax
error if the node starts with spaces (as done in the xpath of
hr_attendance.view_employee_form_inherit_hr_attendance)

closes odoo/odoo#43831

Related: odoo/enterprise#7894
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-01-28 13:58:05 +00:00
Christophe Simonis 58a83d1222 [MERGE] forward port branch saas-12.4 up to 4a1321bc99
closes odoo/odoo#37127

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-20 14:33:54 +00:00
Jairo Llopis 5dad570423 [FIX] *: remove buggy calls to with_context
When .with_context() is called with a dictionary as 1st positional
argument, it will replace context (and not modify the referenced keys)
It may create bugs when losing the content of the context (e.g. remove
partner's language)

This is a partial merge of #36164 without the inventory part as
discussed.

closes odoo/odoo#36729

X-forward: 4717ccfa
Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-09-12 06:18:18 +00:00
Naglis Jonaitis 7417d8fc13 [IMP] *: fix typos in field definitions
* account, crm, hr, im_livechat, l10n_ch, l10n_it_edi, mail,
mass_mailing, project, stock, base

- `String` -> `string`;
- `defaut` -> `default`;
- `defaults` -> `default`;
- `reandonly` -> `readonly`;
- removed redundant `placeholder` attribute for `Char` field;
- removed redundant `size` attribute for `Float` and `Integer` fields;
- changed to use `Selection` instead of `Char` for a field having a
defined `selection`.

closes odoo/odoo#35356

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-31 17:14:19 +00:00
Adrian Torres 4b38cc6590 [REM] *: calls to @api.multi
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-07-17 14:13:12 +02:00
Raphael Collet c552fb7a61 [IMP] api: remove deprecated decorators 2019-07-08 13:51:35 +00:00
Adrian Torres 9e71d57d11 [REM] *: remove calls to api.one and adapt code
Adapt all code that was using `api.one` to recordset-style method and
remove any and all calls to `api.one` in preparation for its removal.
2019-07-05 09:04:45 +00:00
Hiral Bhavsar 3cd7ed07a2 [IMP] *: remove 'view_type' on window actions.
The old tree views don't really exist anymore, this odd pseudo-flag to
dispatch between "list" and "tree" tree views has no reason to remain.

Task 1937686

closes odoo/odoo#31243

Signed-off-by: Xavier Morel (xmo) <xmo@odoo.com>
2019-06-17 11:34:17 +00:00
Nimesh Jethva dae97ee5f0 [IMP]mail_*: Improvement in model description
Purpose of this commit is to give description more "business oriented"
because those descriptions appears in Odoo Studio which is supposed to be used by end users, not only by developers.

Related Task ID : 37311
2018-09-21 11:45:15 +02:00
Thibault Delavallée cdfe479e2e [MOV] mail: reorder a bit mail thread methods by category
As this class has grown a lot some methods have been put a bit anywhere
in the file. To prepare future improvements it is easier to regroup
them a bit.

remove_accent from mail_alias is also moved to tools in order to separate
tools from business or class specific code.
2018-01-11 11:52:37 +01:00
Thibault Delavallée 20d8025036 [FIX] mail: followers alias check on models not inheriting from alias mixin
You could try to check followers on a model not inheriting from mail alias
mixin. In that case current code would check followers on a void mail
alias mixin record, meaning no followers found. Instead we now
differentiate the class method from the method checking record properties.
2017-11-08 12:51:13 +01:00
Thibault Delavallée d6a5c126e7 [FIX] mail: correctly return and log error message when checking aliases
Mesage should be message otherwise it is not displayed in the logs.
2017-11-08 12:47:12 +01:00
Martin Trigaux 2382520c34 [IMP] odoofication 2017-03-30 08:59:13 +02:00
Thibault Delavallée 78ac6de52d [IMP] mail: factorize code that handles alias security in mail gateway
Currently check of alias security is directly embedded in mail.thread
routing method. In this commit we move this check in the mail.alias.mixin
class itself. Doing this allows models to extend or improve the behavior
depending on how inheriting models use aliases.
2017-03-23 13:11:34 +01:00
Raphael Collet b3c97f08bb [FIX] mail: when initializing aliases, force reflection of models 2017-02-22 15:24:06 +01:00
Raphael Collet 5d746d0ac6 [IMP] base, *: tighten ir.model access rights
Remove unrestricted "read" access.  To make code internally using `ir.model`
work, add a private method `_get` on `ir.model` to retrieve the record
corresponding to a model name, without access rights issue.

Change signature of method `get_authorized_fields` to make it use a model name
instead of a model id.  This removes the necessity of a search on `ir.model`.
2017-01-03 16:52:49 +01:00
Raphael Collet 7543afb070 [IMP] base, *: tighten ir.config_parameter access rights
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`.
2017-01-03 16:52:49 +01:00
Raphael Collet bf668b64c1 [IMP] all: clean usage of safe_eval
Specifically: do not import `safe_eval` as `eval`, keep it explicit instead.
2016-08-11 15:36:56 +02:00
Thibault Delavallée c8a313d51e [IMP] various: use odoo for imports instead of openerp and update class names 2016-08-10 15:48:07 +02:00
Yannick Tivisse 4e65848e2a [MIG] mail: Migrate remaining '_init_column' method 2016-08-09 10:29:06 +02:00
Kinjal Mehta 1409de5d36 [IMP] Convert UserError into ValidationError when only a message to display
When only a message argument is given to the crash manager, the popup display
"Error while validating constarint" and "None" with the warning message
which does not make any sense for the common user.
2016-03-30 09:17:42 +02:00
Raphael Collet 3192693a23 [IMP] mail: remove method migrate_to_alias in favor of mail alias mixin 2016-01-08 16:22:05 +01:00
Raphael Collet 7bada82ce3 [IMP] mail: create a mixin class for models _inheritsing mail.alias 2016-01-08 16:22:05 +01:00
Thibault Delavallée f7c0480dc1 [FIX] mail: fix 504227cca9
Do not restrict followers-based alias to members of non public channels.
Otherwise you may have issues defining a public mailing list with a
subscription step. People still wouldn't be able to post on a public
channel using a restricted alias.
2015-12-09 09:59:04 +01:00
Thibault Delavallée 504227cca9 [FIX] mail: followers restricted alias
Now that channels can follow documents, restricted aliases are a bit too
restricted. We consider that followers-based aliases accept emails from
the direct followers (message_partner_ids) or member of non public
channels (message_channel_ids, filetered public field). This way we avoid
having public channels added by mistake, leading to information leak.
2015-12-08 16:33:49 +01:00
Martin Trigaux 087f8bed48 [FIX] correct some English mistakes
Missing spaces, typos, rephrase unclear text
Courtesy of Eric Geens
2015-09-10 12:22:17 +02:00
Thibault Delavallée 744d7e2331 [FIX] mail: alias: default value for alias_domain
otherwise it is not correctly computed on new records inheriting
from mail.alias class.
2015-07-30 10:19:14 +02:00
Christophe Simonis fe2b5f35a4 [MERGE] forward port of branch saas-6 up to bf1e999 2015-05-28 14:27:38 +02:00
Thibault Delavallée 4a975f1b7d [MOV] mail: moved files according to the new module organization 2015-04-27 12:52:45 +02:00