Add project_home_action addon for Project login landing
Restores Home Action on user Preferences (removed in Odoo 19) and defaults internal users to project.open_view_project_all on install and create, so login opens Projects instead of Discuss. Co-authored-by: dyaco8464 <dyaco8464@yahoo.com>
This commit is contained in:
2
odoo/addons/project_home_action/__init__.py
Normal file
2
odoo/addons/project_home_action/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from . import models
|
||||
from .hooks import post_init_hook
|
||||
19
odoo/addons/project_home_action/__manifest__.py
Normal file
19
odoo/addons/project_home_action/__manifest__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Project as Home Action",
|
||||
"version": "1.0.0",
|
||||
"summary": "Open Projects after login instead of Discuss",
|
||||
"description": (
|
||||
"Restores the Home Action field on user Preferences (removed in Odoo 19) "
|
||||
"and sets it to Projects for internal users on install and for new users."
|
||||
),
|
||||
"category": "Project",
|
||||
"author": "Automated",
|
||||
"license": "LGPL-3",
|
||||
"depends": ["base", "project", "web"],
|
||||
"data": [
|
||||
"views/res_users_views.xml",
|
||||
],
|
||||
"post_init_hook": "post_init_hook",
|
||||
"installable": True,
|
||||
"application": False,
|
||||
}
|
||||
13
odoo/addons/project_home_action/hooks.py
Normal file
13
odoo/addons/project_home_action/hooks.py
Normal file
@@ -0,0 +1,13 @@
|
||||
def post_init_hook(env):
|
||||
"""Set Home Action to Projects for internal users that have none."""
|
||||
action = env.ref("project.open_view_project_all", raise_if_not_found=False)
|
||||
if not action:
|
||||
return
|
||||
users = env["res.users"].search(
|
||||
[
|
||||
("share", "=", False),
|
||||
("action_id", "=", False),
|
||||
]
|
||||
)
|
||||
if users:
|
||||
users.write({"action_id": action.id})
|
||||
1
odoo/addons/project_home_action/models/__init__.py
Normal file
1
odoo/addons/project_home_action/models/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import res_users
|
||||
20
odoo/addons/project_home_action/models/res_users.py
Normal file
20
odoo/addons/project_home_action/models/res_users.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from odoo import api, models
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = "res.users"
|
||||
|
||||
@api.model
|
||||
def _project_home_action(self):
|
||||
return self.env.ref("project.open_view_project_all", raise_if_not_found=False)
|
||||
|
||||
@api.model_create_multi
|
||||
def create(self, vals_list):
|
||||
users = super().create(vals_list)
|
||||
action = self._project_home_action()
|
||||
if not action:
|
||||
return users
|
||||
to_update = users.filtered(lambda user: not user.share and not user.action_id)
|
||||
if to_update:
|
||||
to_update.write({"action_id": action.id})
|
||||
return users
|
||||
30
odoo/addons/project_home_action/views/res_users_views.xml
Normal file
30
odoo/addons/project_home_action/views/res_users_views.xml
Normal file
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<!-- Admin user form: Preferences → Home Action -->
|
||||
<record id="view_users_form_home_action" model="ir.ui.view">
|
||||
<field name="name">res.users.form.home.action</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='preferences']//group[@name='other_preferences']" position="inside">
|
||||
<group string="Menus Customization" invisible="share">
|
||||
<field name="action_id" options="{'no_create': True}"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- My Preferences dialog -->
|
||||
<record id="view_users_form_simple_modif_home_action" model="ir.ui.view">
|
||||
<field name="name">res.users.preferences.form.home.action</field>
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form_simple_modif"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page[@name='preferences_page']//group[@name='other_preferences']" position="inside">
|
||||
<group string="Menus Customization">
|
||||
<field name="action_id" options="{'no_create': True}" readonly="0"/>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user