Commit Graph
72 Commits
Author SHA1 Message Date
Zelong Lin d57c64f95b [IMP] mail, *: remove 'public' field in channel
*: im_livechat, website_livechat

Access right should be based on channel type and membership instead.
Chat always private, group always private, channel private should
disapear and be a group instead (migration needed), and other channel
always public (but they can still be further restricted with
the "allowed groups" feature)

task-2632861

closes odoo/odoo#90415

Related: odoo/enterprise#30980
Related: odoo/upgrade#3850
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-09-06 10:57:59 +02:00
Romain Derie 44ae3f38da [IMP] *: bypass sanitize for full editor users on frontend fields
The previous commit allows the sanitizer to be bypassed by some users if
those users are part of one of the `base.group_sanitize_override` group
and if the HTML field is declared as `sanitize_overridable`.

This commit flag frontend HTML fields as `sanitize_overridable`.
See the main commit of this PR for more details.
It also gives the `base.group_sanitize_override` group to the "Editor &
Designer" group.

Part-of: odoo/odoo#97398
2022-08-24 23:03:23 +02:00
Louis Wicket (wil) fdcaa53ca0 [IMP] mail, *: rename mail.channel.partner to mail.channel.member
* = calendar, crm_livechat, hr_holidays, im_livechat, privacy_lookup,
privacy_lookup, test_discuss_full, test_mail_full, website_livechat

closes odoo/odoo#95912

Related: odoo/upgrade#3681
Related: odoo/enterprise#29433
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-07-19 11:50:37 +02:00
Romain Derie d348bed1ad [IMP] website, *: use upsert to improve visitor perf
* im_livechat, test_event_full, website_blog, website_crm,
  website_event, website_event_track, website_event_track_quiz,
  webite_livechat, website_sale

There is 6 main changes in this commit:

1. Using raw SQL Upsert instead of the ORM methods. While raw SQL should
generally be avoided, it makes sense for such a low level behavior which
is impacting every flows.
Indeed, tracking visitors is a generic behavior done on all pages and
controllers. It is important to optimize it to reduce processing time
and SQL Queries.
Benchmark of that change alone:
> Rendering a tracked page improves from ~19.5ms to ~17ms (using `ab`
  with 1000 loop) and the requests involved in the tracking process are
  reduced from 8 SQL Queries to 3:
  - 1 request to upsert the visitor
  - 1 request to fetch the visitor data
  - 1 request to add the tracking record

2. Adding in that upsert query the `visitor.track` insert, creating both
records in one go, bringing the query count from 3 to 2.

3. Refactoring of the `parent_id` behavior that was introduced in stable
with [1]. The purpose was to keep track of multiple visitor linked to a
same user to merge the tracking together. Especially useful for tracking
a same visitor on different devices (when logged in).
Only one visitor was kept as active, others would be archived and their
tracks would be set/moved to the main partner.
Removing those duplicate visitor was not possible because those archived
duplicated visitor were holding the devices notification push token.
Since [2], those token were moved to their own table, all related to the
main visitor.
We can then now safely remove those duplicate visitors after merging
their track to the main visitor. Thus, the `parent_id` field is no more
useful. Removing it removes a layer of complexity.
Note that thanks to this part, the `active` field can also be removed.

4. Deeper functionnal change, inspired from Plausible: The access_token
is no more stored in a cookie but is the result of a hashing method
based on <IP Adress, User Agent>.
The reason behind that change is that, in an upcoming refactoring,
sessions won't be stored anymore unless absolutely needed (login, add to
cart..). It will also ship a no cookies policy, trying to get rid of all
cookies.
This change is bringing some functional changes:
- Since the IP is included in the hash to generate the token, it means
  that:
  A. If an anonymous user switch IP (eg from 4G to wifi), it is
     considered as a new visitor.
  B. If 2 anonymous users with the exact same user agent (same browser,
     same browser version, same exact os or phone) are on the same IP,
     those will be considered as the same visitor.
- Since the request host is not included in the hash, it means that
  visiting a DB from 2 differents URLs (domain and/or ip) on the same
  device and same browser will result in a shared visitor.
  It shouldn't imply any issue as this is A. not wrong and B. mostly
  used for tests.
As all this is only related to non logged in user, it shouldn't be a
real issue as anonymous visitors are not supposed to be meant to be
business critical, even if we use them for "a bit more" than simple
analytics data.

5. The access_token is now replaced by the partner_id once the user logs
in, so:
- We don't need to either search on the partner_id field or the
access_token field (depending if the user is logged in or not), we can
only use the access_token row/field to do both.
- On logout, everything works out of the box as the access_token will be
regenerated since there is no partner_id anymore.
- On login, if an access_token matches the user's partner_id, that
visitor is returned.
If there is no such token, a new visitor is created for that partner_id.
In both 2 cases, tracks are moved to that visitor and the anonymous
visitor is removed.
- We can remove the code that was in charge of checking if the
access_token / visitor cookie was wrong (coming from another user eg,
different user login on same device). Indeed, such collision is not
possible anymore as the access_token automatically match the logged in
user.
- We can remove the code that was in charge of checking if the
access_token / visitor cookie was wrong (coming from a logged in user
while the current visitor is not loggedin). Such collision is not
possible anymore as the access_token is (re)generated as an anonymous
token (hash) when not logged in.

6. There is no more check to prevent a track to be created if there was
already a track for that URL in the last 30 minutes.
While this can easily be re-introduced (one CTE on the upsert), it was
adding ~100ms (from ~20 to ~110ms) to the request on a big database as
Odoo where there is ~100 millions tracks and ~100 millions visitors.
It has been validated that it was not a real issue as it is not
fundamentally wrong. If a visitor visited 20 times a product or a
specific page in that short amount of time, you might want to know that
because the user is most likely interested by it.

Changes (1+2), 3, (4+5) and 6 are all independant from each other and
could have existed on their own.

[1]: https://github.com/odoo/odoo/commit/c6b8a44b970a46dcd87a4e2cb1ad52fa340b209f
[2]: https://github.com/odoo/enterprise/pull/16781/commits/f75090fe8b42484e89e933976e8441d2f5eb9415

task-2867045

closes odoo/odoo#87857

Related: odoo/enterprise#28004
Related: odoo/upgrade#3566
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
2022-06-07 16:31:20 +02:00
Fabio Barbero fc79bd1e0e [IMP] sm modules: "neutralise" genders
Purpose
=======
Change all masculine nouns in Odoo's code to neutral nouns (when
possible), making sure that demo data is correctly handled. This is
particularly important since our code is open source, and nowadays lots
of machine learning models are trained on open source repositories.

With this small change we contribute to training more "fair" models, and
teaching models that "employee" or "user" != "he".

This also affects some text visible by the user, hence making it more
inclusive for Odoo users.

Task-2853046

closes odoo/odoo#91292

Related: odoo/enterprise#27302
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2022-05-16 10:09:32 +02:00
Aurélien Warnon d7c6a5a3ca [IMP] [im|website]_livechat: make operators avatars publicly available
This commit improves the livechat to always allow website visitors to be able
to see the operator avatar, regardless of ACLs.

Indeed, we currently depend on ACLs and when website is installed, the
visibility of the operator avatar depends on his website_published status.
Which does not make much sense as it requires extra configuration to make it
work.

Instead, we now consider that all livechat operators and all chatbot operators
have their avatar publicly available, using a custom livechat route.

Task-2813529

closes odoo/odoo#89756

X-original-commit: 127bf62a5d701f8d2f1d4b246f55cc8ca8630dcf
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
Signed-off-by: Warnon Aurélien (awa) <awa@odoo.com>
2022-04-27 07:52:18 +02:00
Sébastien Theys 870eb515eb [IMP] mail, *: remove uuid from channel_pin
* = im_livechat, website_livechat

Unnecessary param.

task-2827807

Part-of: odoo/odoo#89115
2022-04-21 12:49:58 +02:00
Aurélien WarnonandPatrick Hoste ea680d8595 [IMP] im_livechat: introduce chatbot scripts
PURPOSE

This commit introduces a chatbot operator that works based on a user-defined
script with various steps.

SPECS

A im_livechat.chatbot.script can be defined on a livechat rule.
When a end-user reaches a website page that matches the rule, the chat window
opens and the script of the bot starts iterating through its steps.

The chatbot code is currently directly integrated with the existing livechat
Javascript code.
It defines extra conditions and layout elements to be able to automate the
conversation and register user answers.

AVAILABLE STEPS

A script is defined with several steps that can currently be one of the
following types:

"text"

A simple text step where the bot posts a message without expecting an answer
e.g: "Hello! I'm a friendly robot!"

"question_selection"

The bot will ask a question and suggest answers, the end-user will have to
click on the answer he chooses
e.g: "How can I help you?
  -> Create a Ticket
  -> Create a Lead
  -> Speak with a human"

"question_email"

That step will ask the end user's email address (and validate it)
The result is saved on the linked im_livechat.im_livechatchatbot.mail.message

"question_phone"

Same logic as the 'question_email' for a phone number
We don't validate the input this time as it's a complicated process
(requires country, ...)

"forward_operator"

Special type of step that will add a human operator to the conversation when
reached, which stops the script and allow the visitor to discuss with a
real person.

The operator will be chosen among the available operators on the
livechat.channel.

If there is no operator available, the script continues normally which allows
to automate an "answering machine" that will redirect the user in case no
operator is available.

e.g: "I'm sorry, no operator is available right now, please contact us by email
at 'info@company.com', we will try to respond as soon as possible!".
(Or even something more complex with multiple questions / paths).

"free_input_single"

Will ask the visitor for a single line of text.
This text is not saved anywhere else than in the conversation, but it's still
useful when combined with steps that create leads / tickets since those print
the whole conversation into the description.

"free_input_multi"

Same as "free_input_single" but lets the user input multiple lines of text.
The frontend implementation is made by waiting a few seconds (currently 10) for
either the next submitted message or the next character typed into the input.

This lets visitors explain their issue / question with multiple messages.
Which is very useful since new messages are sent every time you press "Enter".

LINKS

Task-2030386

Part-of: odoo/odoo#84000
Co-authored-by: Patrick Hoste <pko@odoo.com>
Co-authored-by: Aurélien Warnon <awa@odoo.com>
2022-04-01 18:49:56 +02:00
Hiral Bhavsar 7bab57a50a [FIX] (im,website)_livechat: visitor country displayed twice in backend
Before this commit:

At least if website_livechat is installed, the livechat visitor (website visitor)
country is displayed twice in channel name: once from the country inside the
name of livechat_visitor and once from the country of the actual
website_visitor.

After this commit:

Livechat visitor country will be displayed only once instead of twice

Task-2668051

closes odoo/odoo#81398

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-03-31 16:27:54 +02:00
Aurélien Warnon 0641cb20e8 [REF] website_event: move website.visitor's parent_id to website
The concept of 'parent_id' on website.visitors was introduced in the saas-13.3
stable while implementing the "event online" feature:
However, it should have been part of the website module from the start since
it's a 'global' concept that does not depend on events at all.
See #53540 for more details.

This commit aims to clean the code by moving the field to the website module,
which allows a nice cleaning of associated overridden methods as well.

Along with that, we move the website.visitor demo data from the event module to
the website module, allowing a fresh install of website to showcase some of our
visitors feature.

We also took this opportunity to do some minor improvements in the visitors
kanban view in order to make relevant information more visible.

Task-2429652

Part-of: odoo/odoo#65113
2022-02-17 17:37:40 +00:00
Luis González 3ca6e48142 [FIX] website_livechat: access error when retrieving chatter info
When chatter information is retrieved but current user has no access to website visitors, an access error is raised and chatter messages are not displayed.

To replicate:
- Enable livechat for current website
- Set user A as member of the livechat
- Log-in with user B, who doesn't have access to website visitors
- Visit any page that automatically opens the livechat with user B (no
  need to input anything, as a livechat is created when the chat window
  pops up)
- Go to backend with user B

To solve the above, visitor information is included only if current user
has enough right to access it.

closes odoo/odoo#84823

X-original-commit: 7fb23842ef2e2950466f44b18005d27443d292f9
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-02-17 16:42:04 +00:00
Raphael Collet a1904aa6f6 [IMP] core: field index names
The possible index names have been renamed "btree", "btree_not_null"
(instead of "not null") and "trigram" (instead of "gin").

Task 2742526

Part-of: odoo/odoo#83274
2022-01-28 14:10:01 +00:00
Fabien Pinckaers eedf37d6e2 [IMP] Better handling of indexes
Three supported types:
- btree (default for index=True)
- btree not null (when >90% of the data are null)
- gin trigram search (for char fields)

Review of indexes on all objects.

closes odoo/odoo#83015

Signed-off-by: Fabien Pinckaers <fp@odoo.com>
2022-01-19 16:52:23 +00:00
Sébastien Theys 07048871af [FIX] mail, im_livechat, *: restore usage of livechat user name
* = website_livechat

Prevents from leaking unnecessary information to livechat clients.

opw-2453956

closes odoo/odoo#82026

X-original-commit: 5ec191d288d5b44f78cd1f6980c47bb64cfd9bd1
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-12-29 16:55:47 +00:00
Didier (did) 1afcc9c368 [IMP] bus, mail, *: improve longpolling bus notification format
* = auth_signup, calendar, im_livechat, snailmail_account, survey, test_mail,
    web_editor, website_crm_iap_reveal, website_livechat

The aim of this PR is to improve/fix various flaws and limitation of the current
API, to make it easier to use and more efficient.

Notification are now defined with 3 distinct parts:

- the channel determines which client(s) should receive it
- the type determines how it should be handled
- the payload determines any extra information helpful for handling it

Channel
=======

Business code
-------------

- Record channel is introduced for ease of subscribing to and sending
  notifications to specific partners, channels, documents, ...
- String channel is still supported (but it is converted internally to the tuple
  channel).
- Tuple channel is still supported without any change (but should be avoided
  whenever possible due to its complex syntax).

The channel is no longer sent to the client. When the channel was used for
business purpose, the information it contained has been moved into either the
new type, or the payload itself.

Technical note
--------------

All channels are now internally converted to the tuple (db, ...) channel, which
is necessary for the platform code (saas/sh).

Internally, the bus.bus table is not changed, type and payload are grouped
together into what was (and still is) called message.

Type
====

Type is introduced to uniformize the way notifications are sent and handled.
All existing notifications already had some kind of manually-built type in them.
This is now officially supported at the bus API.

In client code this will allow (to be done in future commits) to register one
handler per specific type, instead of having to iterate and to filter all
received notifications on every handler.

Payload
=======

Payload (ex message) did not change, it can still be anything depending on
business needs.

Few adaptations:
- When the type was included on the payload, the type has been moved to the new
  type parameter.
- When the channel was used in business code, its data has been copied into the
  payload.

task-1891151

closes odoo/odoo#79201

X-original-commit: 543af27c7d6836ffac9e80ff8490b6ddbd849221
Related: odoo/enterprise#21998
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-10-29 16:05:23 +00:00
Sébastien Theys 3a87aaf914 [IMP] mail, *: clean up message component by introducing view model
* = hr, hr_holidays, sms, snailmail, website_livechat

Message model incorrectly contained data related to a specific component (only
one) even though there can be multiple message components per message model.

This cascaded to adapting related component/models to the same principle.

closes odoo/odoo#76718

closes odoo/odoo#77779

Related: odoo/enterprise#20964
Related: odoo/enterprise#21426
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2021-10-05 15:40:49 +00:00
std-odoo 9183a86fde [REM] mail: remove "email_send" field on the mail channel
Purpose
=======

Remove the "email_send" field on the <mail.channel> (mass_mailing named
on the JS side).

This feature will be introduced with a new model (<mail.group>) in a
new module in the next commit.

Remove the email notification support on the channel, so now the mail
channels work only by chat.

Remove the "subject" on the Discuss side because this was used only on
"email" channel.

Technical
=========

In the mail channel model we can drop the usage of the blacklist as well
as the usage of the "email_to" field. Those two features were mainly
used for mailing list and have no utility for "chat like" channel.

Links
=====

Task-2510267
See odoo/odoo/pull/71599
See odoo/enterprise/pull/19296
See odoo/upgrade/pull/2600
2021-07-09 11:16:38 +00:00
Florent de Labarre 16a0427bc4 [FIX] website_livechat: error during closing livechat
During closing a livechat session an error occur :
_get_visitor_leave_message() got an unexpected keyword argument 'speaking_with'
Because argument 'speaking_with' is pass in this method https://github.com/odoo/odoo/blob/14.0/addons/im_livechat/models/mail_channel.py#L182, it should be operator.

closes odoo/odoo#70697

X-original-commit: 36866412483af80da812a38842e6df35b232190a
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-11 15:41:19 +00:00
Nicolas Seinlet 9a01a2953f [IMP] mail, im_livechat: inline sql instead of long id list
using inselect operator to inline sql in the search method and avoid ORM
to fetch multiple useless messages to check if there's one

closes odoo/odoo#70410

X-original-commit: 505c7b0946689d3ac1ac4dd2f59cf4d535c36cbb
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-05-05 12:40:29 +00:00
David Beguin 6d6a442ecd [FIX] website_livechat: ensure session data integrity during visitor lifecycle
This commit fixes two issues encountered during the visitor lifecycle.

1. When a visitor arrives on the website on a non tracked page, a
website.visitor is not created yet, but the visitor can still start a livechat
session. When navigating to a tracked page, a website.visitor is created but the
lifechat session already started is not recovered and the discussion is lost at
visitor's side. This commit links the already started livechat session to the
newly created visitor to ensure that the conversation can still continue
normally.

2. When a visitor logs in, his attributed visitor is linked to the partner. But
there can be only one visitor per partner. If there was already a visitor linked
to the partner, the later visitor's livechat session are updated with the
partner and the visitor is then deleted. But the visitor's livechat sessions are
not linked to the main partner visitor. So when looking at all the session the
partner had, we can only see the main visitor's livechat session.
This commit copy the livechat session of that later visitor to the main partner
visitor to ensure keeping the complete livechat history for each partner.

Task ID: 2460892

closes odoo/odoo#69402

X-original-commit: 4e1034ff2f08fa20bcdc9ac39eb2489d34a9715d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2021-04-16 14:11:34 +00:00
Thibault Delavallée e5338146e7 [REF] mail: make message belongs to a single thread without listener channels
RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

PURPOSE

Remove channel ability to follow records as it mainly adds noise without a lot
of added value. Simplify channel notification flow by using directly members
and not a delegation through a channel self-following trick. Remove followers
being channels and posting with added listeners being channels.

SPECIFICATIONS

In this commit we force messages to belong to a single document using
``model`` / ``res_id`` pair. It is not possible anymore to link a message
to channels using ``channel_ids``. A message belongs to a document and
is displayed in that document's chatter.

This change implies modifying a lot of domains, notably in chatter. Indeed
discuss for channels does not use ``('channel_ids', 'in', [3])`` domains.
They now use ``('model', '=', 'mail.channel'), ('res_id', 'in', [3])`` like
other documents fetching their messages.

This commit also removes ``channel_message_ids`` field on ``mail.channel``
model. As channels are now considered as standard documents they will use
``message_ids`` field like all other documents. Linking a channel on a message
is possible only as a link in message from now on. It is not possible to push
it into a channel anymore (no more listener channels, no more channel link).

Finally a global cleaning also linked to all previous commits is done.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:16:35 +00:00
Thibault Delavallée 62dc6a6173 [REF] mail, mass_mailing, hr, {(website_)im_/crm_}livechat: clean use of channel members in various code place
RATIONALE

Channel model is a mail.thread enabled model behaving strangely with followers,
notifications and discuss. Its code should however be simplified to be more
self contained and avoid unwanted side effects on other models.

SPECIFICATIONS

Purpose of this commit is to better differentiate channel members technical
model from partner members in code :

  * ``channel_partner_ids``: contacts member of a channel, filtering notably
    on active and checking ACLs on res.partner business model. This one
    should be used whenever we deal with members of a channel at business
    level;
  * ``channel_last_seen_partner_ids``: memberships of a channel and technical
    model. This one should be used for internal processes and members
    management;

Also containing

  * clean naming or API of methods managing channel members. This should
    not change anything functionally as only code renaming / cleaning is
    performed;
  * improve performances of channel member auto subscription by aggregating
    all members to add and creating them at once;
  * check the use of ``mail.channel.partner`` and ``res.partner`` records
    through ``channel_last_seen_partner_ids`` and ``channel_partner_ids``
    Channel fields;

Functionally nothing should change with this commit. It only cleans code
in order to prepare future modifications.

LINKS

Task ID-2070632 (main task)
Task ID-2419762 (followup task)
COM PR odoo/odoo#62859
ENT PR odoo/enterprise#15172
UPG PR odoo/upgrade#2005
2021-03-17 18:07:25 +00:00
Xavier Dubuc ce5588c85d [IMP] website_livechat: better field naming for visitor in channel_info
task-2345866

closes odoo/odoo#59848

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-10-20 11:53:16 +00:00
Xavier Dubuc 52dfe6a4e1 [IMP] mail, website_livechat: bring back visitor banner in discuss
task-2276589

closes odoo/odoo#58858

X-original-commit: 65dbe1c4760e2ffe104426f9aa41007a10dc32f0
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-09-29 17:39:13 +00:00
Alexandre Kühn 7a0aecfca9 [FIX] im_livechat, mail, website_livechat: open chat website visitor
Also fix an issue with livechats not being considered in 'chat'
filter of messaging menu.

Task-Id 2282426

closes odoo/odoo#58468

X-original-commit: 631e52536964763bbfe857305f023e5e67084e95
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-09-24 18:25:12 +00:00
Alexandre Kühn 8be77ece37 [FIX] im_livechat, mail, website_livechat: invite button in livechats
Task-2334724

closes odoo/odoo#57511

X-original-commit: 5316c91c27e48bfaa3ebf3fb97e35220fabc986e
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2020-09-11 11:07:12 +00:00
Didier (did) 467208f6e4 [FIX] website_livechat: missing decorator on message_post
Incorrect override of message_post.
Without this decorator, message_post returns a string `mail.message(ID,)` via
RPC. Discuss needs the message ID to scroll chat window

closes odoo/odoo#57123

X-original-commit: 3939d3aa3b60e0f606a9f7defd695417f7b3f383
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2020-09-04 17:26:24 +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 ba244cef01 [IMP] *: replace to new _() syntax
Using a few regex like
\((_\(.*%s.*)(\) % )([\w\[\]][\w .\[\]\(\)'"]*)\)
($1, $3))

Old syntax is still compatible but starts the migration to the new
syntax that catches error.
2020-06-18 13:03:34 +02:00
DramixDw 9b9829416b [IMP] website: simplify website menu
Some apps, once installed, automatically create a menuitem in website.
What complexify the UI and create useless menu withtout plusvalue.

It is not because you install livechat to make support online, that you want
a link in your menu to show stats e.g.

Now we remove the default menu created, and help user to find it when he create
a link. The autocomplete suggest most of the main App's controllers

task-2189613

closes odoo/odoo#49081

Related: odoo/enterprise#9733
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-05-01 07:59:07 +00:00
fja-odoo 388c222c6c [IMP] base, *: allow html fields not to sanitize forms
* = event, website_event_track, website_sale, website_hr_recruitment,
website_livechat, website_sale, website_slides

The option to sanitize or not the forms was not available, this will
allow better flexibility on whether forms should be sanitized or not on
an HTML field.
Also we use this new param to allow forms to be added on some already
existing html fields where forms where sanitized out.

task-2209554

closes odoo/odoo#47318

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-03-31 14:22:43 +00:00
Jeremy Kersten 4c40393490 [FIX] website: perf - translation - avoid query to find what we know
Before this commit, each module override _get_translation_frontend_modules_domain
from ir.http to add its own translation in website if needed and that module
is not starting by website_. Updating the domain from the super() call.
Since we know in most of the case the name, it is useless to do a:
   select name from module where name = 'name1' or name = 'name2'...

Now we support a new override of _get_translation_frontend_modules_name that will
allow to add the known module name directly in the list instead to make a search.

In case nobody override _get_translation_frontend_modules_domain, we don't need to
make an extra rpc to find the module.

Related to #47257
task-2211013

X-original-commit: 0dc54814161ab55c34dd2242f65dea23d19fdfca
2020-03-19 15:37:47 +00:00
David Beguin 190dab8144 [IMP] website_livechat : add various tests on livechat and visitors
Adds Python tests and javascripts tours on livechat (website and visitor
integration). Because breaking livechat every two days in rush periods
(or even not) is getting quite annoying.

Those tests are testing :

- The client side flow (open livechat, send messages,
  send rating and close the livechat session)
- The channel and message author naming, visitor page view history
- Chat request flow (complete chat request flow, open empty operator's
  chat request and cancel due to visitor's new chat session)

Task ID : 2079087
PR #40052

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-03-17 12:21:48 +00:00
David Beguin 20a7ae2657 [REF] im_livechat, website_livechat : move close livechat session to base module
In order to be able to flag the livechat as inactive when the visitor left the
conversation, livechat_active field is moved to im_livechat module, as it is
not linked to website_visitor.

This commit is also a preparation for next one, which will implement the close
conversation right after the first click on x button in livechat window (at
visitor side). We needed the livechat_active flag to be available without
website installed.

Task ID: 2120210
PR #39939
2020-02-12 16:06:22 +00:00
David Beguin 9c9032e664 [IMP] (im/website)_livechat : hide and clean empty livechat sessions
Purpose
=======

Whenever a visitor start a livechat session but finally close the session
without sending any messages, the livechat session is empty and stay in DB.
Livechat session counter counts all the sessions (with and without message)
but when opening the sessions tree view, the view is filtered by default on
session with messages. There is no reason to see the empty sessions as it
does not give any information (except "the visitor hesitated to start
livechat and finally did not" which is quite useless info)

The goal is to keep only sessions with messages.

When the visitor is closing the livechat window, if the session is empty,
the session should be deleted. But what happens if a visitor start a livechat
session, send no message and just leave the website without closing the
livechat window ? --> empty live chat session will remains in database.

The ir_autovacuum already handle the deletion of empty sessions to main a
clean DB.

Specifications
==============

- Apply 'with messages' domain on session count in the livechat channel view
- Apply 'with messages' domain on session count in the lead view
- Apply 'with messages' domain on livechat session view
- Remove With message filter
- Remove Without message filter

- If send message on a deleted session :
    just tell the visitor that operator is not available anymore
    AND delete livechat session cookie (as he waited 1 day to send a message)

Empty sessions becomes invisible : not possible for users to see empty session
(in count or in views) and cron is cleaning empty sessions every day.

This commit also adapts visitor session count and view accordingly.

Task ID: 2146962
PR #41065

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-02-10 11:46:05 +00:00
David Beguin 5b62f6e0b6 [IMP] website_livechat : enable chat request on all livechat enabled pages
Before this commit, only the tracked page can start the chat request at visitor
side. Which is a bit sad as the operator can send the visitor a chat request
but if the visitor goes on a non tracked page but has the opportunity to start
a livechat, the chat request won't reach the visitor.

This commit refactor the way a chat request is sent to the client side.
Instead of looking for a opened chat request on every page request,
the chat request information (if any opened) is added to the channel info
that are given to the Livechat button widget.

If the widget receives chat request infos, the widget set himself, before
starting, the cookie of the livechat session using the chat request
informations. Then, the conversation (from chat request) is automatically
loaded as any other opened chat session.

Task ID: 2081550
PR #40274

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-01-02 15:14:47 +00:00
Thibault Delavallée e2b33f460d [REF] mail, various: rename subtype parameter of message_post to subtype_xmlid
PURPOSE

Clean posting process and improve mail.message definition and comprehension.

SPECIFICATIONS

In order to be more explicit subtype parameter is renamed to subtype_xmlid.
It therefore clearly indicates it should be a valid subtype Xml ID. Support
of ill formatted Xml IDs is removed because there is no reason to try to
add some random prefix. Give something that exists or go to hell, punk !

LINKS

Task ID 2071556
PR #38692
2019-12-02 15:18:44 +00:00
Jeremy Kersten 3a7033463e [FIX] website: allow authenticate in json multidb
Before this commit launch a server with --db-filter that match at least 2 dbs name
Try to authenticate

You will have an error request is unbound when you try to access request.env

Now we retrieve the user from self instead of the request.

New test to ensure rpc authentication is tested.

Related to commit 245ef4b1

closes odoo/odoo#38969

X-original-commit: 4b3400c430bec7539aada0619fd203978daca2d8
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-10-17 15:35:11 +00:00
fja-odoo 950f252ba6 [FIX] website: rename user_partner_id -> partner_id
It is just a partner_id not a user related field

task-2072877

closes odoo/odoo#37102

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-10-01 19:50:00 +00:00
fja-odoo fe1dddb1ec [FIX] website: allow visitor sort by last visit time
A visitor needs to be sorted by last visit datetime, to do so we need to
remove the temp table and ignore concurrent updates.

task-2072877
2019-10-01 19:49:46 +00:00
David Beguin 4a37beeff6 [FIX] website_livechat : fix history in discuss visitor banner
Adding a string element to a list with += is not adding the element to the list
but is instead adding every single character of the string as an element to the list.
Building a string using a join method was resulting to an recent history displayed like
H > O > M > E > ( > 8 > : > 4 > 2 > )
--> Should be : HOME (8:42) > Contact Us (8:45)

Apart from that, since the tracking is now ordered by visit_datetime DESC,
to have a chronological order, we need to reverse the list of last visited pages
to have something like :
    Home (12:43) > About us (12:45) > Contact Us (12:52)
instead of :
    Contact Us (12:52) > About us (12:45) > Home (12:43)

Task ID: 2076190
PR #37340
2019-09-24 13:25:50 +00:00
David Beguin 33f5bbc7d0 [FIX] website_livechat, im_livechat : use visitor display name instead of name
As since 5b9a81a2c6
website.visitor.name can be null
if the visitor is not linked to a lead or a res.partner,
we cannot use the name anymore to build the name of the mail.channel, etc..
Using display_name will always return the correct value,
and will include the numbering of the visitor,
in order to identify easily the chat windows
(if operator is speaking with multi visitor at the same time)

Task ID: 2076190
PR #37340
2019-09-24 13:25:50 +00:00
David Beguin e6b5aae210 [FIX] website,website_livechat : restore chat request feature
since e33172e832,
a chat request could not be sent to a visitor as the website was not
set anymore on the visitor and the mail_channel could then not be
assigned to a livechat_channel (using the website_id).

This commit restore the feature using the new temporary model
website.visitor.lastconnection.

Task ID: 2056080
PR #36290
2019-09-17 14:12:22 +00:00
David Beguin 6f5abf933b [IMP] website,livechat : apply various imp and fix on visitor views
Applies various improvements:
  - Remove welcome message if chat request usecase.
  - If a visitor is online: line is green / if offline: line is red (in the list view)
  - Visitors list view: add first / last connection fields and remove time_since_last_action
  - Avoid useless leave notification if the livechat channel is empty

Fix
  - ACLS on website_visitor_page model (for im_livechat_group_user)
  - ACLS on website_visitor and website_visitor_page model (for sales_team.group_sale_salesman)
  - Update visitor lang if visitor change the website lang.
  - Create visitor twice when translated website (due to rerouting)
  - Avatar for visitor banner in discuss. (image_64 instead of old image_small)

Task ID: 2056080
PR #36290
2019-09-17 14:12:19 +00:00
fja-odoo e33172e832 [IMP] website_sale, *: keep track of products viewed
*= website, website_livechat, website_rating

///// Tracking Product /////

Now when a user browse products in eCommerce, we keep track of the
products he looked at. We use the website_visitor
to store the products viewed. A cookie is added with a TTl of 30 min it
will prevent the RPC for that time. We track the page only if the
product view is tracked.

The recently viewed products are displayed as a snippet but also
with the customize option in product pages of website_sale.

Products that are in cart will not be returned as recently viewed.

It is possible to add a recently viewed product to the cart directly
from the carousel, it will not redirect to the cart. If we are on the
cart page, the product is displayed in the cart.

The Visitor page in website now references products viewed

///// Tracking Page /////

Feature to track a view was remove in: https://github.com/odoo/enterprise/pull/4834

That feature is now reintroduced and will use website_track instead of
leads to be stored.

The track field is now on the view instead of the page.

url field is added to website.track, it will store the url for pages and
views

The Visitor page in website now references urls viewed

Add some tests

task-1984575

closes odoo/odoo#35810

Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2019-09-16 09:38:53 +00:00
David Beguin e74c6ef86a [FIX] website : fix visitor cookie expiration
Before this commit, the visitor cookie was expiring by default on
browser session close on firefox. On Chrome, the cookie was always
valid after browser session closing.

On Firefox, the expiration date must be set to make the cookie still valid
after closing the browser.

The same thing happened with livechat_session cookies set
in context of livechat request.

The cookie expiration date (100 years to 'never' expire) have been added.

Linked to original Task ID : 2028059

Task ID : 2060381
PR #36126

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-08-27 12:12:37 +00:00
David Beguin 78e6ce3c3f [IMP] website_livechat : allow to send chat request to a website_visitor
This commit allows a livechat operator to send a chat request to a
connected and available website_visitor.

A visitor is considered as connected if his last tracked website.page request
was within the last 5 minutes.
A visitor is available if he doesn't have an active livechat conversation
(mail_channel with type = livechat).
  - If another operator sent him a chat request
  - Or if the visitor asked himself to speak with an operator
    (via the normal and existing flow)

A livechat conversation is active while the visitor haven't left the conversation.
An operator cannot leave a livechat conversation, only the visitor can.

The flow to send a chat request:
  - On the visitor view (tree or form), operator click on 'send chat request'
    (button or livechat icon)
  - A empty conversation with the visitor pops up at operator side.
  - While the operator didn't send a message, the visitor won't see the conversation.
  - The operator can type a message to the user
  - If the operator close the chat without sending any messages,
    the chat request AND the mail_channel are both deleted.
    In this case, the visitor is then available to send him a new chat request.
  - If the operator send a message, at the visitor's next action
    (page navigation on pages that allows livechat, based on livechat rules),
    the conversation will pop up at visitor side, using the livechat button widget.
    The visitor won't be able to request a livechat conversation with an operator until
    he leaves the chat requested by the operator.
  - Once the visitor leaves (with or without rating) the conversation :
        - the operator is notified that the visitor has left the conversation
        - the chat request is deleted to keep the chat request table clean and minimal
        - the livechat conversation if set to inactive.
  - The visitor is now available again to send him a chat request.

This feature uses the already existing livechat_session cookie mechanism,
so no further code modification was needed to make this work.
It's directly integrated is existing livechat flow.

The chat_request model is only useful to quickly check if a visitor has a chat request
and to send the livechat conversation info to the visitor via the livechat_session cookie.

This commit also add a website_visitor banner info on discuss view :

To be able to quickly see all the relevant information of a website visitor
while talking with in discuss view, a fixed banner have been added.
Only the discuss view will benefit from this because detached chatter window
is to small to display such banner.

Task ID: 34624
PR #2028059
2019-08-19 06:33:37 +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
Christophe Simonis a97037c6d4 [MERGE] forward port branch saas-12.2 up to 78b3b650b0 2019-05-06 12:27:51 +02:00
Julien Castiaux 4ba4d61903 [FIX] website_livechat: load im_livechat i18n
As authenticated user, join the website livechat. As a portal user,
start a livechat. Close it, it asks you to review the chat but all
messages are displayed in english.

opw-1958819

closes odoo/odoo#32629

Signed-off-by: Julien Castiaux <Julien00859@users.noreply.github.com>
2019-04-12 08:02:41 +00:00