Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions multi_livechat/models/mail_channel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright 2021 Ivan Yelizariev <https://twitter.com/yelizariev>
# License MIT (https://opensource.org/licenses/MIT).
from odoo import api, fields, models
from odoo import api, fields, models, _
from odoo.exceptions import UserError, ValidationError

import logging

_logger = logging.getLogger(__name__)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New imports are not used...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed not used imports


ODOO_CHANNEL_TYPES = ["chat", "channel", "livechat", "group"]

Expand All @@ -21,16 +26,14 @@ def _prepare_multi_livechat_channel_vals(
):
return {
"channel_partner_ids": [(4, pid) for pid in partner_ids],
"public": "groups",
"group_public_id": self.env.ref("base.group_user").id,
"channel_type": channel_type,
"name": channel_name,
}

def _compute_is_pinned(self):
# TODO: make batch search via read_group
for r in self:
r.is_pinned = self.env["mail.channel.partner"].search_count(
r.is_pinned = self.env["mail.channel.member"].search_count(
[
("partner_id", "=", self.env.user.partner_id.id),
("channel_id", "=", r.id),
Expand All @@ -41,7 +44,7 @@ def _compute_is_pinned(self):
def _inverse_is_pinned(self):
# TODO: make batch search via read_group
for r in self:
channel_partner = self.env["mail.channel.partner"].search(
channel_partner = self.env["mail.channel.member"].search(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

[
("partner_id", "=", self.env.user.partner_id.id),
("channel_id", "=", r.id),
Expand Down