Skip to content

Commit

Permalink
[MIG] portal_backend: Migration to 16.0 (vib)
Browse files Browse the repository at this point in the history
  • Loading branch information
vib-adhoc committed May 16, 2023
1 parent a0c073c commit d984484
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions portal_backend/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# directory
##############################################################################
from . import res_users
from . import ir_attachment
from . import ir_http
from . import mail_thread
from . import mail_activity_mixin
15 changes: 15 additions & 0 deletions portal_backend/models/ir_attachment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import api, models


class IrAttachment(models.Model):
_inherit = 'ir.attachment'

@api.model
def check(self, mode, values=None):

""" Portal users are not allow to access to attachments
"""
if self.env.user.has_group('portal_backend.group_portal_backend'):
super(IrAttachment, self.with_context(portal_bypass=True)).check(mode, values)
else:
super(IrAttachment, self).check(mode, values)
19 changes: 9 additions & 10 deletions portal_backend/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ class ResUsers(models.Model):

_inherit = 'res.users'

# @api.model
# def systray_get_activities(self):
# """ We did this to avoid errors when use portal user when the module "Note" is not a depends of this module.
# Only apply this change if the user is portal.
# """
# import pdb;pdb.set_trace()
# if self.env.user.has_group('portal_backend.group_portal_backend') and self.env['ir.module.module'].sudo().search(
# [('name', '=', 'note')]).state == 'installed':
# self = self.sudo()
# return super().systray_get_activities()
@api.model
def systray_get_activities(self):
""" We did this to avoid errors when use portal user when the module "Note" is not a depends of this module.
Only apply this change if the user is portal.
"""
if self.env.user.has_group('portal_backend.group_portal_backend') and self.env['ir.module.module'].sudo().search(
[('name', '=', 'note')]).state == 'installed':
self = self.sudo()
return super().systray_get_activities()

def _is_internal(self):
self.ensure_one()
Expand Down
4 changes: 3 additions & 1 deletion portal_backend/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ access_ir_fields_portal,ir.model.fields.portal,base.model_ir_model_fields,portal
access_ir_groups,ir.model.groups.portal,base.model_res_groups,portal_backend.group_portal_backend,1,0,0,0
access_ir_model_data_portal,ir.model.model.data.portal,base.model_ir_model_data,portal_backend.group_portal_backend,1,0,1,0
access_ir_attachment_portal,ir_attachment.portal,base.model_ir_attachment,portal_backend.group_portal_backend,1,0,0,0
access_mail_activity_portal,mail.activity.portal,mail.model_mail_activity,portal_backend.group_portal_backend,1,0,1,0
access_mail_activity_type_portal,access_mail_activity_type_portal.portal,mail.model_mail_activity_type,portal_backend.group_portal_backend,1,0,0,0
access_mail_channel_portal,mail.group.portal,mail.model_mail_channel,portal_backend.group_portal_backend,1,0,1,0
calendar_attendee_portal_backend,calendar.attendee.portal.backend,calendar.attendee,portal_backend.group_portal_backend,1,0,0,0
access_mail_followers_portal,mail.followers.portal,mail.model_mail_followers,portal_backend.group_portal_backend,1,0,0,0
access_mail_message_subtype_portal,mail.message.subtype.portal,mail.model_mail_message_subtype,portal_backend.group_portal_backend,1,0,0,0

0 comments on commit d984484

Please sign in to comment.