Commit Graph
71 Commits
Author SHA1 Message Date
Renaud Thiry 8d99f2f415 [MOV] test_website, web_editor: move test to right module
Some web_editor test was in "test_website" when it could
have simply been in web_editor.

It is moved there and modified to reuse existing imports and pass standard
web linting rules.

task-3741858

closes odoo/odoo#155704

Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2024-03-29 09:12:17 +00:00
Renaud Thiry 5c7e377f77 [FIX] mail, web_editor: add attachment at file upload
When using the `/image` command in the composer, or otherwise uploading a file
the editor should add the attachment to the composer if it is the current model

During a change in js relational models [1] the code was not adapted properly.
This lead to a traceback when using the command inside the composer.

[1]: 218ad8456a

task-3741858

Part-of: odoo/odoo#155704
2024-03-29 09:12:17 +00:00
Renaud Thiry 00ebf747af [FIX] mail: add selection when fetching message type
A new message type was added in stable. This is usually safe,
however in cases where there are related fields on that same selection
fetching them will raise an exception as the ORM has to fetch the translations
for the selection in DB.

We add a hack on mail.mail to update the selections in DB when fetching
the message_type field for the first time.

task-3773301

closes odoo/odoo#156235

X-original-commit: 19683173708a2b029acb4e744871772b6c248715
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-03-05 14:22:19 +00:00
Renaud Thiry 16102407f3 [FIX] mail: let auto_subscribe use up-to-date values
`_message_auto_subscribe` relies on `_get_subscription_data` to know who
is subscribed to what. This method uses a raw SQL query but doesn't flush
the relevant records beforehand.

This is not an issue in most normal cases, but if followers are edited manually
for example in order to merge existing records. It may cause issues when
assigning a user to the record after merging, as the this will attempt to add
them to the list of followers automatically, when they already were on it.

task-3713472
original issue in opw-3634410

closes odoo/odoo#155139

X-original-commit: d1b0e46f7d3034c400ba3c60f343c21c68aa011e
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-03-04 08:11:55 +00:00
Renaud Thiry ffda905ba7 [FIX] mail: consider empty "section" nodes to be empty html
Currently an empty section is not considered empty text.

As the web editor sometimes uses them, it is relevant to consider
them when asking whether some html will appear empty.

Currently, even completely removing the website description of an
exhibitor in website_event_exhibitor from the backend does not make
the 'missing description' tooltip appear in the front-end

task-3607615

closes odoo/odoo#154097

X-original-commit: 7dc376d4d2d2b4000de0da7573c30e4508f32318
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-02-15 07:54:50 +00:00
Renaud Thiry 75ba9e6bfa [FIX] website_event: set utm values for event registrations
The utm parameters i.e. utm_source, utm_campaign, utm_medium, are only set
when a sale order is attached to an event registration. If no sale order is
generated the event registration won't have any source despite it being
accessed via a campaign.

Reproduction steps:
1. Create an event and copy its website link.
2. Go to link tracker and create a tracked link with utm values filled.
3. Use this tracked link in incognito preferably to register for the event.
4. Check the attendees of the event and check the marketing utm values.

The registration has no campaign. When it should have one.

This is because event.registration mistakenly does not inherit from
the utm mixin. The fix is to call the default_get of the mixin
as it is independant from any field defined in the mixin.

OPW-3222179
task-3458877

closes odoo/odoo#151047

X-original-commit: 06803bc12115ccb2afb7ea7b8dd101e3a75bfb67
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2024-01-25 13:42:51 +00:00
Renaud Thiry d0c2c225da [FIX] calendar: support writing attendee_ids with ids
Before this commit, attempting to do
`self.env['calendar.event'].write({'partner_ids': [0, 1, 2]})`
would give a traceback as the method that updates attendees
only supports parsing commands, not ids.

This is a problem as that method is called from 'write' and other methods
with the assumption that partner_ids can only contain commands.

This will not be the case when using a gantt view and grouping
by partner_ids for example, and cannot be worked around.

task-3452277

closes odoo/odoo#146446

X-original-commit: 88e191132bf40a4e3090077f1fd0077e649eb7fb
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2023-12-15 13:05:37 +00:00
Renaud Thiry 71a61fb8d9 [FIX] website_event_track{_live}: prevent traceback when missing track_live
In the recent redesign of the `website_event` module(s)
[1] a field was used in the templates of event_track
that only exists if event_track_live is installed.

The `t-att-class` argument is now overriden in `event_track_live`.

task-3597612

1: 94c5bc3d152c80fdbb6798d9b4d28bf62740856b

closes odoo/odoo#142215

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-11-24 14:59:39 +00:00
Renaud Thiry 77de6e827a [IMP] mail: Allow hiding tracking
It is sometimes desirable to completely remove a field
from the automated tracking message
when setting a custom message that already covers the change being made.

Add a filtering method on threads to allow models to selectively
hide tracking values from emails and messages.

task-2974500

closes odoo/odoo#109606

Related: odoo/enterprise#31795
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-10-30 07:37:12 +00:00
Renaud Thiry 044cd8af7b [FIX] web: update reference resModel with props
When ReferenceField uses an M2O field. The model is not updated along
with the props when the model field is updated.

Because of this, the onWillUpdateProps hook will keep trying to update
its value. This results in an infinite render loop.

task-3248500

closes odoo/odoo#139954

X-original-commit: f8f6aaa5e32967d6c7cd888fbe574acdc6f79dc6
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2023-10-27 07:14:45 +00:00
Renaud Thiry 79e9665a49 [IMP] mail: improve Composer duplicates check
Only duplicate emails used to be checked when sending a mass mail.

However it is possible (e.g. using templates) to send a mass mail
to the same person containing different information.

The existing functions to allow models to specify emails
processed in the past by some other means are kept.

A new check is added in the processing that checks the full contents
of the message, subject and attachment ids.

The strings are not hashed as most situations are:
- Sending the exact same mail to everyone
  -> Only need to check against one message
   -> Same complexity as hashing

- Sending all different emails
  -> Checking inequality of str is usually very fast

For attachments, as we cannot compare them easily.
They are ignored for the purpose of equating emails
whenever there are the same number of attachments
in the email values as there are on the composer.

This is because each email should receive its own copy
of the composer attachments. If they have a different
number of attachments, they were generated dynamically
through reports and we assume they are all different.

We can thus remove the 'document based' information
as it is implicitly infered from this check.

-------------------------

Test utils are also updated for two purposes:

1. Add optional body and attachment_name discriminents
assertMailMail assumed all emails could at least be
differentiated by subject. Our test breaks that
assumption, so we use body and attachment to find the
best-fitting email based on the data passed in.

2. Check email_formatted on recipients
When using assertMailMailWEmails, we first find the
email using the non-formatted email of the recipient.
This does not match assertSentMail which checks against
the raw email_to value, which would often be formatted.

Task-2826811

closes odoo/odoo#99541

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-09-18 22:16:56 +00:00
Renaud Thiry b71e5eea64 [FIX] mail: voice do not trigger change on unmount
'unmounting' key was not passed in when cleaning up the voice recorder
for an unmount.

In whatsapp this made the composer difficult to use as the voice
recoder is unmounted each time a message is sent.
The missing key made it impossible to send multiple messages as the
composer would be in the 'recording message' state, disabling the send
button.

Task-2377154

Part-of: odoo/odoo#134377
2023-09-07 11:46:11 +00:00
Renaud Thiry e7635bc705 [FIX] mass_mailing: toggle fullscreen once
In 16.0 and up, when toggling full-screen mode on the mailing editor
the iframe content is not properly made scrollable.

This is due to the toggle method being triggered 4 times
which effectively cancels the effect.

The reason for it being triggered 4 times is that the check that would
prevent multiple event listeners from being set on the button compares
an existing jquery object to a new one on the same element.
As these are two different references to the same element
they are still different objects and thus the listener will be added
even if they reference the same iframe.

The fix is simply to compare the html elements directly, if they exist.
We also add the expected state of 'full screen' to the class toggle
as it may avoid other inconsistencies from blindly toggling.

task-3446768

closes odoo/odoo#130853

X-original-commit: 30f27563868af4b247c96c24135c1003aa191cef
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-08-04 15:02:38 +02:00
Renaud Thiry 4dd17a201b [FIX] mail: notify alias owner when fetching
[1] introduces an issue when a response is sent to an aliased email.

In that case, it is intended that the message should be created
by the owner of the alias by [2]
Which breaks the assumption of made in the first commit, as the message
is being passively processed by fetchmail.

This causes the owner of the alias to never be notified on reponses
in cases where the message could be an alias update.
i.e. on any model where the alias applies.
Because the responses are assumed to have been authored by the owner.

As we do not actually care who creates the message records
and deciding the alias owner 'created the message' does not
actually make sense.
We make sure messages are created by odoobot even
if the message was sent to an alias address.

[1]: c676ed3ea906e99d27a6116cd77218c5ec95b416
[2]: af80c68ae5

task-3383275

X-original-commit: 96fe37d37c94c3d6f4642bd6c28d13fcd87075b7
Part-of: odoo/odoo#130798
2023-08-04 08:26:01 +02:00
Renaud Thiry 9da5f6e0f6 [FIX] mail: no default alias owner
Before this change aliases were assigned to the user creating them

The purpose was originally to reduce the number of records created by
odoobot however this leads to unexpected
behavior for the users who just wanted to create an alias without fuss

We make remove the default user such that any automated record
modification/creation will be applied by root instead of some
arbitrary user.

task-3383275

X-original-commit: 3edf18168b92545fc29e078a155494f2781adff6
Part-of: odoo/odoo#130798
2023-08-04 08:26:01 +02:00
Renaud Thiry 82e7f08afe [FIX] website_event: make falsy string id as False
Before [1] we used to consider '0' as False.
As this was not transfered in the refactoring, registering for
an event that does not have any ticket would give a traceback
saying the ticket is invalid.

This adds back the fallback to `False` for falsy values after they
have been converted from string to integer
as '0' is not Falsy in python.

[1]: 6b8daa880c

task-3381943

closes odoo/odoo#126783

X-original-commit: 5d61bc66b9e147d22175d15c8d39fc594f45b546
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Renaud Thiry (reth) <reth@odoo.com>
2023-06-30 00:21:14 +02:00
Renaud Thiry 845111af36 [IMP] crm: remove set_reason toggle field
In odoo/odoo#124103 we stop using this field in the wizard.
It is thus removed from master.

task-3356095

closes odoo/odoo#124049

Related: odoo/upgrade#4743
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-06-15 17:36:20 +02:00
Renaud Thiry f86f55f1ef [IMP] crm: ask for loss reason in leads too
In odoo/odoo#118494 we made it possible to set a loss reason on a lead
from the list view action.

However this did not update the behavior of the form view button.

As we remove the 'set reason' suggestion in this PR (odoo/odoo#124103)
It makes sense to update the form action to behave
the same way as the list view one.

task-3356095

closes odoo/odoo#124437

X-original-commit: 4a2534c8eda1b005e1a09a389fc77dcf7b3547fa
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-06-09 13:49:57 +02:00
Renaud Thiry 629666c489 [IMP] crm: remove loss reason toggle
To set the lost reason you currently need to toggle a field
in the wizard if you are marking a lead as lost.

As the loss reason isn't technically necessary, we can just let users
choose whether to input anything or not without having to click anything

We also introduce groups so field strings are displayed.
As the first field cannot easily be implied
to be the loss reason anymore.

task-3356095

X-original-commit: b5181ea609f798e09e2032fe182e01fd07d1c10e
Part-of: odoo/odoo#124437
2023-06-09 13:49:57 +02:00
Renaud Thiry ef37dce5fa [FIX] web_editor: _blank href for readonlyIframe
The "readonly iframe" mode of html_editor does not do
the processing required to ensure all links target a new tab when
the setup is called more than once.

As this happens often, links effectively did not redirect to a new tab.

Additionally sandboxedIframe did not allow new tabs to open.
We add `allow-popups` and `allow-popups-to-escape-sandbox`
to the sandbox attributes.

This is safe as the popup will not have access to the odoo window.
Which should mean it's as safe as opening a link without the sandbox.

opw-3337670

closes odoo/odoo#124395

X-original-commit: 61b6b6bf6181fe703cd3d455dba9004e1fad7135
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-06-09 10:55:02 +02:00
Renaud Thiry bb542f8374 [FIX] mail: allow editing of mail mail
As it holds full HTML documents, mail.mail often encounters issues with
the html editor.

We piggy-back off the intoduction of the switching
behavior between code-view and readonly-view behavior introduced in
a5c0085ce91570c6c961e3293dfe50f4faba6043

The 'sandboxed preview' mode can now be enabled with an option
and will ensure all content can only be viewed in a sandboxed iframe
or in the code editor.

This re-introduces editing, which was mistakenly fully disabled in the
usability fix that introduced body_content here:
5055b374c3bac0126f441dad61afd7e0b68b1370

Some tests are added to ensure the key points of this commit remain
the same. Tests are re-ordered alphabetically to match the order
of execution, making debugging easier.

task-3255777

closes odoo/odoo#121976

X-original-commit: 062569ef042f3b01044c5e4cdbd8b71e96bfd39d
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
2023-05-23 16:32:13 +02:00
Renaud Thiry c3866ca706 [IMP] mail: add search on body_content
It can be useful to search the body_content field
to find specific text while not including HTML tags
and attributes in the search.

task-3255777

X-original-commit: 1c60ffa13ca0d383480cae562379a7cde387a2df
Part-of: odoo/odoo#121976
2023-05-23 16:32:13 +02:00
Renaud Thiry 5ee99c04ce [FIX] web_editor: hide codeview when readonly
In 2389f77c25f3c4dcfd609a8674dc673703cac6a1
containsComplexHTML was added to allow editing of html content
that would otherwise break when inserted as-is in a DOM

For this we added a rule to always display the code view toggle button.
This should not be the case when the field is marked as readonly.

Switching to the code view in readonly mode will cause a traceback.

task-3255777

X-original-commit: 243b7879ecad229aaefed3cdf0c64e7ae434d8ec
Part-of: odoo/odoo#121976
2023-05-23 16:32:12 +02:00
Renaud Thiry 3bbabf5618 [IMP] event: use overridable getters for ics file
Currently the summary and description in event ics file generation
are set directly, with a condition in case the event is an appointment.

We make these two ics 'fields' use a getter so that it can be
overriden inside appointment instead.

In addition we remove the special formater for 'online events'
as it is only used for appointments, which does not use it anymore
as of this task

task-3232952

closes odoo/odoo#116211

Related: odoo/enterprise#38570
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-10 19:16:52 +02:00
Renaud Thiry 31262f27a5 [IMP] crm: remove set_lost_with_reason action
This cancels the changes added to f91782279a
for minor version 16.3 as the server action is completely removed
instead of being fixed in this.

The action is not removed in the upgrade as it is still technically
working. Though it should be considered deprecated.

------------------------------------

We remove the action that was used to conditionally call a window action

The action was not called consistently and added confusing indirection.

To maintain the current behaviour of only suggesting adding a loss
reason for opportunities.
We make the reason fields toggleable in the wizard, and hide them by
default for leads.

This leaves the user with the option to add a reason anyway, and serves
as a confirmation wizard if they don't want to.

-------------------

task-3272955

closes odoo/odoo#118494

Related: odoo/upgrade#4640
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-10 10:18:46 +02:00
Renaud Thiry 1a25988101 [IMP] crm: replace context with explicit default
Prior to this we used the context active_ids directly to determine
which leads to mark as lost in the lost reason wizard.

We now use a m2m field to store that value to make the behavior more
obvious and predictable, and to ease debugging.

task-3272955

Part-of: odoo/odoo#118494
2023-05-10 10:18:46 +02:00
Renaud Thiry 39f14ca2c9 [IMP] mail: add auto_comment message type
Currently some auto_reply templates are internal as a means to prevent
notifying users everytime we send a reply to somebody.

This raises the issue that since responses to internal notifications
are themselves internal notifications, often nobody will be notified of
responses to these automated messages.

We fix this by marking these messages as auto_comments, which will
ensure responses to these messages are
considered non-internal (and thus 'discussions', by default).

task-2834304

closes odoo/odoo#94018

Related: odoo/enterprise#35466
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-05-05 09:25:42 +02:00
Renaud Thiry c9f55bb227 [IMP] mail: Show reorder template response
If a tracked value sent a mail template on creation of a record,
the template was displayed before the original message in the chatter.

We fix this by using precommit hooks similar to those already used for
tracking.

We also update the query count for a couple of tests. This is required
because in those tests the test user is not in the cache when we execute
the precommit hook, which we use to fetch a fallback language early in
the precommit.

Task-2834304

Part-of: odoo/odoo#94018
2023-05-05 09:25:42 +02:00
Renaud Thiry 1196d470eb [IMP] mail, crm: reword notification actions
Prior to this notification actions are shown as such:
MODEL RECORD_NAME won | lost | settings

After they will be shown as such:
MODEL won lost settings RECORD_NAME

with the action links colored to match the company color.

The aim is to streamline the layout of e-mails and make actions
clearer.

task-3067315

closes odoo/odoo#106307

Related: odoo/enterprise#34284
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-24 10:20:12 +02:00
Renaud Thiry 87b0189ff1 [IMP] mail: remove default logo
Many templates use the company logo that is set by default on
database creation. As that logo is clearly a placeholder and the user
isn't necesserely prompted to update it. It's possible for a user to
inadvertently start sending emails with "your logo" placeholders
plastered all over.

This removes the default logo of the company and removes it from
templates conditionally.

The logo isn't simply replaced with a transparent PNG as the templates
set a fixed height for the logo, which would look weird.

task-3067315

Part-of: odoo/odoo#106307
2023-04-24 10:20:12 +02:00
Renaud Thiry c5bb2d0838 [FIX] web_editor: prevent editing of header
The way the live HTML editor for html_field works means the header
(and other nodes that should only appear once) are removed
and the content inserted inside the body.
This results in values being edited without the user being aware.

For emails, this results in any email using 'style' in the header
to break on GMail and other clients that do not support 'style'
outside of the header.

When an html_field is passed a value containing a header
the html_field appears readonly and the user is able to toggle
the code view. Which enables them to edit the 'raw' HTML and see changes
while preventing the presentation view from affecting the database value

task - 3035163

closes odoo/odoo#118920

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-04-18 18:29:08 +02:00
Renaud Thiry 3fa9aa2c05 [FIX] mail: exclude abstract models from templates
Templates could previously be created for abstract models.

The methods are not written with that in mind and most useful ones will
raise an exception when calling them on that template.

task-3162320

X-original-commit: 0d4b473ee54d2376f4f71efd864aa0e16822d4ba
Part-of: odoo/odoo#118710
2023-04-17 11:47:12 +02:00
Renaud Thiry f7e5fd7aab [FIX] base: use html method from lxml
Prior to this change the convert tool did could mangle
the value of html fields when importing static data.

This is because html does not support 'self-closing'
except for HTML5 where it is allowed on void elements (such as img).

Browsers will assume that they are opening tags, left unclosed.
<span/> becomes <span>
They will then try to repair them with variying degrees of success.

Example where it fails:
`<t><t/></t><t><t/></t>`
should become
`<t><t></t></t><t><t></t></t>`
but it becomes
`<t><t></t><t><t></t></t>`

i.e. instead of closing the 'self-closing' tag immediately,
it puts everything inside a single t node

More concretely:
```
<t t-if>
  <t t-out />
</t>
<t t-else>
  <t t-out/>
</t>
```
becomes
```
<t t-if>
  <t t-out></t>
  <t t-else>
     <t t-out></t>
  </t>
</t>
```
which is invalid

-------------------------
The fix is simply to tell lxml that we want to print the xml nodes
as HTML nodes. This will make sure the output is compliant with
the standard and keep the semantic clear for the browser.

The issue does not appear before 16.2, as jquery used to fix it
for us until an update here 9c41ee5091ac06ac3ca71aeac607195c70061e4a

task-3162320

X-original-commit: 8ff2e1018264972107f19755ecda352d78dfa829
Part-of: odoo/odoo#118710
2023-04-17 11:47:11 +02:00
Renaud Thiry 5c146ec219 [FIX] mail: compute resource_ref
Before this, the resource_ref field is computed once in the default_get.
This means if the cache is invalidated, its value is unrecoverable.

Notably, the cache is invalidated when an attachment is generated
(triggering a commit).

So calling _generate_template could invalidate resource_ref,
which we use as a key to retrieve its result.

This results in a traceback for the user when trying to preview
a template where the first record hasn't yet generated its attachment.

As an example, trying to preview `Sales: Send Quotation`
on fresh installs.

task-3162320

X-original-commit: b4bd93c9b61736a7f41d70afe5db977a6e4b35e0
Part-of: odoo/odoo#118710
2023-04-17 11:47:11 +02:00
Renaud Thiry 20fe457377 [FIX] mail: set error_msg in template_preview
If the preview wizard was used to preview a template on a model that
has no record, error_msg would not be set.

This means the field is never set in that case and creating the wizard
results in a cache miss on that field.

The fix is to simply set it, and we add a test to cover that flow of
the wizard.

task-3162320

X-original-commit: 0976ce53e0a97a1f49dc2a262cf66355242fde25
Part-of: odoo/odoo#118710
2023-04-17 11:47:11 +02:00
Renaud Thiry b3f6a6e695 [IMP] mail: make alias domain into its own setting
Currently, the alias domain can only be set by selecting:
'Custom Email Server' in the settings.

This does not make sense for users of pre-configured databases who
just want to use the default server with their own domain.

We move the domain to its own setting to prevent confusion.
As people are not always aware they can just set a domain without
configuring a server.

task-3224434

closes odoo/odoo#116174

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-04-13 12:29:51 +02:00
Renaud Thiry dddb2f5355 [IMP] base: Clear precommits on test cleanup
Precommit hooks would stock data until a call to ``cr.flush`` was made.
Notably, this happens when the ``assertRaises`` method is called.
Functions were applied on records already cleared from the cache.

This change adds a cleanup call for `TransactionCase` as it keeps
the same cursor for all tests. Cursor precommits can now
be safely executed inside tests.

Task-2834304

Forward port of #117555

closes odoo/odoo#118290

X-original-commit: ff5d0c75fcea5842c5236b1b3f7480ef5a3dc415
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-04-13 04:08:25 +02:00
Renaud Thiry 442467ceb8 [FIX] mail: handle non-thread model in _message_format
Calling _message_format on a anything but a thread could throw a traceback.

Task-3254379

Part-of: odoo/odoo#117763
2023-04-05 15:11:33 +02:00
Renaud Thiry f91782279a [IMP] crm: preserve action context for lost lead
Prior to this all of the context of the action called in the list
action was overriden. We now combine the action context with the
environment context.

This allows keeping the context from the XML action that defines the modal sizing.

task-3235932

closes odoo/odoo#116287

Related: odoo/upgrade#4493
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-04-04 17:03:28 +02:00
Renaud Thiry 035057a522 [IMP] mail: track contact address
Currently there is no way of knowing who changed the address
of a partner. This field is of high importance and should be
tracked to be able to follow who is editing it.
As addresses are represented with a bunch of fields, tracking
them individually would result in weird-looking tracking
messages with each value stacked on top of the other.

To avoid this, we take advantage of the fact that tracking can
be used on non-stored compute fields to log any change as a
change over the full address.

The full address is derived from the contact_address field to
take advantage of the existing regional formatting of addresses.
It is however modified to replace return to lines with commas to
accomodate the formatting of tracking messages in the front-end.

task-3165293

closes odoo/odoo#114695

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-03-30 16:22:45 +02:00
Renaud Thiry ecbca821ad [FIX] mail: make access button clickable
When the template layout was made more mail-client friendly in 16.0
we used padding on a <td> node with
a color background to make it look like a button with centered text.

This approach makes most of the button unclickable.

The fix is to put the padding inside the link itself so that the whole
'button' is clickable. We already do this for most templates.

task-3168757

closes odoo/odoo#116945

X-original-commit: c40327db4f46040d4a6ed0231afcdefd5be47db5
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-29 10:37:37 +02:00
Renaud Thiry bc4abcc1b3 [FIX] mail: allow sending notification emails
Add back the 'sudo()' on batch mail unlinking.

Sudo is necessary to delete user notifications on auto-delete.
Which makes sense as the  recipient would have an email for it anyway.

The sudo was there as far back as:
c5c369355d

Then transfered in this change:
036a739b62

And removed in the recent optimization here:
e38bfd25df1bb25e7e5695b536052d5a0c85c5c4

task-3225207

closes odoo/odoo#115956

X-original-commit: 93a28f17024511e30d3c70eb847c361ca87e0ffe
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-03-21 07:36:00 +01:00
Renaud Thiry beb02b5c8e [FIX] mass_mailing: hide menu on mobile
closes odoo/odoo#114543

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-03-08 16:26:16 +01:00
Renaud Thiry 37348521ce [IMP] mass_mailing: remove A/B percentage limit
A/B testing was used in the past to create mutually-exclusive mailings.
Since then a 100% limit for the recipients of an A/B campaign.

As there is no technical reason for this limit and not having it allows
for a special usecase, it is replaced here with a text warning.
The usecase in question being that as the domain of the different
mailings composing a campaign may be different, users may want to
take advantage of the fact that only 1 email will be sent to each
address to avoid sending 2 mailings when only one or the other should
be sent. Consequently users may want to use 100% of the domain on
every mailing in their campaign.

As the ab_testing_total_pc is only used for that purpose the field
is removed. 'total' field  is not always accurate and is unused so
it is also cleaned up.

task-3008627

closes odoo/odoo#105639

Related: odoo/upgrade#4257
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-02-21 19:08:09 +01:00
Renaud Thiry 689aa32ee3 [FIX] web: sampleserver generates __range
The sample server did not create a __range value when grouping by 'date'
This resulted in a traceback as it is expected to at least be false.

This commit computes it properly.

task-3098681

closes odoo/odoo#113163

X-original-commit: cf074f1dc01da39e75aa30e4ac21eafa29d528d9
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2023-02-20 19:25:04 +01:00
Renaud Thiry 7b6638407d [FIX] calendar: redirect to auth url
In 16.0, at 6a42ec7c73
an error was introduced redirecting users to the configuration panel
when clicking the 'sync' button for extenal providers in calendar.

This simply replaces that call with a redirect to an authentication url
received from the back-end.

task-3131128

closes odoo/odoo#111392

X-original-commit: 0574c18acd70c3fe52cdb5cbe563ffa02f5f5ad3
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
Signed-off-by: Thiry Renaud (reth) <reth@odoo.com>
2023-02-03 09:28:30 +01:00
Renaud Thiry fbb808301a [FIX] mass_mailing: correct 'total' value
The percentage used for A/B test was applied even when
A/B testing was disabled. As that value is 10% by default
the 'total' was innacurate by 90% for most mailings.

task - 3008627

closes odoo/odoo#110677

X-original-commit: eb2271330e7759400dad155b72208cf7677e175e
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-01-23 13:18:59 +01:00
Renaud Thiry a64a72188b [FIX] mail: remove MAKO compatibility
Before this change URLs would get their url-safe encoding replaced
with regular characters when cleaning up
html content.

This caused signed URLs that use some of those characters to become
invalid if the target did not accept equivalent characters.

Concrete example:

/markers=size%3Alittle%7CAddress
is not the same as
/markers=size%3Alittle|Address
for google maps signed static urls

Do not add special handling for MAKO patterns
as they are not used in templates anymore

task - 3079113

Part-of: odoo/odoo#107200
2023-01-20 19:56:52 +01:00
Renaud Thiry 1348509668 [IMP] event: add setting menu for g-map API key
Add some setting buttons for users to configure their API keys in events

task-3079113

Part-of: odoo/odoo#107200
2023-01-20 19:56:52 +01:00
Renaud Thiry 83e4551492 [FIX] event: add signed static maps api
Google now requires an API key for the static maps API.
As API calls cost money, and we cannot restrict the domain of the caller
with the API key in emails, as the domain may vary vastly,
the signing of static API URLs is implemented in the existing
'google_map_img' of partners.

This in turn can be used to get a url for an existing location.
While preventing anyone from stealing the API key for their own purposes

task - 3079113

Part-of: odoo/odoo#107200
2023-01-20 19:56:52 +01:00
Renaud Thiry a8cb52afee [FIX] web: keep full urls in settings
The function that adds the missing url root on documentation links uses a regex
in startsWith, which is not supported.

startsWith is replaced with ``regex.test`` which will succeed
if the regex has any match.
Which is fine because we use a '^' to ensure it *starts* with https

task-3079113

closes odoo/odoo#110443

X-original-commit: fdaeaf69c1770edf3f33e32947326d1ebe42820e
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
2023-01-20 10:42:43 +01:00
Renaud Thiry 9828ce96d0 [FIX] web: handle falsy m2m_tags
Before this change, if a user left a string value in a m2m_tags
and removed it afterward without selecting a tag, the update method
of Many2XAutoComplete would be called with false.

As the update method for m2m_tags expects a record or record list
this caused a traceback.

The fix is to simply skip the update in that case.

task-3109811

closes odoo/odoo#110123

X-original-commit: 14f314feb7594dc888de6af4e4ad23a948044854
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2023-01-17 14:16:47 +01:00
Renaud Thiry 024569fe4c [FIX] event: Remove broken google maps api link
Note:

This is not fixed earlier  because this in invalidates
template translations and this isn't a major issue.
Invalidating translations on 16.0 should still be
fine as of writing this.

Issue:

Google recently added a requirement for an API key
to their static maps API. This means we can no longer generate
<img> tags linking to the google API without using a key.

As we send that key inside emails, it cannot be protected
by origin policies to prevent people from using the key outside
of the domain of the database. Protecting it would require
implementing signed google API requests, which cannot be
done both quickly and sanely on stable.

Fix:

This commit replaces the image with a generic string to get rid of the
'missing image' icon. A better fix/imp may be introduced on the master
branch at a later time.

task - 3079113

closes odoo/odoo#109797

X-original-commit: a730c9920bc82a6637882f325ca3d947ca0ddd78
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2023-01-13 09:18:45 +01:00
Renaud Thiry f039f57eb8 [IMP] Add more detailed default email subjects from chatter
All emails sent from the chatter start with "Re:" followed
by the name of the record. The name of the record alone is sometimes not enough for
the followers to understand what the mail is about.
Additionally, "Re:" does not make sense when starting a conversation.

This commit gives better default subject
for event registrations and allows thread models
to override the default subject of messages.

This also removes "Re:" from default mail subjects.

Task-2833215

closes odoo/odoo#95817

Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2023-01-05 15:36:53 +01:00
Renaud Thiry 78a3738559 [IMP] mail, sms, livechat: update emoji picker
CONTEXT:

emoji_char_field and emoji_text_field
previously used the emoji_dropdown component
along with some utility functions to display
a very limited number of emojis.

As discuss now has a feature-full emoji picker
we aim to take advantage of it by bootstrapping
the picker from the existing components,
using a new javascript model for the
insert/update logic

AFTER THE CHANGE:

Users should be able to select the same emojis
they can use in the discuss chat in all fields
that previously featured an emoji picker.
Such as the livechat bot responses,
social posts, mailing subjects and
the sms message composer.

RELATED CHANGES:

Some tests are updated to use the pyEnv testing
'framework', as we now need to have access to
the messaging service to test these fields.

emoji_mixin is modified to match any emoji
character. The mixin is consolidated into
a single function is actually called anymore.

The text to emoji dict from emojis.js is removed
as it is no longer relevant where it was used.

The fields that used the emoji_mixin will no longer
trigger onChange on inserting an emoji.
However both the input and keydown event are fired
to allow fields using onchange_on_keydown
to trigger the onchange.

The emoji button was turned into an actual button
replacing the original span used in these fields.
This required a different approach to styling as
buttons inherently behave differently than spans.
The button is now moved using an empty div next
to the input and absolute positioning.

Most of the code used for char and text emoji
fields is consolidated into emojis_field_common.

task-3035021

closes odoo/odoo#104799

Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-12-01 16:27:44 +01:00
Renaud Thiry 53cad6f9f7 [FIX] calendar: show dialog when sync unconfigured
## Issue

Currently if an administrator installs one of the sync modules but does
not set any credentials. If the user tries to sync their calendar
they are met with an error.

## Fix

Make sure they get a clear dialog explaining why they cannot sync.

task - 3056311

X-original-commit: 6ec6a3764c5e5460aa8a1cdfa228740606fdfe13
Part-of: odoo/odoo#106517
2022-11-25 17:56:31 +01:00
Renaud Thiry 13db30cba5 [FIX] calendar: show calendar sync when installed
## Issue

Regular users were not able to see the sync button
used to sync with external calendar services even after
these services were configured

## Fix

Conditionally display the whole sync section until one of the
services is configured.

Override the display conditions when one of the relevant modules are
installed.

task - 3056311

X-original-commit: 29f820cfd421859a2b480725ba2a81a515509b88
Part-of: odoo/odoo#106517
2022-11-25 17:56:31 +01:00
Renaud Thiry a43b8c6805 [FIX] calendar: hide 'sync' options from users
Issue
When the google and outlook sync plugins are not installed the admin user should see an option to install them from the calendar but other users should not see anything.

Fix
This replaces the 'groups' attribute in the calendar controller template with a t-if and a dynamic check as OWL doesn't process 'groups'.

task - 3056311

X-original-commit: 4d5b7d4b5347c958f37b8f40e9edfae7cd78c2ca
Part-of: odoo/odoo#106517
2022-11-25 17:56:30 +01:00
Renaud Thiry 629b904f32 [FIX] mail: focus on search bar after load
The logic to set the focus on the emoji search bar was only triggered
the first time any emoji picker was opened.

This makes sure the focus is processed every time a picker is opened.

task - 3035021

closes odoo/odoo#106315

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-11-23 13:24:56 +01:00
Renaud Thiry 84b4af755d [FIX] mass_mailing: remove gold color in stats
Commit a170b7265e158323d3769f1631314f06c96a6e4b
applies the star color to all stars in the form view

The star in the stats bar should remain black.

task-3044832

closes odoo/odoo#104210

X-original-commit: b2f37a06546638fde69d392dfec3d76fc15ca0e3
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-10-26 19:03:58 +02:00
Renaud Thiry eeb8197516 [FIX] mass_mailing: reduce pad on template select
There was too much padding up and down from the tooltip.

Adds conditional display on the template menu
when there are no templates (t-for-each is not fully empty).

Also fixes the favorite  icon color in edit mode.

task #2984478

closes odoo/odoo#104108

X-original-commit: a170b7265e158323d3769f1631314f06c96a6e4b
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2022-10-26 08:09:23 +02:00
Renaud Thiry 0db9c830a9 [FIX] mail: remove suggested recipient
When creating a recipient from composer_suggested_recipient the user
is free to modify the partner form however they want.

This can lead to them inputing data which will create a partner
that does not match the suggested partner data.
In that case the box acts as if the partner was not created.

This aims to remove the partner in such cases and warn the user.

task #3016112

closes odoo/odoo#104005

X-original-commit: 51dd925d3660609b03349c42377e15064461eb3e
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2022-10-25 12:05:18 +02:00
Renaud Thiry 96c8dd3ca8 [FIX] web_editor: onAttachmentChange only composer
Due to a previous fix, attachments uploaded through media dialog would appear in the attachments of mail marketting.
That fix prevents attachments from 'dangling' and being garbage collected later.

That fix is now limited to the mail composer in this commit as attachments are only garbage collected for that model, for now.

related commit: c112361bf9e2f5e7b087c5e5b9a31879856b1da4

task 3003939

closes odoo/odoo#103038

X-original-commit: 69fdca133b06eb66443635bc52d380233580ef51
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-10-11 14:10:25 +02:00
Renaud Thiry eaf905d55a [IMP] mass_mailing: hide mailing option on invalid
Currently when creating a composer in mass mode
the composer always shows the 'mass mailing name' option
even when a mailing cannot be created.

This silently creates a regular mass mail.

This hides that option when selecting records of models
that do not inherit from thread. So that users do not falsly
believe a mailing will be created.

task #2990447

closes odoo/odoo#102105

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-10-06 14:56:49 +02:00
Renaud Thiry be53351746 [FIX] web_editor: Invalid import in test
Imported unsplash in web_editor when it was not a dependency.
This caused the test to fail when web_unsplash was not installed.

As it is necessary to import it when the module is installed,
this test is moved to test_website as both modules are installed there.
(Also updated to ES6 import syntax + odoo-module style test)

task #3000801

closes odoo/odoo#101672

X-original-commit: d85ba585ec4642a507d24ab94606a65970c635f3
Signed-off-by: Stéphane Debauche (std) <std@odoo.com>
2022-09-30 09:32:03 +02:00
Renaud Thiry 0553e16dbd [FIX] mail, web_editor: dialog file update event
An event was not called on uploading files in a media dialog.
This meant the parent of html field didn't know of the new attachments
which resulted in attachments being linked to no record at all
and  not being garbage collected later.

This adds a reference inside the media dialog file input so that it can
trigger that event on behalf of the html field.

The attachments newly uploaded in media dialog are uneditable
to prevent users from unlinking attachments
that are still used in the body of the composer (causing the same issue)

Task-2860761

closes odoo/odoo#101405

X-original-commit: f4dd1eb3f25672e7309759c347e2b552c5652b2f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-28 14:19:11 +02:00
Renaud Thiry bcce093ed3 [IMP] mail: add message_partner inverse on threads
This change allows for adding and removing followers from threads
by directly setting the message_partner_ids field of threads.

This enables the use of many2many_tags to add followers to a thread.

Task-2804888

closes odoo/odoo#95645

Related: odoo/enterprise#29284
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-09-14 21:21:09 +02:00
Renaud Thiry 00c04b7a8f [FW][FIX] mail: Give reply-to non-template value
When sending a mass mail through the composer, if the field ``reply_to`` had to
fall back to being ``email_from``, reply_to would take the value of the template
syntax instead of the rendered value.

This is notably the case when mass-mailing invoices through the accounting app.
Resulting in reply_to fields such as: '{{user.email}}'

On some mail clients (including mailhog), this could also result in template
syntax being shown as part of the subject or sender field.

This commit fixes that by correctly taking the rendered value of 'email_from'

Task-2816845

X-original-commit: e320b852e8f1958ac3dccaa5333420bb7b8d8f3d
Part-of: odoo/odoo#98287
2022-08-18 15:07:56 +02:00
Renaud Thiry fe0107803e [FW][IMP] test_mail: add test for from and reply-to computation in composer mass mode
FWD-PORT: updated to new test files, and tests are more in-depth since v14

When sending a mass mail through the composer, if the field ``reply_to`` had to
fall back to being ``email_from``, reply_to would take the value of the template
syntax instead of the rendered value.

This is notably the case when mass-mailing invoices through the accounting app.
Resulting in reply_to fields such as: '{{user.email}}'

On some mail clients (including mailhog), this could also result in template
syntax being shown as part of the subject or sender field.

Task-2816845

X-original-commit: b87df6664908615bdf57bf16e239a10c3f7bf89b
Part-of: odoo/odoo#98287
2022-08-18 15:07:55 +02:00
Renaud Thiry 9eb8e52fdc [IMP] mail: Remove "duplicate" from notification form view
(To be commited with  [#94024](https://github.com/odoo/odoo/pull/94024))

Duplicating an email sent from Odoo would raise an error because some required fields could not be set.
Setting those fields on duplication does not make sense, duplication is to be disabled on e-mails.

As this applies to some messages and no use-case could be found for the duplication of messages or notifications,
both also had duplication disabled.

Task-2857244

closes odoo/odoo#95138

X-original-commit: 6f9656fc4ceeecd304f600b7cd65d649618ad182
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-07-04 10:19:39 +02:00
Renaud Thiry e42446600e [FIX] mail: Update legacy arguments for services.action.doAction
Emails could not be resent from the chatter after failing to be sent.
This was due to parts of code not being updated after a refactoring of OWL.

Multiple other instances of non-updated code are updated here.

Task-2887153

closes odoo/odoo#94529

X-original-commit: 8fbdb1b52b9051e92e4980d5af73460a46fe70da
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-06-24 15:00:48 +02:00