You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

53 lines
2.0 KiB

# -*- coding: utf-8 -*-
#############################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2021-TODAY Cybrosys Technologies(<https://www.cybrosys.com>)
# Author: Cybrosys Techno Solutions(<https://www.cybrosys.com>)
#
# You can modify it under the terms of the GNU LESSER
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details.
#
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE
# (LGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
from odoo import models, fields, api
from odoo.osv import expression
class DashboardMenu(models.Model):
_name = "dashboard.menu"
_description = "Dashboard Menu"
_rec_name = "name"
name = fields.Char(string="Name")
menu_id = fields.Many2one('ir.ui.menu', string="Menu")
group_ids = fields.Many2many('res.groups', string='Groups',
related='menu_id.groups_id',
help="User need to be at least in one of these groups to see the menu")
client_action = fields.Many2one('ir.actions.client')
@api.model
def create(self, vals):
"""This code is to create menu"""
values = {
'name': vals['name'],
'tag': 'dynamic_dashboard',
}
action_id = self.env['ir.actions.client'].create(values)
vals['client_action'] = action_id.id
menu_id = self.env['ir.ui.menu'].create({
'name': vals['name'],
'parent_id': vals['menu_id'],
'action': 'ir.actions.client,%d' % (action_id.id,)
})
return super(DashboardMenu, self).create(vals)