Commit Graph
9 Commits
Author SHA1 Message Date
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
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
Thibault Francois 7f10e89d21 [IMP] crm_livechat: add country from visitor to lead
Issue
-----
Automatic assignation assign leads mostly based on country.
So far the country need to be set manually on the lead.

Solution
--------
Since we have the information on the website vistor
works, set the country on the lead from the visitor
website. Unless the visitor is link to a partner
with a country. In that case setting a country
will cancel the address sync from the partner to the lead.

closes odoo/odoo#59575

X-original-commit: eff2b357db179e6e62f3db58ca2d90cc61c3748f
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2020-10-09 08:21:23 +00:00
Martin Trigaux 6156f98288 [FIX] *: adapt action content retrieval
Use _for_xml_id to replace all the self.env.ref().read()[0]
This has the advantage of having a single point of control and to add
the fields filtering and model verification.

Add sudo for other operations on ir.actions.*
2020-08-17 09:09:02 +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 dc101d12a5 [IMP] website_crm_livechat : link visitor to lead on /lead command
If an operator executes the /lead commands, the visitor was not linked to the
lead. This commit fixed that. The visitor is now linked to the lead but the
visitor does not take the lead's name.
(As '/lead leadName' creates a lead with 'leadName' as name but not as contact
name and the visitor needs the contact name of the lead)

Task ID: 2081534
PR #38706

closes odoo/odoo#41960

X-original-commit: 8c257a6219f72118af4e81c14fb2c6c9f320df17
Signed-off-by: David Beguin <dbeguin@users.noreply.github.com>
2019-11-20 13:33:08 +00:00
David Beguin 75dc514955 [FIX] website_crm_livechat : restrict livechat sessions to livechat users
Only the livechat users can see the livechat sessions linked to the lead.

Task ID: 2081534
PR #38706

X-original-commit: 3ae0f1564cb64afc7c2d9be6a427b75e0f13acd0
2019-11-20 13:33:05 +00:00
David Beguin 3cd5107316 [ADD] website_crm_livechat : add sessions stat button on lead form view
To ease the marketing and lead follow up, a stat button about
livechat sessions of the lead (that comes from the website_visitor model)
is added to the crm.lead form view.

This button displays and redirect to a list of all the sessions
from all the visitors related to the lead.

Task ID : 2057428
PR #36180

Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
2019-09-11 14:12:07 +00:00