diff --git a/import_partner_employee_image/README.md b/import_partner_employee_image/README.md new file mode 100644 index 000000000..c559ed82c --- /dev/null +++ b/import_partner_employee_image/README.md @@ -0,0 +1,33 @@ +Import Employee/Partner Image +============================= + +Installation +============ +- www.odoo.com/documentation/15.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
+ Version 15: 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..a3e2c09ce --- /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': '15.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..0187b2498 --- /dev/null +++ b/import_partner_employee_image/doc/RELEASE_NOTES.md @@ -0,0 +1,6 @@ +## Module + +#### 30.11.2021 +#### Version 15.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..ca304e1bd --- /dev/null +++ b/import_partner_employee_image/models/import_employee_image.py @@ -0,0 +1,129 @@ +# -*- 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.")) + + 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'): + link = vals.get('emp_image') + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + 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) + 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..3114e52a3 --- /dev/null +++ b/import_partner_employee_image/models/import_partner_image.py @@ -0,0 +1,139 @@ +# -*- 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.")) + + 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: + link = vals.get('partner_image') + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + 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) + + 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..2e96cb519 --- /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 +16,/home/cybrosys/Downloads/image.jpeg 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/assets/icons/check.png b/import_partner_employee_image/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/check.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/chevron.png b/import_partner_employee_image/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/chevron.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/cogs.png b/import_partner_employee_image/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/cogs.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/consultation.png b/import_partner_employee_image/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/consultation.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/ecom-black.png b/import_partner_employee_image/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/ecom-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/education-black.png b/import_partner_employee_image/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/education-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/hotel-black.png b/import_partner_employee_image/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/hotel-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/license.png b/import_partner_employee_image/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/license.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/lifebuoy.png b/import_partner_employee_image/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/lifebuoy.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/logo.png b/import_partner_employee_image/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/logo.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/manufacturing-black.png b/import_partner_employee_image/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/manufacturing-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/pos-black.png b/import_partner_employee_image/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/pos-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/puzzle.png b/import_partner_employee_image/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/puzzle.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/restaurant-black.png b/import_partner_employee_image/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/restaurant-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/service-black.png b/import_partner_employee_image/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/service-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/trading-black.png b/import_partner_employee_image/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/trading-black.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/training.png b/import_partner_employee_image/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/training.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/update.png b/import_partner_employee_image/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/update.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/user.png b/import_partner_employee_image/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/user.png differ diff --git a/import_partner_employee_image/static/description/assets/icons/wrench.png b/import_partner_employee_image/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/import_partner_employee_image/static/description/assets/icons/wrench.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/1.png b/import_partner_employee_image/static/description/assets/modules/1.png new file mode 100644 index 000000000..924a65196 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/1.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/2.png b/import_partner_employee_image/static/description/assets/modules/2.png new file mode 100644 index 000000000..4e4ea0e51 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/2.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/3.png b/import_partner_employee_image/static/description/assets/modules/3.png new file mode 100644 index 000000000..4be2248a4 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/3.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/4.png b/import_partner_employee_image/static/description/assets/modules/4.png new file mode 100644 index 000000000..3afc14722 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/4.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/5.png b/import_partner_employee_image/static/description/assets/modules/5.png new file mode 100644 index 000000000..cea66b05f Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/5.png differ diff --git a/import_partner_employee_image/static/description/assets/modules/6.png b/import_partner_employee_image/static/description/assets/modules/6.png new file mode 100644 index 000000000..0c9bb377e Binary files /dev/null and b/import_partner_employee_image/static/description/assets/modules/6.png differ diff --git a/import_partner_employee_image/static/description/assets/screenshots/hero.png b/import_partner_employee_image/static/description/assets/screenshots/hero.png new file mode 100644 index 000000000..90e68b1c0 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/screenshots/hero.png differ diff --git a/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_1.png b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_1.png new file mode 100644 index 000000000..d2424f946 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_1.png differ diff --git a/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_2.png b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_2.png new file mode 100644 index 000000000..5c55140c1 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_2.png differ diff --git a/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_3.png b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_3.png new file mode 100644 index 000000000..ca25b7907 Binary files /dev/null and b/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_3.png differ diff --git a/import_partner_employee_image/static/description/assets/screenshots/import_employee_partner_image_4.png b/import_partner_employee_image/static/description/assets/screenshots/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/assets/screenshots/import_employee_partner_image_4.png differ 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..79d144dde 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..622adffab Binary files /dev/null and b/import_partner_employee_image/static/description/icon.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..ee143e071 --- /dev/null +++ b/import_partner_employee_image/static/description/index.html @@ -0,0 +1,587 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+ +
+
+
+
+ +
+
+
+

+ Import Employee/Partner Image

+

+ Manage the Importing of Employee and Partner Image Easily +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

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

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Easy Importing Of Employee and Partner Image.

+
+
+
+
+ +
+
+

+ Image From Url and Local Storage.

+
+
+
+
+ +
+
+

+ It Supports XlSX and CSV Files.

+
+
+ +
+ +
+
+

+ Screenshots +

+
+
+

+ CSV/XLSX Sample File

+

+ Screeshot of the CSV/XLSX sample file is shown below.

+ +
+
+

+ A New Field For Showing Record ID

+

+ A new field is displayed for Showing Record ID.

+ +
+ +
+

+ Wizard to import images

+

+ Employee >> Import Employee Image , This is the Wizard To Import Images.

+ +
+ +
+

+ Access Partner Image from Configuration Menu

+

+ Contacts >> Configuration >> Import Partner Image

+ +
+ +
+ + +
+
+

Suggested Products

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

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

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

Need Help?

+
+
+
+ + +
+ +
+ +
+ +
+ WhatsApp +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ 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 diff --git a/product_import/README.rst b/product_import/README.rst new file mode 100644 index 000000000..2364b4187 --- /dev/null +++ b/product_import/README.rst @@ -0,0 +1,37 @@ +Product Image from URL +====================== +Product Image from URL and Path + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +Credits +------- +* Developers: Mohammed Shahil MP @cybrosys, odoo@cybrosys.com + V14 Minhaj T @cybrosys, odoo@cybrosys.com + V15 Minhaj T @cybrosys, odoo@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 `__ + +Further information +=================== +HTML Description: ``__ + + diff --git a/product_import/__init__.py b/product_import/__init__.py new file mode 100644 index 000000000..a65bb6e3b --- /dev/null +++ b/product_import/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# +from . import wizard +from . import models diff --git a/product_import/__manifest__.py b/product_import/__manifest__.py new file mode 100644 index 000000000..6ff7533ff --- /dev/null +++ b/product_import/__manifest__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2022-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# + +{ + 'name': 'Product Image from URL', + 'summary': 'Product Images from Web URL and Path', + 'version': '15.0.1.0.0', + 'description': """Product Images from Web URL, Product Images from path, local""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'category': 'Sales', + 'license': 'AGPL-3', + 'images': ['static/description/banner.png'], + 'depends': ['sale_management', 'stock'], + 'data': [ + 'security/ir.model.access.csv', + 'views/product_url.xml', + 'wizard/product_import.xml', + ], + 'installable': True, + 'application': False, + 'auto_install': False, +} diff --git a/product_import/demo/.~lock.product.xlsx# b/product_import/demo/.~lock.product.xlsx# new file mode 100644 index 000000000..6b2726f45 --- /dev/null +++ b/product_import/demo/.~lock.product.xlsx# @@ -0,0 +1 @@ +,cybrosys,cybrosys,30.11.2021 23:38,file:///home/cybrosys/.config/libreoffice/4; \ No newline at end of file diff --git a/product_import/demo/phone.jpeg b/product_import/demo/phone.jpeg new file mode 100644 index 000000000..d2aadaa42 Binary files /dev/null and b/product_import/demo/phone.jpeg differ diff --git a/product_import/demo/product.csv b/product_import/demo/product.csv new file mode 100644 index 000000000..7cc59fcda --- /dev/null +++ b/product_import/demo/product.csv @@ -0,0 +1,4 @@ +Product name,product type,Barcode,Price,Image +Laptop,consu,5465465554,25000,https://images-na.ssl-images-amazon.com/images/I/81xe3aoU6BL._AC_SL1500_.jpg +watch,product,7981234174,3500,/home/cybrosys/Desktop/watch.jpg +bike,service,8720132165,2700, diff --git a/product_import/demo/product.xlsx b/product_import/demo/product.xlsx new file mode 100644 index 000000000..352b28f3b Binary files /dev/null and b/product_import/demo/product.xlsx differ diff --git a/product_import/demo/watch.jpg b/product_import/demo/watch.jpg new file mode 100644 index 000000000..13651c909 Binary files /dev/null and b/product_import/demo/watch.jpg differ diff --git a/product_import/models/__init__.py b/product_import/models/__init__.py new file mode 100644 index 000000000..dea9a8296 --- /dev/null +++ b/product_import/models/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# +from . import product_url diff --git a/product_import/models/product_url.py b/product_import/models/product_url.py new file mode 100644 index 000000000..9e4f3f5e8 --- /dev/null +++ b/product_import/models/product_url.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# +import requests +import base64 +from odoo import models, fields, api + + +class ProductImage(models.Model): + _inherit = 'product.template' + + image_url = fields.Char(string='Image URL') + + @api.onchange('image_url') + def _onchange_image_url(self): + """ function to load image from URL """ + image = False + if self.image_url: + image = base64.b64encode(requests.get(self.image_url).content) + self.image_1920 = image + + +class ProductVariantImage(models.Model): + _inherit = 'product.product' + + image_url = fields.Char(string='Image URL') + + @api.onchange('image_url') + def _onchange_image_url(self): + """ function to load image from URL in product variant""" + image = False + if self.image_url: + image = base64.b64encode(requests.get(self.image_url).content) + self.image_1920 = image \ No newline at end of file diff --git a/product_import/security/ir.model.access.csv b/product_import/security/ir.model.access.csv new file mode 100644 index 000000000..bbfb68a12 --- /dev/null +++ b/product_import/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_product_import_product_import,product_import.product_import,model_product_import,base.group_user,1,1,1,1 \ No newline at end of file diff --git a/product_import/static/description/assets/icons/check.png b/product_import/static/description/assets/icons/check.png new file mode 100644 index 000000000..c8e85f51d Binary files /dev/null and b/product_import/static/description/assets/icons/check.png differ diff --git a/product_import/static/description/assets/icons/chevron.png b/product_import/static/description/assets/icons/chevron.png new file mode 100644 index 000000000..2089293d6 Binary files /dev/null and b/product_import/static/description/assets/icons/chevron.png differ diff --git a/product_import/static/description/assets/icons/cogs.png b/product_import/static/description/assets/icons/cogs.png new file mode 100644 index 000000000..95d0bad62 Binary files /dev/null and b/product_import/static/description/assets/icons/cogs.png differ diff --git a/product_import/static/description/assets/icons/consultation.png b/product_import/static/description/assets/icons/consultation.png new file mode 100644 index 000000000..8319d4baa Binary files /dev/null and b/product_import/static/description/assets/icons/consultation.png differ diff --git a/product_import/static/description/assets/icons/ecom-black.png b/product_import/static/description/assets/icons/ecom-black.png new file mode 100644 index 000000000..a9385ff13 Binary files /dev/null and b/product_import/static/description/assets/icons/ecom-black.png differ diff --git a/product_import/static/description/assets/icons/education-black.png b/product_import/static/description/assets/icons/education-black.png new file mode 100644 index 000000000..3eb09b27b Binary files /dev/null and b/product_import/static/description/assets/icons/education-black.png differ diff --git a/product_import/static/description/assets/icons/hotel-black.png b/product_import/static/description/assets/icons/hotel-black.png new file mode 100644 index 000000000..130f613be Binary files /dev/null and b/product_import/static/description/assets/icons/hotel-black.png differ diff --git a/product_import/static/description/assets/icons/license.png b/product_import/static/description/assets/icons/license.png new file mode 100644 index 000000000..a5869797e Binary files /dev/null and b/product_import/static/description/assets/icons/license.png differ diff --git a/product_import/static/description/assets/icons/lifebuoy.png b/product_import/static/description/assets/icons/lifebuoy.png new file mode 100644 index 000000000..658d56ccc Binary files /dev/null and b/product_import/static/description/assets/icons/lifebuoy.png differ diff --git a/product_import/static/description/assets/icons/logo.png b/product_import/static/description/assets/icons/logo.png new file mode 100644 index 000000000..478462d3e Binary files /dev/null and b/product_import/static/description/assets/icons/logo.png differ diff --git a/product_import/static/description/assets/icons/manufacturing-black.png b/product_import/static/description/assets/icons/manufacturing-black.png new file mode 100644 index 000000000..697eb0e9f Binary files /dev/null and b/product_import/static/description/assets/icons/manufacturing-black.png differ diff --git a/product_import/static/description/assets/icons/pos-black.png b/product_import/static/description/assets/icons/pos-black.png new file mode 100644 index 000000000..97c0f90c1 Binary files /dev/null and b/product_import/static/description/assets/icons/pos-black.png differ diff --git a/product_import/static/description/assets/icons/puzzle.png b/product_import/static/description/assets/icons/puzzle.png new file mode 100644 index 000000000..65cf854e7 Binary files /dev/null and b/product_import/static/description/assets/icons/puzzle.png differ diff --git a/product_import/static/description/assets/icons/restaurant-black.png b/product_import/static/description/assets/icons/restaurant-black.png new file mode 100644 index 000000000..4a35eb939 Binary files /dev/null and b/product_import/static/description/assets/icons/restaurant-black.png differ diff --git a/product_import/static/description/assets/icons/service-black.png b/product_import/static/description/assets/icons/service-black.png new file mode 100644 index 000000000..301ab51cb Binary files /dev/null and b/product_import/static/description/assets/icons/service-black.png differ diff --git a/product_import/static/description/assets/icons/trading-black.png b/product_import/static/description/assets/icons/trading-black.png new file mode 100644 index 000000000..9398ba2f1 Binary files /dev/null and b/product_import/static/description/assets/icons/trading-black.png differ diff --git a/product_import/static/description/assets/icons/training.png b/product_import/static/description/assets/icons/training.png new file mode 100644 index 000000000..884ca024d Binary files /dev/null and b/product_import/static/description/assets/icons/training.png differ diff --git a/product_import/static/description/assets/icons/update.png b/product_import/static/description/assets/icons/update.png new file mode 100644 index 000000000..ecbc5a01a Binary files /dev/null and b/product_import/static/description/assets/icons/update.png differ diff --git a/product_import/static/description/assets/icons/user.png b/product_import/static/description/assets/icons/user.png new file mode 100644 index 000000000..6ffb23d9f Binary files /dev/null and b/product_import/static/description/assets/icons/user.png differ diff --git a/product_import/static/description/assets/icons/wrench.png b/product_import/static/description/assets/icons/wrench.png new file mode 100644 index 000000000..6c04dea0f Binary files /dev/null and b/product_import/static/description/assets/icons/wrench.png differ diff --git a/product_import/static/description/assets/modules/approval_image.png b/product_import/static/description/assets/modules/approval_image.png new file mode 100644 index 000000000..84fe94e80 Binary files /dev/null and b/product_import/static/description/assets/modules/approval_image.png differ diff --git a/product_import/static/description/assets/modules/budget_image.png b/product_import/static/description/assets/modules/budget_image.png new file mode 100644 index 000000000..fe6aa6fe4 Binary files /dev/null and b/product_import/static/description/assets/modules/budget_image.png differ diff --git a/product_import/static/description/assets/modules/export_image.png b/product_import/static/description/assets/modules/export_image.png new file mode 100644 index 000000000..4e4ea0e51 Binary files /dev/null and b/product_import/static/description/assets/modules/export_image.png differ diff --git a/product_import/static/description/assets/modules/magento_image.png b/product_import/static/description/assets/modules/magento_image.png new file mode 100644 index 000000000..39de0820f Binary files /dev/null and b/product_import/static/description/assets/modules/magento_image.png differ diff --git a/product_import/static/description/assets/modules/pos_image.png b/product_import/static/description/assets/modules/pos_image.png new file mode 100644 index 000000000..c5932894b Binary files /dev/null and b/product_import/static/description/assets/modules/pos_image.png differ diff --git a/product_import/static/description/assets/modules/shopify_image.png b/product_import/static/description/assets/modules/shopify_image.png new file mode 100644 index 000000000..c6d92c16d Binary files /dev/null and b/product_import/static/description/assets/modules/shopify_image.png differ diff --git a/product_import/static/description/assets/screenshots/hero.png b/product_import/static/description/assets/screenshots/hero.png new file mode 100644 index 000000000..48bbad370 Binary files /dev/null and b/product_import/static/description/assets/screenshots/hero.png differ diff --git a/product_import/static/description/assets/screenshots/product_import_7.png b/product_import/static/description/assets/screenshots/product_import_7.png new file mode 100644 index 000000000..112827960 Binary files /dev/null and b/product_import/static/description/assets/screenshots/product_import_7.png differ diff --git a/product_import/static/description/banner.png b/product_import/static/description/banner.png new file mode 100644 index 000000000..0a798d149 Binary files /dev/null and b/product_import/static/description/banner.png differ diff --git a/product_import/static/description/icon.png b/product_import/static/description/icon.png new file mode 100644 index 000000000..9652bc1bd Binary files /dev/null and b/product_import/static/description/icon.png differ diff --git a/product_import/static/description/index.html b/product_import/static/description/index.html new file mode 100644 index 000000000..f89207d21 --- /dev/null +++ b/product_import/static/description/index.html @@ -0,0 +1,551 @@ +
+
+
+
+ +
+
+
+ Community +
+
+ Enterprise +
+ +
+
+
+
+ +
+
+
+

+ Product Image from URL

+

+ Product Image from URL and Path +

+ +
+
+ + + + +
+
+

+ Overview +

+
+ +
+

+ With the help of this App you can easily load product image from URL and Path, You can also load + images by pasting url in the field.

+ +
+
+ + +
+
+

+ Features +

+
+ +
+
+ +
+
+

+ Product Image URL

+

+ Import Product image from path and URL.

+
+
+
+
+ +
+
+

+ Load Image in Product View with URL

+

+ Load image in product using URL in product view itself.

+
+
+ +
+ +
+
+

+ Screenshots +

+
+
+

+ Add Product Image by Updating URL

+

+ We can add the product image by updating URL in the given field.

+ +
+
+ + +
+
+

Suggested Products

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

Our Services

+
+
+ +
+
+ +
+
+ Odoo + Customization
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Support
+
+ + +
+
+ +
+
+ Hire + Odoo + Developer
+
+ +
+
+ +
+
+ Odoo + Integration
+
+ +
+
+ +
+
+ Odoo + Migration
+
+ + +
+
+ +
+
+ Odoo + Consultancy
+
+ +
+
+ +
+
+ Odoo + Implementation
+
+ +
+
+ +
+
+ Odoo + Licensing Consultancy
+
+
+
+ + + +
+
+
+

Our Industries

+
+
+ +
+
+ +
+ Trading +
+

+ Easily procure + and + sell your products

+
+
+ +
+
+ +
+ POS +
+

+ Easy + configuration + and convivial experience

+
+
+ +
+
+ +
+ Education +
+

+ A platform for + educational management

+
+
+ +
+
+ +
+ Manufacturing +
+

+ Plan, track and + schedule your operations

+
+
+ +
+
+ +
+ E-commerce & Website +
+

+ Mobile + friendly, + awe-inspiring product pages

+
+
+ +
+
+ +
+ Service Management +
+

+ Keep track of + services and invoice

+
+
+ +
+
+ +
+ Restaurant +
+

+ Run your bar or + restaurant methodically

+
+
+ +
+
+ +
+ Hotel Management +
+

+ An + all-inclusive + hotel management application

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

Need Help?

+
+
+
+ + +
+ +
+ +
+ +
+ WhatsApp +
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + +
\ No newline at end of file diff --git a/product_import/views/product_url.xml b/product_import/views/product_url.xml new file mode 100644 index 000000000..eab94f692 --- /dev/null +++ b/product_import/views/product_url.xml @@ -0,0 +1,29 @@ + + + + Product URL + product.template + + + + + + + + + + + + Product URL + product.product + + + + + + + + + + + \ No newline at end of file diff --git a/product_import/wizard/__init__.py b/product_import/wizard/__init__.py new file mode 100644 index 000000000..157975fbb --- /dev/null +++ b/product_import/wizard/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# +from . import product_import diff --git a/product_import/wizard/product_import.py b/product_import/wizard/product_import.py new file mode 100644 index 000000000..075156eec --- /dev/null +++ b/product_import/wizard/product_import.py @@ -0,0 +1,146 @@ +# -*- coding: utf-8 -*- +############################################################################# +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2019-TODAY Cybrosys Technologies(). +# Author: Mohammed Shahil MP @cybrosys(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 . +# +############################################################################# +import tempfile +import binascii +import base64 +import certifi +import urllib3 +import xlrd +from odoo.exceptions import Warning +from odoo import models, fields, _ + + +class ProductImport(models.Model): + + _name = 'product.import' + + file = fields.Binary(string="Upload File") + file_name = fields.Char(string="File Name") + option = fields.Selection([ + ('csv', 'CSV'), + ('xlsx', 'XLSX')], default='csv') + + def import_file(self): + """ function to import product details from csv and xlsx file """ + if self.option == 'csv': + try: + product_temp_data = self.env['product.template'].search([]) + file = base64.b64decode(self.file) + file_string = file.decode('utf-8') + file_string = file_string.split('\n') + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + except: + raise Warning(_("Please choose the correct file!")) + + firstline = True + for file_item in file_string: + if firstline: + firstline = False + continue + product_temp = self.env['product.template'].search([('name', '=', file_item.split(",")[0])], limit=0) + if not product_temp.id: + if file_item.split(",")[0]: + if "http://" in file_item.split(",")[4] or "https://" in file_item.split(",")[4]: + link = file_item.split(",")[4] + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + product_name = { + 'name': file_item.split(",")[0], + 'type': file_item.split(",")[1], + 'barcode': file_item.split(",")[2], + 'list_price': file_item.split(",")[3], + 'image_1920': image_thumbnail, + } + product_line = product_temp_data.create(product_name) + elif '/home' in file_item.split(",")[4]: + with open(file_item.split(",")[4], 'rb') as file: + data = base64.b64encode(file.read()) + product_name = { + 'name': file_item.split(",")[0], + 'type': file_item.split(",")[1], + 'barcode': file_item.split(",")[2], + 'list_price': file_item.split(",")[3], + 'image_1920': data, + } + product_line = product_temp_data.create(product_name) + else: + product_name = { + 'name': file_item.split(",")[0], + 'type': file_item.split(",")[1], + 'barcode': file_item.split(",")[2], + 'list_price': file_item.split(",")[3], + } + product_line = product_temp_data.create(product_name) + + if self.option == 'xlsx': + try: + product_temp_data = self.env['product.template'].search([]) + file_string = tempfile.NamedTemporaryFile(suffix=".xlsx") + file_string.write(binascii.a2b_base64(self.file)) + book = xlrd.open_workbook(file_string.name) + sheet = book.sheet_by_index(0) + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + except: + raise Warning(_("Please choose the correct file")) + + startline = True + for i in range(sheet.nrows): + if startline: + startline = False + else: + line = list(sheet.row_values(i)) + product_temp = self.env['product.template'].search([('name', '=', line[0])], limit=0) + if not product_temp.id: + if line[0]: + if "http://" in line[4] or "https://" in line[4]: + link = line[4] + image_response = http.request('GET', link) + image_thumbnail = base64.b64encode(image_response.data) + product_name = { + 'name': line[0], + 'type': line[1], + 'barcode': line[2], + 'list_price': line[3], + 'image_1920': image_thumbnail, + } + product_line = product_temp_data.create(product_name) + elif "/home" in line[4]: + with open(line[4], 'rb') as file: + data = base64.b64encode(file.read()) + product_name = { + 'name': line[0], + 'type': line[1], + 'barcode': line[2], + 'list_price': line[3], + 'image_1920': data, + } + product_line = product_temp_data.create(product_name) + else: + product_name = { + 'name': line[0], + 'type': line[1], + 'barcode': line[2], + 'list_price': line[3], + } + product_line = product_temp_data.create(product_name) diff --git a/product_import/wizard/product_import.xml b/product_import/wizard/product_import.xml new file mode 100644 index 000000000..b53c29a0f --- /dev/null +++ b/product_import/wizard/product_import.xml @@ -0,0 +1,36 @@ + + + + + Import Product + product.import + +
+ + + + +
+
+
+
+
+ + + Import Product + product.import + ir.actions.act_window + tree,form + + {} + new + + + + +