Skip to content

Commit

Permalink
[MIG] impersonate_login: migration to V15
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed Jan 27, 2025
1 parent 3c5682f commit 68a2703
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 171 deletions.
12 changes: 6 additions & 6 deletions impersonate_login/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Impersonate Login
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5b81c79d20d3679798c2f35fe1c7dc4cbe88abe7567ee2f21f05f63ff34c0bd2
!! source digest: sha256:501ad96751e358edef9d921d3cd01157ee6f2d22e37e4b576d135d77b3616f00
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand All @@ -17,13 +17,13 @@ Impersonate Login
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github
:target: https://github.com/OCA/server-auth/tree/14.0/impersonate_login
:target: https://github.com/OCA/server-auth/tree/15.0/impersonate_login
:alt: OCA/server-auth
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/server-auth-14-0/server-auth-14-0-impersonate_login
:target: https://translation.odoo-community.org/projects/server-auth-15-0/server-auth-15-0-impersonate_login
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/server-auth&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -66,7 +66,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/server-auth/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20impersonate_login%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/server-auth/issues/new?body=module:%20impersonate_login%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -108,6 +108,6 @@ Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-Kev-Roche|

This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/14.0/impersonate_login>`_ project on GitHub.
This module is part of the `OCA/server-auth <https://github.com/OCA/server-auth/tree/15.0/impersonate_login>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
11 changes: 6 additions & 5 deletions impersonate_login/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "Impersonate Login",
"summary": "tools",
"version": "14.0.1.0.1",
"version": "15.0.1.0.0",
"category": "Tools",
"website": "https://github.com/OCA/server-auth",
"author": "Akretion, Odoo Community Association (OCA)",
Expand All @@ -18,15 +18,16 @@
"mail",
],
"data": [
"views/assets.xml",
"views/res_users.xml",
"views/impersonate_log.xml",
"views/res_config_settings.xml",
"security/group.xml",
"security/ir.model.access.csv",
],
"qweb": [
"static/src/xml/user_menu.xml",
],
"assets": {
"web.assets_backend": [
"impersonate_login/static/src/js/user_menu.esm.js",
],
},
"pre_init_hook": "pre_init_hook",
}
1 change: 0 additions & 1 deletion impersonate_login/models/impersonate_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class ImpersonateLog(models.Model):

user_id = fields.Many2one(
comodel_name="res.users",
string="User",
)
impersonated_partner_id = fields.Many2one(
comodel_name="res.partner",
Expand Down
8 changes: 6 additions & 2 deletions impersonate_login/models/res_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ def impersonate_login(self):
request.session, request.env
)

# reload the client;
# reload the client; open the first available root menu
menu = self.env["ir.ui.menu"].search([("parent_id", "=", False)])[:1]
return {
"type": "ir.actions.client",
"tag": "reload",
"params": {"menu_id": menu.id},
}

@api.model
Expand Down Expand Up @@ -122,8 +124,10 @@ def back_to_origin_login(self):
f"Logout as {self._get_partner_name(self._uid)}"
)

# reload the client;
# reload the client; open the first available root menu
menu = self.env["ir.ui.menu"].search([("parent_id", "=", False)])[:1]
return {
"type": "ir.actions.client",
"tag": "reload",
"params": {"menu_id": menu.id},
}
9 changes: 5 additions & 4 deletions impersonate_login/static/description/index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Expand Down Expand Up @@ -367,9 +368,9 @@ <h1 class="title">Impersonate Login</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:5b81c79d20d3679798c2f35fe1c7dc4cbe88abe7567ee2f21f05f63ff34c0bd2
!! source digest: sha256:501ad96751e358edef9d921d3cd01157ee6f2d22e37e4b576d135d77b3616f00
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/14.0/impersonate_login"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-14-0/server-auth-14-0-impersonate_login"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/server-auth/tree/15.0/impersonate_login"><img alt="OCA/server-auth" src="https://img.shields.io/badge/github-OCA%2Fserver--auth-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/server-auth-15-0/server-auth-15-0-impersonate_login"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/server-auth&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module allows one user (for example, a member of the support team)
to log in as another user. The impersonation session can be exited by
clicking on the button “Back to Original User”.</p>
Expand Down Expand Up @@ -415,7 +416,7 @@ <h1><a class="toc-backref" href="#toc-entry-2">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/server-auth/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20impersonate_login%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/server-auth/issues/new?body=module:%20impersonate_login%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -447,7 +448,7 @@ <h2><a class="toc-backref" href="#toc-entry-6">Maintainers</a></h2>
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainer</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/Kev-Roche"><img alt="Kev-Roche" src="https://github.com/Kev-Roche.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/14.0/impersonate_login">OCA/server-auth</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/server-auth/tree/15.0/impersonate_login">OCA/server-auth</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
23 changes: 0 additions & 23 deletions impersonate_login/static/src/css/navbar.scss

This file was deleted.

18 changes: 0 additions & 18 deletions impersonate_login/static/src/js/abstract_web_client.js

This file was deleted.

45 changes: 45 additions & 0 deletions impersonate_login/static/src/js/user_menu.esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/** @odoo-module **/
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import {_t} from "@web/core/l10n/translation";
import {registry} from "@web/core/registry";
import {session} from "@web/session";

export function impersonateLoginItem(env) {
return {
type: "item",
id: "impersonate_login",
description: _t("Switch Login"),
hide: session.impersonate_from_uid || !session.is_impersonate_user,
callback: async function () {
const actionImpersonateLogin = await env.services.orm.call(
"res.users",
"action_impersonate_login"
);
env.services.action.doAction(actionImpersonateLogin);
},
sequence: 55,
};
}

export function impersonateBackLoginItem(env) {
return {
type: "item",
id: "impersonate_back",
description: _t("Back to Original User"),
hide: !session.impersonate_from_uid,
callback: async function () {
const actionBackToOriginLogin = await env.services.orm.call(
"res.users",
"back_to_origin_login"
);
env.services.action.doAction(actionBackToOriginLogin);
},
sequence: 55,
};
}

registry
.category("user_menuitems")
.add("impersonate_login", impersonateLoginItem, {force: true})
.add("impersonate_back", impersonateBackLoginItem, {force: true});
66 changes: 0 additions & 66 deletions impersonate_login/static/src/js/user_menu.js

This file was deleted.

22 changes: 0 additions & 22 deletions impersonate_login/static/src/xml/user_menu.xml

This file was deleted.

24 changes: 0 additions & 24 deletions impersonate_login/views/assets.xml

This file was deleted.

1 change: 1 addition & 0 deletions setup/impersonate_login/odoo/addons/impersonate_login
6 changes: 6 additions & 0 deletions setup/impersonate_login/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit 68a2703

Please sign in to comment.