Commit Graph
65 Commits
Author SHA1 Message Date
Victor FeyensandThibault Delavallée f85387ef33 [IMP] mail(_*): limit usage of search
Purpose of this commit is to globally improve code performance by limiting
search impact by

  * adding limits when only first found record id used;
  * avoid unnecessary searches when record set can be filtered instead;
  * using cache when accessing ir.model;

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:04 +00:00
Xavier-Do fdaee845d5 [FIX] base: remove options parameters
Regarding previous commit, the option parameter can be removed
from _get_asset_content api, followed by a nice snowball effect.

Part-of: odoo/odoo#75248
2021-08-26 10:21:10 +00:00
Julien Mougenot 08bb6e2e50 [FIX] im_livechat: Convert external_lib assets
Before this commit: some assets in im_livechat have not been converted
to the new manifest asset declaration system.

This commit converts these assets.

closes odoo/odoo#69612

X-original-commit: b6e1945a20b69dfc7cf83cd4380e92d949665093
Related: odoo/enterprise#17851
Signed-off-by: Christophe Simonis <chs@odoo.com>
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2021-04-21 15:49:57 +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
3fea5b2136 [REF] mail, *: refactor messaging with OWL
This commit is a significant rewriting of client-side discuss, chatter,
chat window, and messaging menu using OWL. The behavior should be broadly
the same, with some slight functional changes here and there.

From a technical standpoint, the code of messaging is mainly organized in 2
main groups of modules:

- models, which are logical entities that depict the client-side state of
  messaging as a whole.
- components, which are in charge of displaying information from models.

This refactoring also introduces new JS guidelines regarding folder structure
(/static) and naming rules for JS modules.

Community PR: https://github.com/odoo/odoo/pull/39023
Enterprise PR: https://github.com/odoo/enterprise/pull/6249

Task-1914207

This PR is a collaborative work by Alexandre, Julien, Sébastien and Xavier,
with the precious help of Lucas to speed it up towards the end.

closes odoo/odoo#39023

Related: odoo/enterprise#6249
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Alexandre Kühn <aku@odoo.com>
Co-authored-by: Julien Giannone <jgi@odoo.com>
Co-authored-by: Lucas Perais <lpe@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Co-authored-by: Xavier Dubuc <xdu@odoo.com>
2020-06-15 18:12:21 +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
Thibault Delavallée 5649fc88e8 [REF] {website_}mail: move and replace published field of mail.message to is_internal
PURPOSE

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

SPECIFICATIONS

Website mail defines a website_published field allowing to publish / unpublish
comments on the frontend of some modules. This field has several drawbacks :

  * it is used only for front-end people (portal, public) and has no real
    effect in chatter / classic discussions;
  * it is used only in some advanced front-end module and is not available
    in portal by default;
  * its naming is not really correct as it is not linked to fields coming
    from the website_published mixin and its behavior is not really
    the same;
  * its use is a bit duplicated with internal flag coming from subtype
    allowing to hide messages related to an internal subtype;
  * there are overrides of standard mail.message methods just to handle
    this flag;

In this commit we change that field by an is_internal flag directly on
mail.message model itself. It tells if share people (customers, share users)
are allowed to read the message. This field can be given through posting
API or set manually using widgets. It is also used in access rights custom
methods and managed like the internal flag of subtypes.

Mailgateway was already using an internal flag for internal note replies. It
is renamed to is_internal and propagated as it is now a standard field. It
also eases code understanding.

Portal is updated to allow managing the flag directly. It means customer portal
now natively allows to moderate customer comments without any need of website
modules.

Rating is updated accordingly. An is_internal field is added, replacing the
related on website published.

LINKS

Task ID 2071556
PR #38692
2019-12-02 15:18:44 +00:00
Thibault Delavallée 69ccabb212 [FIX] mail: restrict access to mail.mail model
From now on mail.mail is considered as a technical model. Indeed people should
not really manually craft mails by hand. Instead various functional flows
should either send mails, either craft mails based on some user input.

We therefore make mail restricted to admin users. Flows creating mail.mail
are updated to use sudo, and ensure it was done in a context that makes
sense to delegate this power to the user.

Task ID 1853147
PR #32243
2019-11-29 13:35:14 +00:00
David Beguin 1832d17d21 [FIX] im_livechat, website_livechat: fix use visitor name in livechat session
im_livechat main controller was referring to website.visitor but this module is
not depending on website. The usage of website visitor's name should have been
done in website_livechat module.

This commit fix this issue.

Task ID: 2116715
PR #40732

closes odoo/odoo#40884

X-original-commit: defb98c1083e55ff02f290c3c6257a4ca8dc7d1f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-11-22 16:32:19 +00:00
David Beguin 8d359aa5a5 [FIX] livechat : use visitor name when visitor start livechat
If the visitor starts a livechat session, his anonymous name was 'Visitor'.
Since visitor info are now stored, we can use the visitor name instead, if a visitor
can be retreived.

Task ID: 2076656
PR #37511
2019-09-30 15:54:48 +00:00
David Beguin 013128699d [FIX] im_livechat : fix send feedback from livechatter.
This commit fixes the send feedback by creating explicitely the
rating.
Before, we gave to the mail channel the rating values.
But as rating uses res_id and res_model, creating the rating
directly with correct values in res_id and res_model makes the magic.
The rating is correctly linked to the mail channel.

Task ID: 2076190
PR #37340
2019-09-24 13:25:50 +00:00
Christophe Simonis 5a273e74f0 [MERGE] forward port branch saas-12.4 up to fe59754c52
closes odoo/odoo#36721

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-09-13 13:32:51 +00:00
Christophe Simonis 545e6d2034 [MERGE] forward port branch 12.0 up to 52f6e38cea 2019-08-30 17:20:28 +02:00
Christophe Simonis 12e9613f96 [MERGE] forward port branch saas-11.3 up to 668c360e32 2019-08-21 18:26:18 +02:00
Christophe Simonis 668c360e32 [MERGE] forward port branch 11.0 up to 1b234b1be7 2019-08-21 16:58:16 +02:00
Lucas Perais (lpe) 5e3d49bc47 [FIX] im_livechat: livechat rating computes well
Open a livechat session between a visitor and a user
That is, open the / controller as public user, and click,
on the bottom right corner, on "Have a question ? Chat with us."
Exchange at least one message to open the session

From the visitor side, close the window. There is a proposal to rate the discussion
Assign either the green face or the yellow one
(The red one is a bit trickier)

Now, on the user side, check the list view of LiveChat sessions

Before this commit, the rating of those sessions were 0
This is because:
The rating.rating < Many2One > mail.channel link is not a foreign key
(rather, it is composed by char::res_model; Integer::res_id)
and doesn't make the reciprocal field recompute, which in turn doesn't make
our relevant field compute

After this commit, the last_rating field field is recomputed and appear in the list view

OPW 2052964

closes odoo/odoo#35830

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
2019-08-20 08:12:32 +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
mgh-odoo 737746c05c [IMP] im_livechat: allow visitors to get a transcript of their live chat
after this commit user can get a copy of the conversation with operator

task-2029660
closes #34620

closes odoo/odoo#35083

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-08-14 12:25:12 +00:00
Raphael Collet caf900e89e [FIX] *: use auth='public' in controllers that use request.env
The following trick used to work, because `sudo()` was actually making
an environment for the superuser to operate upon:

request.env[...].sudo().method(...)

It no longer works in general, since `sudo()` now makes an environment
in superuser mode but with `uid=None`!  It may still work by accident
for operations that never use `env.uid`, but is broken in general.

Using `auth='public'` fixes the problem by using the public user when no
user is available.

closes odoo/odoo#34297

Signed-off-by: Olivier Dony (odo) <odo@openerp.com>
2019-07-04 11:32:22 +00:00
Aurélien Warnon 594c6e8a2a [IMP] im_livechat: ensure that visitors always gets the same operator
Task #1919871

Purpose
=======

If a visitor comes on the website and launches a livechat, it will be randomly assigned operator A.
If he comes the next day and opens a livechat again, we want him to have the same operator if he's available.

To handle that use case, we added a cookie that stores the "previous operator id" information for 7 days.
2019-04-01 07:03:11 +00:00
Aurélien Warnon c04b9c019e [REF] im_livechat: rework some 'im_livechat.channel' model methods
Purpose
=======

Several methods of the 'im_livechat.channel' model were passed a 'channel_id' to work on.
This has been changed so that the caller can use those methods on an instance of this model instead.

Some methods have also been switched to private because they had no apparent reasons to be public.

This is a preliminary cleaning for task #1919871

Specicial note for the "loader" template:
To load the livechat assets in a website page, the 'loader' template of livechat
is directly called (instead of being returned through a controller) in order
to avoid a new call to server.
As this commit moves 'sudo' to make method callable on the record directly, it
still needs to be sudo. First solution was to add the 'sudo' in the template, which
is a bad practise.
This commit creates a proxy method on website model returning the livechat info
with 'sudo'. This avoid having the 'sudo' done in template. Like always, explicit
is better than implicit.

Task-1919871
2019-04-01 07:03:11 +00:00
Martin Geubelle 7abeaf56b3 [REF] im_livechat, *: remove JSONP in favor of CORS
When embedding the livechat on an external website, we used to make JSONP calls.
As the support of JSONP calls has been dropped, we now use the CORS mechanism
instead.
2019-02-13 09:38:30 +00:00
7d85ab1eac [REF] base, *: refactor binary_content
*: tools, web, website, website_forum, mail, im_livechat

This commit refactors ir_http to make it more readable
and flexible.

Move the resize function of web/image to odoo.tools

Co-authored-by: XavierDo <xdo@odoo.com>
Co-authored-by: Antony Lesuisse <al@openerp.com>

closes: #28563
task: #1908896
2018-12-06 19:09:33 +00:00
David Beguin 2986a5a412 [IMP] im_livechat : add measures to channel report to be used in Dashboard
Adds some indicators in channel report in order to use them in the new
enterprise livechat dashboard. Those indicator are added here to re-use
directly the channel report view. It allows the users to use also those
new indicators in the existing reports.

- No answer indicator
- Days of activity indicator
- Day number indicator
- Country of visitor :
    This makes able to see from which country comes the visitors
    and make statistics with it.

    If no GeoIP server are installed, or if the country is not found,
    or if visitor is logged in but has no country configured, the country
    si set to 'Unknown'.

Also, align sessions and operator report title on menu name

Task ID : 1895998
Closes PR #28283
2018-12-05 14:37:13 +00:00
David Beguin 8c8f219b47 [IMP] im_livechat : uses anonymous name only if visitor is anonymous
Before, if the visitor was logged in, anonymous name = user.name.
But if we use anonymous name field even if visitor is not anonymous,
we cannot know, in stat e.g., if the session was really made with
an anonymous visitor or not as the field is always filled in.

Now, if the visitor is not anonymous, we use directly the user.name
but we do not fill in the anonymous name. So that if anonymous name
is null, we know afterwards that the session was made we a real
anonymous visitor.

Since the anonymous name is empty if visitor is logged in,
we cannot use anonymous_name anymore to get the title of the session window.

Task ID : 1895998
Closes PR #28283
2018-12-05 14:37:10 +00:00
Alexandre Kühn 5f1d32f3fb [IMP] mail, im_livechat: 'is typing...' indicator on mail channels
With this commit, most threads show an indicator when a member is typing
something. e.g.

	"Mitchell Stephens is typing..."

Supported threads:

	- DM
	- (public & private) channels
	- Livechat (Website & Backend)

Unsupported threads:

	- mailboxes (e.g. 'Inbox')
	- document thread (= 'Chatter')
	- support channel (with `im_support` module)

Some technical details:

	- This is a mix between 'start'/'stop' and 'regular notify' strategies.
	- On typing text in composer: notify 'start typing' to all members of
	  thread.
	- On clearing text in composer: notify 'stop typing' to all members of
	  thread.
	- A member can only notify once every 2.5 seconds to the server when he
	  starts or stops typing something (throttled, buffered notify call).
	- On receiving a message from someone that is typing: determine that he is
	  no longer typing.
	- On non-empty and unchanged composer text for 5.0 seconds: automatically
	  notifies all members of thread that he is no longer typing anything.
	  (This is like a 'soft / cooperative sender' timeout).
	- On non-receiving a typing notification of someone after 60 seconds:
	  determine that he is not longer typing something (This is like a
	  'hard / receiver assumption' timeout).
	- When some types for more than 50 seconds straight: notify that he is
	  still typing something (again and again every 50 seconds).
	- When two or more people are typing something (Multi-User channels), it
	  displays at most 2 typing users (ordering rule: longer typers first):

	  	"Mitchell Stephens, Marc Brown and more are typing..."

	- Timing summary:

		- Usually 2.5 seconds uncertainty.
    	- Up to 5.0 seconds uncertainty on typer inactivity.
    	- Up to 60 seconds uncertainty on typer page reload / browser tab
    	  closed / etc.

Future Improvements:

	- Detect page reload or browser tab close with loose of longpolling
	  connection

Task-ID 28188
2018-08-13 14:17:40 +02:00
Christophe Simonis 68326b15f9 [MERGE] forward port branch 11.0 up to c5ed372970 2018-06-21 12:18:40 +02:00
Christophe Matthieu 9cd982bcc8 [FIX] qweb: use cdn for asset files
Refactoring of qweb to call _post_processing_att for each nodes. This
change remove the crappy ovewrite in website module. The website overwrite
only the _post_processing_att to add the cdn parameters.

The static node (without t- attributes) can stay static (remove overwrite
of _is_static_node), the cdn is applied at the compile time for this
nodes instead of at the running time like the dynamic node.
2018-06-15 08:42:15 +02:00
Christophe Simonis 4aa5ec3fa5 [MERGE] forward port branch 11.0 up to d67b410dfc 2018-03-07 18:46:38 +01:00
Lucas Perais (lpe) cf5142e059 [FIX] im_livechat: make /history command work for public user
Have the public user (not logged in -- user B) having a live chat with any logged in user (user A)
Having in mind that:
- (A) issues /history in his chatter to see where (B) has gone on the website
- The bus sends a kind of a "pull cookie request" on each clients
- The browser of (B) retrieves the cookie info and calls the relevant route
- That route sends the transient message for (A)

Before this commit:
The command did not work because the user of the route we end up on is the public one
hence, the search for the channel would not yield anything

After this commit:
The command does work as expected

OPW 1818732
closes #23485
2018-03-07 09:12:47 +01:00
Thibault Delavallée 1fbc29a641 [MOV] base: move ir_* models into models/ 2017-11-27 11:15:03 +01:00
Christophe Simonis bd08d4f052 [MERGE] forward port branch saas-16 up to 3ac2a1106c 2017-09-11 14:02:19 +02:00
Christophe Simonis 3ac2a1106c [MERGE] forward port branch saas-15 up to ec15765eec 2017-09-11 13:30:03 +02:00
Christophe Simonis ec15765eec [MERGE] forward port branch saas-14 up to 48f88992da 2017-09-11 12:35:49 +02:00
Nicolas Martinelli 6879409723 [FIX] im_livechat: unsupported locale
- Set the browser to language 'Spanish (Latin America)' ('es-419')
- As a public user, open a livechat session.

The session doesn't open.

The root cause is the creation of a mail channel which contains
translatable fields (e.g. name). This attempts to create translations
in the 'es_419' language. However, this locale doesn't exist in Odoo,
and it triggers the constraint 'lang_fkey_res_lang'.

In this specific case, there is no real reason to translate the channel
name. Therefore, we simply avoid it thanks to a context key.

opw-766489
2017-09-07 15:54:26 +02:00
Rohan Patel cc6fc799a6 [IMP] im_livechat: set the 'rater' partner
If user is logged (example: portal user), set the
partner_id on rating.
2017-07-10 08:49:22 +02:00
xmo-odoo b4429c2a91 [FIX] Various P3-related import changes
* LDAP import: python-ldap is not python3-compatible, pyldap is

  Warning: only supported from debian Stretch (current testing)?
  https://packages.debian.org/search?searchon=names&keywords=pyldap

* implicitly relative imports
* imports of moved or removed stdlib modules

issue #8530
2017-04-28 09:06:53 +02:00
Sagar Ahirrao bb03449bc8 [IMP] im_livechat: visitor history command
this commit introduces the '/history' command
for an operator during a livechat session.

When the visitor load a page, its url is added in
a cookie (kept only 1 day) in order to track his
visited web pages.
The '/history' command will ask the cookie content
and send it to the operator as a transient message
in the livechat channel.
2017-01-30 13:45:03 +01:00
Rohan Patel 7b7995e301 [IMP] im_livechat: give res_model_id instead of res_model submit rating 2017-01-24 09:02:10 +01:00
Jérome Maes 567ae3137f [IMP] rating,livechat: better use of rating mixin
- use rating.mixin field instead of rating_ids to
display rating on form view
- clean controller method
- ...
2017-01-09 16:19:26 +01:00
Jérome Maes 8cac9d664c [FIX] im_livechat: stop using unsecure controller
Loading history can contains sensitive informations.
You can load the history of a public conversation if
you have its uuid.

This commit stops using unsecure controller when a
secure one for this case exists !
2016-11-16 16:12:52 +01: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
Fabien Pinckaers 9bf9eb863b [FIX] rating: correct list view (list --> tree)
[FIX] livechat_rating: ratings from livechat should be consumed
(otherwise invisible)
[IMP] usability: better views and tooltips
2016-07-15 15:13:17 +02:00
Christophe Matthieu 70a69bf9bc [FIX] website/im_livechat: use new api to get asset
Issue: can't get asset content, self don't have env attribute, wrong attributes send.
2016-07-05 18:44:58 +02:00
Christophe Matthieu f1e3ac88f8 [FIX] ir_qweb/website: must adapt AssetsBundle call to nex new syntax
AssetsBundle receive the files list instead of to load the xml content itself (speed up because the file list is cached).
2016-07-05 11:31:03 +02:00
Denis Ledoux ddd3e08fbc [FIX] im_livecat: HttpRequest.render returns a Response
This revision is related to 100d604cb0

The above revision aimed to add the correct `content-type` headers,
the according route returning Javascript and not simple html.

HttpRequest.render` returns a Response,
and `make_response` doesn't expect a Response as first argument.

In other words, this is not possible to make Reponse from a Response.

`HttpRequest.render` accepts kwargs, including `headers`.

opw-666898
2016-01-15 16:37:30 +01:00
Christophe Simonis 100d604cb0 [FIX] im_livechat: correct loader js code 2016-01-07 18:16:20 +01:00
Aaron Bohy 21e2e85790 [FIX] bus,im_livechat: correctly detect livechat availability 2015-12-28 12:48:46 +01:00
Aaron Bohy d8605b7993 [FIX] im_livechat: matching rule in cache
The problem was that the matching rule was evaluated before sending the html
page, and the script was inserted in the page according to the matching rule
(it wasn't inserted if the rule was 'hide_button'). However, the matching rule
wasn't re-evaluated if the page was already in the cache. The page content thus
might depend on a matching rule computed for someone else in that case.

Rather than inserting the script according to the matching rule, we insert it
only if there is an operator available. We then ask for the matching rule in
the livechat widget, by RPC, and we reject its willStart deferred if the rule
says so. We also re-check for operator availability in the same RPC.
2015-12-24 12:59:46 +01:00
Aaron Bohy c58c8f4bd2 [FIX] im_livechat: use correct url to find rules that apply
The problem was that, when calling 'match_rules()' from the loader template,
we compared the wrong url with the url regexp defined in rules. Indeed, we used
the url of the page we were leaving, not the one we were going to.

We thus need to know if we are coming from the controller, or from the loader
template directly as the way to get the correct url differs.

Courtesy of JEM
2015-12-16 15:48:43 +01:00