diff --git a/import_partner_employee_image/README.md b/import_partner_employee_image/README.md new file mode 100644 index 000000000..253e1c899 --- /dev/null +++ b/import_partner_employee_image/README.md @@ -0,0 +1,32 @@ +Import Employee/Partner Image +============================= + +Installation +============ +- www.odoo.com/documentation/14.0/setup/install.html +- Install our custom addon + +License +======= +GNU AFFERO GENERAL PUBLIC LICENSE, Version 3 (AGPLv3) +(http://www.gnu.org/licenses/agpl.html) + +Bug Tracker +=========== +Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. + +Credits +======= +* Cybrosys Techno Solutions + + +Developer: Ijaz Ahammed - odoo@cybrosys.com + Version 14: Minhaj T @cybrosys, odoo@cybrosys.com + +Maintainer +---------- + +This module is maintained by Cybrosys Technologies. + +For support and more information, please visit https://www.cybrosys.com. + diff --git a/import_partner_employee_image/__init__.py b/import_partner_employee_image/__init__.py new file mode 100644 index 000000000..d2edfe6c7 --- /dev/null +++ b/import_partner_employee_image/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Ijaz () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import models diff --git a/import_partner_employee_image/__manifest__.py b/import_partner_employee_image/__manifest__.py new file mode 100644 index 000000000..f055d90c3 --- /dev/null +++ b/import_partner_employee_image/__manifest__.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2020-TODAY Cybrosys Technologies(). +# Author: Ijaz () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +{ + 'name': "Import Employee/Partner Image", + 'version': '14.0.1.0.0', + 'category': 'Human Resources', + 'summary': """Import Partner/Employee Image From Url and Local storage using CSV and XLSX Files""", + 'description': """Import Partner/Employee Image From Url and Local storage using CSV and XLSX Files""", + 'author': "Cybrosys Techno Solutions", + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': "https://www.cybrosys.com", + 'depends': ['hr', 'contacts'], + 'data': ['views/import_employee_image.xml', + 'views/import_partner_image.xml', + 'security/ir.model.access.csv', + ], + 'license': 'AGPL-3', + 'images': ['static/description/banner.png'], + 'application': False, + 'installable': True, + 'auto_install': False, +} diff --git a/import_partner_employee_image/doc/RELEASE_NOTES.md b/import_partner_employee_image/doc/RELEASE_NOTES.md new file mode 100644 index 000000000..0b0da92a2 --- /dev/null +++ b/import_partner_employee_image/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 09.10.2020 +#### Version 14.0.1.0.0 +#### ADD +Initial Commit diff --git a/import_partner_employee_image/models/__init__.py b/import_partner_employee_image/models/__init__.py new file mode 100644 index 000000000..85bbb4eba --- /dev/null +++ b/import_partner_employee_image/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Ijaz () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +from . import import_employee_image +from . import import_partner_image diff --git a/import_partner_employee_image/models/import_employee_image.py b/import_partner_employee_image/models/import_employee_image.py new file mode 100644 index 000000000..4b534404a --- /dev/null +++ b/import_partner_employee_image/models/import_employee_image.py @@ -0,0 +1,133 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Ijaz () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +import binascii +import tempfile + +import certifi +import urllib3 +import base64 +import csv +import io +import xlrd + +from odoo import models, fields, api, _ +from odoo.exceptions import Warning, UserError + + +class EmployeeImageImportWizard(models.TransientModel): + _name = 'import.employee_image' + + file = fields.Binary('File to import', required=True) + file_type = fields.Selection([('csv', 'CSV'), ('xls', 'XLS')], string="File Type", default='csv') + + def import_file(self): + if self.file_type == 'csv': + + keys = ['emp_id', 'emp_image'] + + try: + file = base64.b64decode(self.file) + data = io.StringIO(file.decode("utf-8")) + data.seek(0) + file_reader = [] + csv_reader = csv.reader(data, delimiter=',') + file_reader.extend(csv_reader) + + except: + + raise Warning(_("File is not Valid!")) + + for fr in range(len(file_reader)): + line = list(map(str, file_reader[fr])) + vals = dict(zip(keys, line)) + if vals: + if fr == 0: + continue + else: + vals.update({ + 'emp_id': line[0], + 'employee_image': line[1], + }) + res = self.import_employee_image(vals) + + elif self.file_type == 'xls': + try: + fp = tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") + fp.write(binascii.a2b_base64(self.file)) + fp.seek(0) + vals = {} + workbook = xlrd.open_workbook(fp.name) + sheet = workbook.sheet_by_index(0) + + except: + raise Warning(_("File not Valid")) + + for row_no in range(sheet.nrows): + val = {} + if row_no <= 0: + fields = map(lambda row: row.value.encode('utf-8'), sheet.row(row_no)) + else: + + line = list( + map(lambda row: isinstance(row.value, bytes) and row.value.encode('utf-8') or str(row.value), + sheet.row(row_no))) + + vals.update({ + 'emp_id': line[0], + 'emp_image': line[1], + }) + + self.import_employee_image(vals) + else: + raise UserError(_("Please select xls or csv format!")) + + def import_employee_image(self, vals): + if vals.get('emp_id') == "": + raise UserError(_("ID Field is Empty.")) + if vals.get('emp_image') == "": + raise UserError(_("Image Field is Empty.")) + print('vals.get', vals.get('emp_id')) + + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + id = str(vals.get("emp_id")) + emp_id = id.rstrip('0').rstrip('.') if '.' in id else id + + if "http://" in vals.get('emp_image') or "https://" in vals.get('emp_image'): + print('yesss') + link = vals.get('emp_image') + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + image = image_thumbnail + print('image', image_thumbnail) + else: + with open(vals.get('emp_image'), 'rb') as f: + data = base64.b64encode(f.read()) + image = data + + employee_id = self.env['hr.employee'].search([('id', '=', emp_id)], limit=1) + print('partner_id', employee_id.name) + if employee_id: + employee_id.update({ + 'image_1920': image, + }) diff --git a/import_partner_employee_image/models/import_partner_image.py b/import_partner_employee_image/models/import_partner_image.py new file mode 100644 index 000000000..46a86019f --- /dev/null +++ b/import_partner_employee_image/models/import_partner_image.py @@ -0,0 +1,143 @@ +# -*- coding: utf-8 -*- +################################################################################### +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Ijaz () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# 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 for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################### + +import binascii +import tempfile + +import certifi +import urllib3 +import base64 +import csv +import io +import xlrd + +from odoo import models, fields, api, _ +from odoo.exceptions import Warning, UserError + + +class PartnerImageImportWizard(models.TransientModel): + _name = 'import.partner_image' + + file = fields.Binary('File to import', required=True) + file_type = fields.Selection([('csv', 'CSV'), ('xls', 'XLS')], string="File Type", default='csv') + + def import_file(self): + if self.file_type == 'csv': + + keys = ['partner_id', 'partner_image'] + + try: + file = base64.b64decode(self.file) + data = io.StringIO(file.decode("utf-8")) + data.seek(0) + file_reader = [] + csv_reader = csv.reader(data, delimiter=',') + file_reader.extend(csv_reader) + + except: + + raise Warning(_("File is not Valid!")) + + for fr in range(len(file_reader)): + line = list(map(str, file_reader[fr])) + vals = dict(zip(keys, line)) + if vals: + if fr == 0: + continue + else: + vals.update({ + 'partner_id': line[0], + 'partner_image': line[1], + }) + self.import_partner_image(vals) + + elif self.file_type == 'xls': + try: + fp = tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") + fp.write(binascii.a2b_base64(self.file)) + fp.seek(0) + vals = {} + workbook = xlrd.open_workbook(fp.name) + sheet = workbook.sheet_by_index(0) + + except: + raise Warning(_("File not Valid")) + + for row_no in range(sheet.nrows): + val = {} + if row_no <= 0: + fields = map(lambda row: row.value.encode('utf-8'), sheet.row(row_no)) + else: + + line = list( + map(lambda row: isinstance(row.value, bytes) and row.value.encode('utf-8') or str(row.value), + sheet.row(row_no))) + + vals.update({ + 'partner_id': line[0], + 'partner_image': line[1], + }) + + self.import_partner_image(vals) + else: + raise UserError(_("Please select xls or csv format!")) + + + def import_partner_image(self, vals): + if vals.get('partner_id') == "": + raise UserError(_("ID Field is Empty.")) + if vals.get('partner_image') == "": + raise UserError(_("Image Field is Empty.")) + print('vals.get',vals.get('partner_id')) + + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + id = str(vals.get("partner_id")) + p_id = id.rstrip('0').rstrip('.') if '.' in id else id + + + if "http://" in vals.get('partner_image') or "https://" in vals.get('partner_image'): + try: + print('yesss') + link = vals.get('partner_image') + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + image = image_thumbnail + print('image', image_thumbnail) + except: + raise UserError('The Link Is Not valid') + else: + try: + with open(vals.get('partner_image'), 'rb') as f: + data = base64.b64encode(f.read()) + image = data + except: + + raise UserError('The Link Is Not Valid') + + partner_id = self.env['res.partner'].search([('id', '=', p_id)], limit=1) + print('employee_id', partner_id.name) + + partner_id.update({ + 'image_1920': image, + }) + diff --git a/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_csv.csv b/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_csv.csv new file mode 100644 index 000000000..e2802e4b7 --- /dev/null +++ b/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_csv.csv @@ -0,0 +1,3 @@ +Employee/Partner Record ID,Image Link +13,https://www.cybrosys.com/images/cybro-logo-oca.png +14,/home/ijaz/Documents/71t-J3VJtEL._SX466_.jpg diff --git a/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_xlsx.xlsx b/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_xlsx.xlsx new file mode 100644 index 000000000..04446e223 Binary files /dev/null and b/import_partner_employee_image/sample_csv_snd_xlsx_file/import_employee_partner_image_sample_xlsx.xlsx differ diff --git a/import_partner_employee_image/security/ir.model.access.csv b/import_partner_employee_image/security/ir.model.access.csv new file mode 100644 index 000000000..4dd75d727 --- /dev/null +++ b/import_partner_employee_image/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_import_employee_image_user,import.employee_image,model_import_employee_image,base.group_user,1,1,1,1 +access_import.partner_image_user,import.partner_image,model_import_partner_image,base.group_user,1,1,1,1 diff --git a/import_partner_employee_image/static/description/banner.png b/import_partner_employee_image/static/description/banner.png new file mode 100644 index 000000000..fb452636a Binary files /dev/null and b/import_partner_employee_image/static/description/banner.png differ diff --git a/import_partner_employee_image/static/description/icon.png b/import_partner_employee_image/static/description/icon.png new file mode 100644 index 000000000..6b84fd3bc Binary files /dev/null and b/import_partner_employee_image/static/description/icon.png differ diff --git a/import_partner_employee_image/static/description/images/1.jpeg b/import_partner_employee_image/static/description/images/1.jpeg new file mode 100644 index 000000000..ccb8e1556 Binary files /dev/null and b/import_partner_employee_image/static/description/images/1.jpeg differ diff --git a/import_partner_employee_image/static/description/images/2.jpeg b/import_partner_employee_image/static/description/images/2.jpeg new file mode 100644 index 000000000..2625f7727 Binary files /dev/null and b/import_partner_employee_image/static/description/images/2.jpeg differ diff --git a/import_partner_employee_image/static/description/images/3.jpeg b/import_partner_employee_image/static/description/images/3.jpeg new file mode 100644 index 000000000..5dfdf2c2b Binary files /dev/null and b/import_partner_employee_image/static/description/images/3.jpeg differ diff --git a/import_partner_employee_image/static/description/images/4.jpeg b/import_partner_employee_image/static/description/images/4.jpeg new file mode 100644 index 000000000..ec8264c0b Binary files /dev/null and b/import_partner_employee_image/static/description/images/4.jpeg differ diff --git a/import_partner_employee_image/static/description/images/5.jpeg b/import_partner_employee_image/static/description/images/5.jpeg new file mode 100644 index 000000000..e10c28799 Binary files /dev/null and b/import_partner_employee_image/static/description/images/5.jpeg differ diff --git a/import_partner_employee_image/static/description/images/6.jpeg b/import_partner_employee_image/static/description/images/6.jpeg new file mode 100644 index 000000000..529143e4e Binary files /dev/null and b/import_partner_employee_image/static/description/images/6.jpeg differ diff --git a/import_partner_employee_image/static/description/images/checked.png b/import_partner_employee_image/static/description/images/checked.png new file mode 100644 index 000000000..578cedb80 Binary files /dev/null and b/import_partner_employee_image/static/description/images/checked.png differ diff --git a/import_partner_employee_image/static/description/images/cybrosys.png b/import_partner_employee_image/static/description/images/cybrosys.png new file mode 100644 index 000000000..d76b5bafb Binary files /dev/null and b/import_partner_employee_image/static/description/images/cybrosys.png differ diff --git a/import_partner_employee_image/static/description/images/enable.png b/import_partner_employee_image/static/description/images/enable.png new file mode 100644 index 000000000..c38dc2d38 Binary files /dev/null and b/import_partner_employee_image/static/description/images/enable.png differ diff --git a/import_partner_employee_image/static/description/images/import_employee_partner_image_1.png b/import_partner_employee_image/static/description/images/import_employee_partner_image_1.png new file mode 100644 index 000000000..ca25b7907 Binary files /dev/null and b/import_partner_employee_image/static/description/images/import_employee_partner_image_1.png differ diff --git a/import_partner_employee_image/static/description/images/import_employee_partner_image_2.png b/import_partner_employee_image/static/description/images/import_employee_partner_image_2.png new file mode 100644 index 000000000..d2424f946 Binary files /dev/null and b/import_partner_employee_image/static/description/images/import_employee_partner_image_2.png differ diff --git a/import_partner_employee_image/static/description/images/import_employee_partner_image_3.png b/import_partner_employee_image/static/description/images/import_employee_partner_image_3.png new file mode 100644 index 000000000..5c55140c1 Binary files /dev/null and b/import_partner_employee_image/static/description/images/import_employee_partner_image_3.png differ diff --git a/import_partner_employee_image/static/description/images/import_employee_partner_image_4.png b/import_partner_employee_image/static/description/images/import_employee_partner_image_4.png new file mode 100644 index 000000000..176ab99f9 Binary files /dev/null and b/import_partner_employee_image/static/description/images/import_employee_partner_image_4.png differ diff --git a/import_partner_employee_image/static/description/index.html b/import_partner_employee_image/static/description/index.html new file mode 100644 index 000000000..5d9ace976 --- /dev/null +++ b/import_partner_employee_image/static/description/index.html @@ -0,0 +1,318 @@ +
cybrosys-logo
+
+
+
+

Import Employee and Partner Image From Url and Local

+
+

Key Highlights

+
    +
  • Manage the Importing of Employee and Partner Image Easily
  • +
+
+
+
+
+
+
+
+ +
+
+ +

Overview

+
+

+ This module allows the odoo users to Import Employee and Partner image easily . +

+
+
+ +

Import Employee and Partner Image

+
+
    +

    + Easy Importing Of Employee and Partner Image. +

    +
+
    +

    + Image From Url and Local Storage. +

    +
+
    +

    + It Supports XlSX and CSV Files. +

    +
+ +
+ +
+
+

Screenshots

+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + +
+
    +
+
+
+
+
+
+
+

Suggested Products

+
+ +
+
+

Our Service

+
+ +
+
+
+

Our Industries

+
+ +
+
+
+ +
+
+

Trading

+

Easily procure and sell your products.

+
+
+
+
+ +
+
+

Manufacturing

+

Plan, track and schedule your operations.

+
+
+
+
+ +
+
+

Restaurant

+

Run your bar or restaurant methodical.

+
+
+
+
+ +
+
+

POS

+

Easy configuring and convivial selling.

+
+
+
+
+ +
+
+

E-commerce & Website

+

Mobile friendly, awe-inspiring product pages.

+
+
+
+
+ +
+
+

Hotel Management

+

An all-inclusive hotel management application.

+
+
+
+
+ +
+
+

Education

+

A Collaborative platform for educational management.

+
+
+
+
+ +
+
+

Service Management

+

Keep track of services and invoice accordingly.

+
+
+
+
+
+
+ + +
+
+
+

Need Any Help?

+
+

If you have anything to share with us based on your use of this module, please let us know. We are ready to offer our support.

+
+

Email us

+

odoo@cybrosys.com / info@cybrosys.com

+
+
+

Contact Us

+ www.cybrosys.com +
+
+
+
+
+
+
+
+
+ +
+ + + + + + + +
+
+
+ \ No newline at end of file diff --git a/import_partner_employee_image/views/import_employee_image.xml b/import_partner_employee_image/views/import_employee_image.xml new file mode 100644 index 000000000..68993eca1 --- /dev/null +++ b/import_partner_employee_image/views/import_employee_image.xml @@ -0,0 +1,52 @@ + + + + + + hr.employee.view.form.inherit + hr.employee + + + + + + + + + + + + employee.import.image.form + import.employee_image + form + +
+ + + + + + +
+
+
+
+
+ + + Import employee Image + ir.actions.act_window + import.employee_image + form + new + + + + + +
+
diff --git a/import_partner_employee_image/views/import_partner_image.xml b/import_partner_employee_image/views/import_partner_image.xml new file mode 100644 index 000000000..3d631c40e --- /dev/null +++ b/import_partner_employee_image/views/import_partner_image.xml @@ -0,0 +1,47 @@ + + + + partner.view.form.inherit + res.partner + + + + + + + + + + + partner.import.image.form + import.partner_image + form + +
+ + + + + + +
+
+
+
+
+ + + Import Partner Image + ir.actions.act_window + import.partner_image + form + new + + + +
+
\ No newline at end of file