Skip to content

Commit

Permalink
[MIG] portal_backend: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-zanotti committed Dec 20, 2022
1 parent b74d702 commit f149346
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 8 deletions.
2 changes: 1 addition & 1 deletion portal_backend/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:alt: License: AGPL-3

==============
POrtal Backend
Portal Backend
==============

This module is for generated an environment to be able to use portal users in backend.
Expand Down
6 changes: 4 additions & 2 deletions portal_backend/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
##############################################################################
{
'name': 'Portal Backend',
'version': "15.0.1.0.0",
'version': "16.0.1.0.0",
'category': 'Base',
'sequence': 14,
'summary': '',
Expand All @@ -32,9 +32,11 @@
'portal',
],
'data': [
'views/base_menus.xml',
'views/base_security.xml',
'security/ir.model.access.csv',
],
'installable': False,
'installable': True,
'auto_install': False,
'application': False,
}
2 changes: 1 addition & 1 deletion portal_backend/controllers/portal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from odoo import http
from odoo.addons.portal.controllers.web import Home as PortalHome
from odoo.addons.web.controllers.main import Home
from odoo.addons.web.controllers.home import Home
from odoo.http import request


Expand Down
4 changes: 0 additions & 4 deletions portal_backend/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from odoo.http import request
from odoo.tools import ustr

from odoo.addons.web.controllers.main import HomeStaticTemplateHelpers


class Http(models.AbstractModel):
_inherit = 'ir.http'
Expand All @@ -19,13 +17,11 @@ def session_info(self):
# but is still included in some other calls (e.g. '/web/session/authenticate')
# to avoid access errors and unnecessary information, it is only included for users
# with access to the backend ('internal'-type users)
qweb_checksum = HomeStaticTemplateHelpers.get_qweb_templates_checksum(debug=request.session.debug, bundle="web.assets_qweb")
menus = request.env['ir.ui.menu'].load_menus(request.session.debug)
ordered_menus = {str(k): v for k, v in menus.items()}
menu_json_utf8 = json.dumps(ordered_menus, default=ustr, sort_keys=True).encode()
session_info['cache_hashes'].update({
"load_menus": hashlib.sha512(menu_json_utf8).hexdigest()[:64], # sha512/256
"qweb": qweb_checksum,
})
session_info.update({
# current_company should be default_company
Expand Down
6 changes: 6 additions & 0 deletions portal_backend/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ def systray_get_activities(self):
[('name', '=', 'note')]).state == 'installed':
self = self.sudo()
return super().systray_get_activities()

def _is_internal(self):
self.ensure_one()
if self.has_group('base.group_portal'):
return True
return super()._is_internal()
1 change: 1 addition & 0 deletions portal_backend/security/ir.model.access.csv
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ access_ir_groups,ir.model.groups.portal,base.model_res_groups,base.group_portal,
access_ir_model_data_portal,ir.model.model.data.portal,base.model_ir_model_data,base.group_portal,1,0,1,0
access_ir_attachment_portal,ir_attachment.portal,base.model_ir_attachment,base.group_portal,1,0,0,0
access_mail_activity_type_portal,access_mail_activity_type_portal.portal,mail.model_mail_activity_type,base.group_portal,1,0,0,0
access_mail_channel_portal,mail.group.portal,mail.model_mail_channel,base.group_portal,1,0,1,0
6 changes: 6 additions & 0 deletions portal_backend/views/base_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="base.menu_management" model="ir.ui.menu">
<field name="groups_id" eval="[Command.link(ref('base.group_user'))]"/>
</record>
</odoo>
19 changes: 19 additions & 0 deletions portal_backend/views/base_security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<!-- The record rule res_partner_rule_private_employee is no updatetable so we need to temporarily set the noupdate field to False -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data">
<value eval="[('module', '=', 'base'), ('name', '=', 'res_partner_rule_private_employee')]"/>
</function>
<value eval="{'noupdate': False}" />
</function>
<!-- Add Portal group -->
<record id="base.res_partner_rule_private_employee" model="ir.rule">
<field name="groups" eval="[Command.link(ref('base.group_portal'))]"/>
</record>
<!-- Set the previously noupdate False to True again -->
<function name="write" model="ir.model.data">
<function name="search" model="ir.model.data"><value eval="[('module', '=', 'base'), ('name', '=', 'res_partner_rule_private_employee')]"/></function>
<value eval="{'noupdate': True}" />
</function>
</odoo>

0 comments on commit f149346

Please sign in to comment.