diff --git a/web_responsive/README.rst b/web_responsive/README.rst
index ec729266f..f7b590c41 100644
--- a/web_responsive/README.rst
+++ b/web_responsive/README.rst
@@ -32,36 +32,42 @@ This module adds responsiveness to web backend.
**Features for all devices**:
-- New navigation with the fullscreen app menu
+- Redirect to the dashboard after logging in. Users will only be
+ redirected to the home page after login if they have enabled the
+ 'Redirect to Home' option in their profile settings.
|image|
-- Quick menu search inside the app menu
+- New navigation with the fullscreen app menu
|image1|
-- Sticky header & footer in list view
+- Quick menu search inside the app menu
|image2|
-- Sticky statusbar in form view
+- Sticky header & footer in list view
|image3|
-- Bigger checkboxes in list view
+- Sticky statusbar in form view
|image4|
+- Bigger checkboxes in list view
+
+ |image5|
+
**Features for mobile**: \* View type picker dropdown displays
comfortably
- Control panel buttons use icons to save space.
- |image5|
+ |image6|
- Followers and send button is displayed on mobile. Avatar is hidden.
- |image6|
+ |image7|
- Big inputs on form in edit mode
@@ -73,35 +79,36 @@ comfortably
be more intuitive or accessible by fingers of one hand. F.x. Alt + S
for Save
- |image7|
+ |image8|
- Autofocus on search menu box when opening the app menu
- |image8|
+ |image9|
- When the chatter is on the side part, the document viewer fills that
part for side-by-side reading instead of full screen. You can still
put it on full width preview clicking on the new maximize button.
- |image9|
+ |image10|
- When the user chooses to send a public message the color of the
composer is different from the one when the message is an internal
log.
- |image10|
+ |image11|
-.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif
-.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
-.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
-.. |image3| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif
-.. |image4| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
-.. |image5| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif
-.. |image6| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png
-.. |image7| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif
-.. |image8| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
-.. |image9| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif
-.. |image10| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png
+.. |image| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/redirecthome.gif
+.. |image1| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appmenu.gif
+.. |image2| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
+.. |image3| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
+.. |image4| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/formview.gif
+.. |image5| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/listview.gif
+.. |image6| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/form_buttons.gif
+.. |image7| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter.png
+.. |image8| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/shortcuts.gif
+.. |image9| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/appsearch.gif
+.. |image10| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/document_viewer.gif
+.. |image11| image:: https://raw.githubusercontent.com/OCA/web/17.0/web_responsive/static/img/chatter-colors.png
**Table of contents**
@@ -170,6 +177,8 @@ Contributors
- Taras Shabaranskyi
+- Angel Patel
+
Maintainers
-----------
diff --git a/web_responsive/models/res_users.py b/web_responsive/models/res_users.py
index 7b67ccaaa..725eb98d3 100644
--- a/web_responsive/models/res_users.py
+++ b/web_responsive/models/res_users.py
@@ -1,7 +1,7 @@
# Copyright 2023 Taras Shabaranskyi
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
-from odoo import fields, models
+from odoo import api, fields, models
class ResUsers(models.Model):
@@ -24,3 +24,19 @@ class ResUsers(models.Model):
default="milk",
required=True,
)
+ is_redirect_home = fields.Boolean(
+ string="Redirect to Home",
+ help="Redirect to dashboard after signing in",
+ compute="_compute_redirect_home",
+ store=True,
+ readonly=False,
+ )
+
+ @api.depends("action_id")
+ def _compute_redirect_home(self):
+ """
+ Set is_redirect_home to False
+ when action_id has a value.
+ :return:
+ """
+ self.filtered("action_id").is_redirect_home = False
diff --git a/web_responsive/readme/CONTRIBUTORS.md b/web_responsive/readme/CONTRIBUTORS.md
index dc659b2fa..8e7d7d5e2 100644
--- a/web_responsive/readme/CONTRIBUTORS.md
+++ b/web_responsive/readme/CONTRIBUTORS.md
@@ -19,3 +19,5 @@
- David Vidal \<\>
- Taras Shabaranskyi \<\>
+
+- Angel Patel \<\>
diff --git a/web_responsive/readme/DESCRIPTION.md b/web_responsive/readme/DESCRIPTION.md
index d7e22a902..9e2714aad 100644
--- a/web_responsive/readme/DESCRIPTION.md
+++ b/web_responsive/readme/DESCRIPTION.md
@@ -2,6 +2,13 @@ This module adds responsiveness to web backend.
**Features for all devices**:
+- Redirect to the dashboard after logging in.
+Users will only be redirected to the home page after login
+if they have enabled the 'Redirect to Home' option in
+their profile settings.
+
+ 
+
- New navigation with the fullscreen app menu

diff --git a/web_responsive/static/description/index.html b/web_responsive/static/description/index.html
index 358d4ee28..f24f4a830 100644
--- a/web_responsive/static/description/index.html
+++ b/web_responsive/static/description/index.html
@@ -8,10 +8,11 @@
/*
:Author: David Goodger (goodger@python.org)
-:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
+:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.
Default cascading style sheet for the HTML output of Docutils.
+Despite the name, some widely supported CSS2 features are used.
See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
@@ -274,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code {
margin-left: 2em ;
margin-right: 2em }
-pre.code .ln { color: grey; } /* line numbers */
+pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
@@ -300,7 +301,7 @@ span.option {
span.pre {
white-space: pre }
-span.problematic {
+span.problematic, pre.problematic {
color: red }
span.section-subtitle {
@@ -372,30 +373,35 @@ ul.auto-toc {
This module adds responsiveness to web backend.
Features for all devices:
+Redirect to the dashboard after logging in. Users will only be
+redirected to the home page after login if they have enabled the
+‘Redirect to Home’ option in their profile settings.
+
+
New navigation with the fullscreen app menu
-
+
Quick menu search inside the app menu
-
+
Sticky header & footer in list view
-
+
Sticky statusbar in form view
-
+
Bigger checkboxes in list view
-
+
Features for mobile: * View type picker dropdown displays
comfortably
Control panel buttons use icons to save space.
-
+
Followers and send button is displayed on mobile. Avatar is hidden.
-
+
Big inputs on form in edit mode
@@ -407,20 +413,20 @@ comfortably
with Firefox Tab switching. Standard Odoo keyboard hotkeys changed to
be more intuitive or accessible by fingers of one hand. F.x. Alt + S
for Save
-
This module is maintained by the OCA.
-

+
+
+
OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.
diff --git a/web_responsive/static/img/redirecthome.gif b/web_responsive/static/img/redirecthome.gif
new file mode 100644
index 000000000..32dcbe5e1
Binary files /dev/null and b/web_responsive/static/img/redirecthome.gif differ
diff --git a/web_responsive/static/src/components/apps_menu/apps_menu.esm.js b/web_responsive/static/src/components/apps_menu/apps_menu.esm.js
index b9c9e3e0b..200561ab3 100644
--- a/web_responsive/static/src/components/apps_menu/apps_menu.esm.js
+++ b/web_responsive/static/src/components/apps_menu/apps_menu.esm.js
@@ -5,7 +5,7 @@
* Copyright 2023 Taras Shabaranskyi
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
-import {Component, useState} from "@odoo/owl";
+import {Component, onWillStart, useState} from "@odoo/owl";
import {session} from "@web/session";
import {useBus, useService} from "@web/core/utils/hooks";
import {AppMenuItem} from "@web_responsive/components/apps_menu_item/apps_menu_item.esm";
@@ -14,6 +14,7 @@ import {NavBar} from "@web/webclient/navbar/navbar";
import {WebClient} from "@web/webclient/webclient";
import {patch} from "@web/core/utils/patch";
import {useHotkey} from "@web/core/hotkeys/hotkey_hook";
+import {browser} from "@web/core/browser/browser";
// Patch WebClient to show AppsMenu instead of default app
patch(WebClient.prototype, {
@@ -22,6 +23,25 @@ patch(WebClient.prototype, {
useBus(this.env.bus, "APPS_MENU:STATE_CHANGED", ({detail: state}) => {
document.body.classList.toggle("o_apps_menu_opened", state);
});
+ this.user = useService("user");
+ onWillStart(async () => {
+ const is_redirect_home = await this.orm.searchRead(
+ "res.users",
+ [["id", "=", this.user.userId]],
+ ["is_redirect_home"]
+ );
+ this.env.services.user.updateContext({
+ is_redirect_to_home: is_redirect_home[0].is_redirect_home,
+ });
+ });
+ this.redirect = false;
+ },
+ _loadDefaultApp() {
+ if (this.env.services.user.context.is_redirect_to_home) {
+ this.env.bus.trigger("APPS_MENU:STATE_CHANGED", true);
+ } else {
+ super._loadDefaultApp();
+ }
},
});
@@ -31,6 +51,12 @@ export class AppsMenu extends Component {
this.state = useState({open: false});
this.theme = session.apps_menu.theme || "milk";
this.menuService = useService("menu");
+ browser.localStorage.setItem("redirect_menuId", "");
+ if (this.env.services.user.context.is_redirect_to_home) {
+ this.router = useService("router");
+ const menuId = Number(this.router.current.hash.menu_id || 0);
+ this.state = useState({open: menuId === 0});
+ }
useBus(this.env.bus, "ACTION_MANAGER:UI-UPDATED", () => {
this.setOpenState(false);
});
@@ -106,7 +132,30 @@ export class AppsMenu extends Component {
}
onMenuClick() {
- this.setOpenState(!this.state.open);
+ if (!this.env.services.user.context.is_redirect_to_home) {
+ this.setOpenState(!this.state.open);
+ } else {
+ const redirect_menuId =
+ browser.localStorage.getItem("redirect_menuId") || "";
+ if (!redirect_menuId) {
+ this.setOpenState(true);
+ } else {
+ this.setOpenState(!this.state.open);
+ }
+ const {href, hash} = location;
+ const menuId = this.router.current.hash.menu_id;
+ if (menuId && menuId != redirect_menuId) {
+ console.log(this.router.current.hash.menu_id);
+ browser.localStorage.setItem(
+ "redirect_menuId",
+ this.router.current.hash.menu_id
+ );
+ }
+
+ if (href.includes(hash)) {
+ window.history.replaceState(null, "", href.replace(hash, ""));
+ }
+ }
}
}
diff --git a/web_responsive/tests/__init__.py b/web_responsive/tests/__init__.py
index 1961bf280..a21cda15a 100644
--- a/web_responsive/tests/__init__.py
+++ b/web_responsive/tests/__init__.py
@@ -2,3 +2,4 @@
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
from . import test_ir_http
+from . import test_res_users
diff --git a/web_responsive/tests/test_res_users.py b/web_responsive/tests/test_res_users.py
new file mode 100644
index 000000000..1801dc91b
--- /dev/null
+++ b/web_responsive/tests/test_res_users.py
@@ -0,0 +1,32 @@
+# Copyright 2023 Taras Shabaranskyi
+# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html).
+
+from odoo.tests.common import TransactionCase
+
+
+class TestResUsers(TransactionCase):
+ def test_compute_redirect_home(self):
+ record = self.env["res.users"].create(
+ {
+ "action_id": False,
+ "is_redirect_home": False,
+ "name": "Jeant",
+ "login": "jeant@mail.com",
+ "password": "jeant@mail.com",
+ }
+ )
+
+ record._compute_redirect_home()
+ self.assertFalse(record.is_redirect_home)
+
+ action_obj = self.env["ir.actions.actions"]
+ record.action_id = action_obj.create(
+ {"name": "Test Action", "type": "ir.actions.act_window"}
+ )
+ record._compute_redirect_home()
+ self.assertFalse(record.is_redirect_home)
+
+ record.action_id = False
+ record.is_redirect_home = True
+ record._compute_redirect_home()
+ self.assertTrue(record.is_redirect_home)
diff --git a/web_responsive/views/res_users_views.xml b/web_responsive/views/res_users_views.xml
index 8972a65f3..e835770ca 100644
--- a/web_responsive/views/res_users_views.xml
+++ b/web_responsive/views/res_users_views.xml
@@ -61,4 +61,17 @@
]"
/>
+
+
+ res.users.form.web.responsive
+ res.users
+
+
+
+
+
+
+
+
+