@ -0,0 +1,45 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Import User with Access Rights |
|||
============================== |
|||
Allows to import User with User type and Access rights |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
License |
|||
------- |
|||
General Public License, Version 3 (AGPL v3). |
|||
(http://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Credits |
|||
------- |
|||
Developer: (V16)Ammu, |
|||
(V17)Akhil Ashok, |
|||
(V18)Manasa T P, |
|||
Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import wizard |
@ -0,0 +1,42 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
{ |
|||
'name': 'Import User with Access rights', |
|||
'category': 'Extra Tools', |
|||
'version': '18.0.1.0.0', |
|||
'summary': 'Import User details with Access rights by Excel', |
|||
'description': """Allows to import User with User type and Access rights""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'license': 'AGPL-3', |
|||
'depends': ['base'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'wizard/user_import_views.xml', |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'installable': True, |
|||
'application': False, |
|||
'auto_install': False, |
|||
} |
@ -0,0 +1,6 @@ |
|||
## Module <import_user_excel> |
|||
|
|||
#### 11.11.2024 |
|||
#### Version 18.0.1.0.0 |
|||
#### ADD |
|||
- Initial commit for Import User with Access rights |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 170 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 767 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 760 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 697 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 48 KiB |
After Width: | Height: | Size: 54 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 745 KiB |
After Width: | Height: | Size: 39 KiB |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
from . import user_import |
@ -0,0 +1,109 @@ |
|||
# -*- coding: utf-8 -*- |
|||
################################################################################ |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# Author: Manasa T P (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL 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 AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
################################################################################ |
|||
import binascii |
|||
import tempfile |
|||
from openpyxl.reader.excel import load_workbook |
|||
|
|||
from odoo import fields, models, _ |
|||
from odoo.exceptions import ValidationError |
|||
|
|||
|
|||
class UserImport(models.TransientModel): |
|||
"""Import User with access right""" |
|||
_name = 'user.import' |
|||
_description = 'User Import' |
|||
|
|||
file = fields.Binary(string="Upload File", help='Upload the file here') |
|||
|
|||
def import_file(self): |
|||
""" function to import user from xlsx file """ |
|||
if self: |
|||
try: |
|||
with tempfile.NamedTemporaryFile(suffix=".xlsx", |
|||
delete=False) as temp_file: |
|||
# Write the base64-decoded content to the temporary file |
|||
temp_file.write(binascii.a2b_base64(self.file)) |
|||
temp_file.flush() # Ensure all data is written |
|||
|
|||
# Open the workbook using the temporary file |
|||
book = load_workbook(temp_file.name) |
|||
sheet = book.active # Access the active sheet |
|||
except Exception as e: |
|||
raise ValidationError( |
|||
_(f"Please choose the correct file: {str(e)}")) |
|||
startline = True |
|||
for i in range(1, sheet.max_row+1): |
|||
if startline: |
|||
startline = False |
|||
else: |
|||
line = [cell.value for cell in sheet[i]] # Get values in the row |
|||
res_lang = self.env['res.lang'] |
|||
res_groups = self.env['res.groups'] |
|||
res_company = self.env['res.company'] |
|||
user_type = [line[4]] |
|||
invalid_language = [lang for lang in [line[2]] if |
|||
not res_lang.search( |
|||
[('code', '=', lang), |
|||
('active', '=', True)])] |
|||
if invalid_language: |
|||
raise ValidationError(_("Language %s is not active") % ( |
|||
" ".join(invalid_language))) |
|||
invalid_company = [res for res in [line[3]] if |
|||
not res_company.search( |
|||
[('name', '=', res)])] |
|||
if invalid_company: |
|||
raise ValidationError(_("Company %s not exists") % ( |
|||
" ".join(invalid_company))) |
|||
invalid_user = [rec for rec in user_type if |
|||
not res_groups.search( |
|||
[('full_name', '=', rec)])] |
|||
if invalid_user: |
|||
raise ValidationError(_("Invalid User Type %s") % ( |
|||
" ".join(invalid_user))) |
|||
if line[5]: |
|||
groups = line[5].split(",") |
|||
invalid_groups = [rec for rec in groups if |
|||
not res_groups.search( |
|||
[('full_name', '=', rec)])] |
|||
if invalid_groups: |
|||
raise ValidationError(_("Invalid groups %s") % ( |
|||
" ".join(invalid_groups))) |
|||
else: |
|||
groups = [] |
|||
access_right = res_groups.search( |
|||
[('full_name', 'in', groups)]).ids |
|||
tech_settings = line[6].split(',') |
|||
tech_settings += user_type |
|||
total_rights = res_groups.search( |
|||
[('name', 'in', tech_settings)]).ids |
|||
group_ids = access_right + total_rights |
|||
if line[0]: |
|||
self.env['res.users'].create([{ |
|||
'name': line[0], |
|||
'login': line[1], |
|||
'lang': line[2], |
|||
'company_id': self.env['res.company'].search( |
|||
[('name', '=', line[3])]).id if line[3] else False, |
|||
'groups_id': group_ids, |
|||
}]) |
|||
else: |
|||
raise ValidationError(_('Please Enter the User Name.')) |
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Wizard view of user import--> |
|||
<record id="user_import_view_form" model="ir.ui.view"> |
|||
<field name="name">user.import.view.form</field> |
|||
<field name="model">user.import</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="User Options"> |
|||
<group col="4"> |
|||
<field name="file"/> |
|||
</group> |
|||
<footer> |
|||
<button name="import_file" string="Import" type="object" default_focus="1" class="oe_highlight"/> |
|||
<button string="Cancel" class="btn btn-default" special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<!--Action of user import--> |
|||
<record id="action_user_import" model="ir.actions.act_window"> |
|||
<field name="name">Import Users</field> |
|||
<field name="res_model">user.import</field> |
|||
<field name="type">ir.actions.act_window</field> |
|||
<field name="view_mode">list,form</field> |
|||
<field name="view_id" ref="user_import_view_form"/> |
|||
<field name="target">new</field> |
|||
</record> |
|||
<menuitem id="menu_users_import" |
|||
name="Import Users" |
|||
action="action_user_import" |
|||
parent="base.menu_administration"/> |
|||
</odoo> |