Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi_livechat: change mail.channel.partner to mail.channel.member #461

Open
wants to merge 3 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions multi_livechat/models/demo/mail_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ class MailChannel(models.Model):
channel_type = fields.Selection(
selection_add=[("multi_livechat_echo_demo", "ECHO (Demo)")],
ondelete={"multi_livechat_echo_demo": "cascade"},
readonly=False,
yelizariev marked this conversation as resolved.
Show resolved Hide resolved
)
17 changes: 12 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,17 @@ 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,
# "public": "groups", # V16 dropout public field
"group_public_id": False, # V16 checks contrains with group_public_id self.env.ref("base.group_user").id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Field public is removed in v16 -> ok

Field group_public_id is computed in v16 with readonly=False. Maybe just remove the field from result?

https://github.com/odoo/odoo/blob/ef8a9cf01e67f518d85e30221a596372c358a65c/addons/mail/models/mail_channel.py#L196-L201

Copy link
Author

Choose a reason for hiding this comment

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

I remove Field group_public_id, and it's working after I tested it.

"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(
# V16 change mail.channel.partner to mail.channel.member
r.is_pinned = self.env["mail.channel.member"].search_count(
yelizariev marked this conversation as resolved.
Show resolved Hide resolved
[
("partner_id", "=", self.env.user.partner_id.id),
("channel_id", "=", r.id),
Expand All @@ -41,7 +47,8 @@ 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(
# V16 change mail.channel.partner to mail.channel.member
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
1 change: 1 addition & 0 deletions multi_livechat/views/mail_channel_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<field name="arch" type="xml">
<xpath expr="//field[@name='description']" position="before">
<field name="is_pinned" />
<field name="channel_type" />
</xpath>
</field>
</record>
Expand Down