Module Master Selector
This commit is contained in:
parent
5d6c2c09aa
commit
b5b276f552
|
|
@ -0,0 +1 @@
|
|||
from . import controllers
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "Custom Module Switcher",
|
||||
"version": "1.0",
|
||||
"depends": ["web"],
|
||||
"assets": {
|
||||
"web.assets_backend": [
|
||||
"module_selector_sidebar/static/src/js/module_switcher.js",
|
||||
"module_selector_sidebar/static/src/xml/module_switcher.xml",
|
||||
],
|
||||
},
|
||||
"installable": True,
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
from . import master_switcher
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
from odoo import http
|
||||
from odoo.http import request
|
||||
|
||||
|
||||
class MasterSwitcher(http.Controller):
|
||||
|
||||
@http.route('/switch/master/<string:code>', type='http', auth='user')
|
||||
def switch_master(self, code):
|
||||
|
||||
request.session['active_master'] = code
|
||||
|
||||
request.env['ir.ui.menu'].sudo().clear_caches()
|
||||
|
||||
return request.redirect('/web?reload=1')
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
.custom-switcher {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 40%;
|
||||
width: 180px;
|
||||
background: white;
|
||||
padding: 15px;
|
||||
box-shadow: 2px 2px 10px rgba(0,0,0,0.15);
|
||||
z-index: 9999;
|
||||
border-radius: 0 10px 10px 0;
|
||||
}
|
||||
|
||||
.switcher-title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.custom-switcher button {
|
||||
width: 100%;
|
||||
margin-bottom: 8px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/** @odoo-module **/
|
||||
|
||||
import { Component, onWillStart, useState } from "@odoo/owl";
|
||||
import { registry } from "@web/core/registry";
|
||||
import { useService } from "@web/core/utils/hooks";
|
||||
|
||||
export class ModuleSelector extends Component {
|
||||
|
||||
static template = "module_selector_sidebar.ModuleSelector";
|
||||
static props = {};
|
||||
|
||||
setup() {
|
||||
|
||||
this.orm = useService("orm");
|
||||
|
||||
this.state = useState({
|
||||
masters: [],
|
||||
});
|
||||
|
||||
onWillStart(async () => {
|
||||
|
||||
const masters = await this.orm.searchRead(
|
||||
"master.control",
|
||||
[],
|
||||
["name", "code"]
|
||||
);
|
||||
|
||||
this.state.masters = masters;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
registry.category("systray").add("module_selector_sidebar", {
|
||||
Component: ModuleSelector,
|
||||
});
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="module_selector_sidebar.ModuleSelector" owl="1">
|
||||
|
||||
<div class="o_systray_item dropdown">
|
||||
|
||||
<button class="btn btn-link dropdown-toggle"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown">
|
||||
<i class="fa fa-th-large"/>
|
||||
</button>
|
||||
|
||||
<div class="dropdown-menu dropdown-menu-end">
|
||||
|
||||
<t t-if="state.masters.length">
|
||||
<t t-foreach="state.masters" t-as="master" t-key="master.code">
|
||||
|
||||
<a class="dropdown-item"
|
||||
t-att-href="'/switch/master/' + master.code">
|
||||
|
||||
<t t-esc="master.name"/>
|
||||
|
||||
</a>
|
||||
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
|
|
@ -14,6 +14,11 @@
|
|||
# 'views/project_task_kudo_button.xml',
|
||||
'views/task_assign_kudos_action.xml',
|
||||
'views/kudo_log_extend.xml',
|
||||
'views/task_form_extend.xml',
|
||||
'views/task_timesheet_employee_domain.xml',
|
||||
'views/task_timesheet_context.xml',
|
||||
# 'views/task_timesheet_stage_domain.xml',
|
||||
|
||||
],
|
||||
'post_init_hook': 'post_init_hook',
|
||||
'installable': True,
|
||||
|
|
|
|||
|
|
@ -1 +1,5 @@
|
|||
from . import project_kudo_extend
|
||||
from . import task_assignee_domain
|
||||
from . import project_task
|
||||
from . import account_analytic_line
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue