77 lines
2.8 KiB
Python
77 lines
2.8 KiB
Python
# -*- 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/>.
|
|
#
|
|
#############################################################################
|
|
import base64
|
|
|
|
from odoo import api, SUPERUSER_ID
|
|
from odoo.modules import get_module_resource
|
|
|
|
|
|
def _set_menu_icons(env):
|
|
"""Helper function to set custom icons for top-level menus."""
|
|
menu_items = env['ir.ui.menu'].search([('parent_id', '=', False)])
|
|
icon_map = {
|
|
'Contacts': 'Contacts.png',
|
|
'Link Tracker': 'Link Tracker.png',
|
|
'Dashboards': 'Dashboards.png',
|
|
'Sales': 'Sales.png',
|
|
'Invoicing': 'Invoicing.png',
|
|
'Inventory': 'Inventory.png',
|
|
'Purchase': 'Purchase.png',
|
|
'Calendar': 'Calendar.png',
|
|
'CRM': 'CRM.png',
|
|
'Notes': 'Notes.png', # Standardized to 'Notes'
|
|
'Website': 'Website.png',
|
|
'Point of Sale': 'Point of Sale.png',
|
|
'Manufacturing': 'Manufacturing.png',
|
|
'Repairs': 'Repairs.png',
|
|
'Email Marketing': 'Email Marketing.png',
|
|
'SMS Marketing': 'SMS Marketing.png',
|
|
'Project': 'Project.png',
|
|
'Surveys': 'Surveys.png',
|
|
'Employees': 'Employees.png',
|
|
'Recruitment': 'Recruitment.png',
|
|
'Attendances': 'Attendances.png',
|
|
'Time Off': 'Time Off.png',
|
|
'Expenses': 'Expenses.png',
|
|
'Maintenance': 'Maintenance.png',
|
|
'Live Chat': 'Live Chat.png',
|
|
'Lunch': 'Lunch.png',
|
|
'Fleet': 'Fleet.png',
|
|
'Timesheets': 'Timesheets.png',
|
|
'Events': 'Events.png',
|
|
'eLearning': 'eLearning.png',
|
|
'Members': 'Members.png',
|
|
}
|
|
|
|
for menu in menu_items:
|
|
if menu.name in icon_map:
|
|
img_path = get_module_resource(
|
|
'code_backend_theme', 'static', 'src', 'img', 'icons', icon_map[menu.name]
|
|
)
|
|
if img_path:
|
|
with open(img_path, "rb") as f:
|
|
menu.write({'web_icon_data': base64.b64encode(f.read())})
|
|
|
|
|
|
def post_init_hook(env):
|
|
"""Post-init hook: Set menu icons after module installation."""
|
|
_set_menu_icons(env) |