diff --git a/product_import/README.rst b/product_import/README.rst new file mode 100644 index 0000000..dca56bf --- /dev/null +++ b/product_import/README.rst @@ -0,0 +1,49 @@ +.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg + :target: http://www.gnu.org/licenses/agpl-3.0-standalone.html + :alt: License: AGPL-3 + +Product Image from URL +====================== +Product Image from URL and Path + +Configuration +============= +* No additional configurations needed + +Company +------- +* `Cybrosys Techno Solutions `__ + +License +------- +GNU AFFERO GENERAL PUBLIC LICENSE Version 3 (AGPL v3) +(https://www.odoo.com/documentation/user/16.0/legal/licenses/licenses.html) + +Credits +------- +* Developers: Mohammed Shahil MP @cybrosys, Contact: odoo@cybrosys.com + (V14) Minhaj T @cybrosys, Contact: odoo@cybrosys.com + (V15) Minhaj T @cybrosys, Contact: odoo@cybrosys.com + (V16) Amaya Aravind EV @cybrosys, 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 `__ + +Further information +=================== +HTML Description: ``__ diff --git a/product_import/__init__.py b/product_import/__init__.py new file mode 100644 index 0000000..370a5f6 --- /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 models +from . import wizard diff --git a/product_import/__manifest__.py b/product_import/__manifest__.py new file mode 100644 index 0000000..639860a --- /dev/null +++ b/product_import/__manifest__.py @@ -0,0 +1,47 @@ +# -*- 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', + 'version': '16.0.1.1.1', + 'category': 'Sales', + 'summary': 'Product Images from Web URL and Path', + 'description': 'users can effortlessly import images by providing a web ' + 'URL, ensuring swift retrieval from online sources. ' + 'Simultaneously, users can opt for a local import, simply ' + 'specifying the file path.', + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'maintainer': 'Cybrosys Techno Solutions', + 'website': 'https://www.cybrosys.com', + 'depends': ['sale_management'], + 'data': [ + 'security/ir.model.access.csv', + 'views/product_product_views.xml', + 'views/product_template_views.xml', + 'wizard/product_import_views.xml', + ], + 'images': ['static/description/banner.png'], + 'license': 'AGPL-3', + 'installable': True, + 'auto_install': False, + 'application': False, +} diff --git a/product_import/demo/phone.jpeg b/product_import/demo/phone.jpeg new file mode 100644 index 0000000..d2aadaa 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 0000000..ff4e78c --- /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 +smart phone,product,7081234174,35000,/home/cybrosys/Desktop/phone.jpeg +bike,service,8720132165,2700, diff --git a/product_import/demo/product.xlsx b/product_import/demo/product.xlsx new file mode 100644 index 0000000..7dc4ac3 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 0000000..13651c9 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 0000000..a95b0d2 --- /dev/null +++ b/product_import/models/__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 product_product +from . import product_template diff --git a/product_import/models/product_product.py b/product_import/models/product_product.py new file mode 100644 index 0000000..6a58e8a --- /dev/null +++ b/product_import/models/product_product.py @@ -0,0 +1,64 @@ +# -*- 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 base64 +import certifi +import urllib3 +from odoo import api, fields, models, _ +from odoo.exceptions import UserError + + +class ProductProduct(models.Model): + """Inherit the model to add fields and function""" + _inherit = 'product.product' + + image_url = fields.Char(string='Image URL', help='Image URL or Path') + image_added = fields.Binary("Image (1920x1920)", + compute='_compute_image_added', store=True) + + @api.depends('image_url') + def _compute_image_added(self): + """ Function to load an image from URL or local file path """ + image = False + if self.image_url: + if self.image_url.startswith(('http://', 'https://')): + # Load image from URL + try: + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + image_response = http.request('GET', self.image_url) + image = base64.b64encode(image_response.data) + except Exception as e: + # Handle URL loading errors + raise UserError( + _(f"Error loading image from URL: {str(e)}")) + else: + # Load image from local file path + try: + with open(self.image_url, 'rb') as image_file: + image = base64.b64encode(image_file.read()) + except Exception as e: + # Handle local file loading errors + raise UserError( + _(f"Error loading image from local path: {str(e)}")) + image_added = image + if image_added: + self.image_1920 = image_added diff --git a/product_import/models/product_template.py b/product_import/models/product_template.py new file mode 100644 index 0000000..00d900c --- /dev/null +++ b/product_import/models/product_template.py @@ -0,0 +1,64 @@ +# -*- 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 base64 +import certifi +import urllib3 +from odoo import api, fields, models, _ +from odoo.exceptions import UserError + + +class ProductTemplate(models.Model): + """Inherit the model to add fields and function""" + _inherit = 'product.template' + + image_url = fields.Char(string='Image URL', help='Image URL or Path') + image_added = fields.Binary("Image (1920x1920)", + compute='_compute_image_added', store=True) + + @api.depends('image_url') + def _compute_image_added(self): + """ Function to load an image from URL or local file path """ + image = False + if self.image_url: + if self.image_url.startswith(('http://', 'https://')): + # Load image from URL + try: + http = urllib3.PoolManager(cert_reqs='CERT_REQUIRED', + ca_certs=certifi.where()) + image_response = http.request('GET', self.image_url) + image = base64.b64encode(image_response.data) + except Exception as e: + # Handle URL loading errors + raise UserError( + _(f"Error loading image from URL: {str(e)}")) + else: + # Load image from local file path + try: + with open(self.image_url, 'rb') as image_file: + image = base64.b64encode(image_file.read()) + except Exception as e: + # Handle local file loading errors + raise UserError( + _(f"Error loading image from local path: {str(e)}")) + image_added = image + if image_added: + self.image_1920 = image_added diff --git a/product_import/security/ir.model.access.csv b/product_import/security/ir.model.access.csv new file mode 100644 index 0000000..4c768f5 --- /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,access.product.import,model_product_import,base.group_user,1,1,1,1 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 0000000..c8e85f5 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 0000000..2089293 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 0000000..95d0bad 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 0000000..8319d4b 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 0000000..a9385ff 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 0000000..3eb09b2 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 0000000..130f613 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 0000000..a586979 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 0000000..658d56c Binary files /dev/null and b/product_import/static/description/assets/icons/lifebuoy.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 0000000..697eb0e 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 0000000..97c0f90 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 0000000..65cf854 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 0000000..4a35eb9 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 0000000..301ab51 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 0000000..9398ba2 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 0000000..884ca02 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 0000000..ecbc5a0 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 0000000..6ffb23d 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 0000000..6c04dea Binary files /dev/null and b/product_import/static/description/assets/icons/wrench.png differ diff --git a/product_import/static/description/assets/misc/categories.png b/product_import/static/description/assets/misc/categories.png new file mode 100644 index 0000000..bedf1e0 Binary files /dev/null and b/product_import/static/description/assets/misc/categories.png differ diff --git a/product_import/static/description/assets/misc/check-box.png b/product_import/static/description/assets/misc/check-box.png new file mode 100644 index 0000000..42caf24 Binary files /dev/null and b/product_import/static/description/assets/misc/check-box.png differ diff --git a/product_import/static/description/assets/misc/compass.png b/product_import/static/description/assets/misc/compass.png new file mode 100644 index 0000000..d5fed8f Binary files /dev/null and b/product_import/static/description/assets/misc/compass.png differ diff --git a/product_import/static/description/assets/misc/corporate.png b/product_import/static/description/assets/misc/corporate.png new file mode 100644 index 0000000..2eb13ed Binary files /dev/null and b/product_import/static/description/assets/misc/corporate.png differ diff --git a/product_import/static/description/assets/misc/customer-support.png b/product_import/static/description/assets/misc/customer-support.png new file mode 100644 index 0000000..79efc72 Binary files /dev/null and b/product_import/static/description/assets/misc/customer-support.png differ diff --git a/product_import/static/description/assets/misc/cybrosys-logo.png b/product_import/static/description/assets/misc/cybrosys-logo.png new file mode 100644 index 0000000..cc3cc0c Binary files /dev/null and b/product_import/static/description/assets/misc/cybrosys-logo.png differ diff --git a/product_import/static/description/assets/misc/features.png b/product_import/static/description/assets/misc/features.png new file mode 100644 index 0000000..b41769f Binary files /dev/null and b/product_import/static/description/assets/misc/features.png differ diff --git a/product_import/static/description/assets/misc/logo.png b/product_import/static/description/assets/misc/logo.png new file mode 100644 index 0000000..478462d Binary files /dev/null and b/product_import/static/description/assets/misc/logo.png differ diff --git a/product_import/static/description/assets/misc/pictures.png b/product_import/static/description/assets/misc/pictures.png new file mode 100644 index 0000000..56d255f Binary files /dev/null and b/product_import/static/description/assets/misc/pictures.png differ diff --git a/product_import/static/description/assets/misc/pie-chart.png b/product_import/static/description/assets/misc/pie-chart.png new file mode 100644 index 0000000..426e052 Binary files /dev/null and b/product_import/static/description/assets/misc/pie-chart.png differ diff --git a/product_import/static/description/assets/misc/right-arrow.png b/product_import/static/description/assets/misc/right-arrow.png new file mode 100644 index 0000000..730984a Binary files /dev/null and b/product_import/static/description/assets/misc/right-arrow.png differ diff --git a/product_import/static/description/assets/misc/star.png b/product_import/static/description/assets/misc/star.png new file mode 100644 index 0000000..2eb9ab2 Binary files /dev/null and b/product_import/static/description/assets/misc/star.png differ diff --git a/product_import/static/description/assets/misc/support.png b/product_import/static/description/assets/misc/support.png new file mode 100644 index 0000000..4f18b8b Binary files /dev/null and b/product_import/static/description/assets/misc/support.png differ diff --git a/product_import/static/description/assets/misc/whatsapp.png b/product_import/static/description/assets/misc/whatsapp.png new file mode 100644 index 0000000..d513a53 Binary files /dev/null and b/product_import/static/description/assets/misc/whatsapp.png differ diff --git a/product_import/static/description/assets/modules/1.png b/product_import/static/description/assets/modules/1.png new file mode 100644 index 0000000..5238bde Binary files /dev/null and b/product_import/static/description/assets/modules/1.png differ diff --git a/product_import/static/description/assets/modules/2.png b/product_import/static/description/assets/modules/2.png new file mode 100644 index 0000000..1ae7cfe Binary files /dev/null and b/product_import/static/description/assets/modules/2.png differ diff --git a/product_import/static/description/assets/modules/3.png b/product_import/static/description/assets/modules/3.png new file mode 100644 index 0000000..3c3ff1a Binary files /dev/null and b/product_import/static/description/assets/modules/3.png differ diff --git a/product_import/static/description/assets/modules/4.png b/product_import/static/description/assets/modules/4.png new file mode 100644 index 0000000..3fae463 Binary files /dev/null and b/product_import/static/description/assets/modules/4.png differ diff --git a/product_import/static/description/assets/modules/5.gif b/product_import/static/description/assets/modules/5.gif new file mode 100644 index 0000000..2a5f8e6 Binary files /dev/null and b/product_import/static/description/assets/modules/5.gif differ diff --git a/product_import/static/description/assets/modules/6.png b/product_import/static/description/assets/modules/6.png new file mode 100644 index 0000000..7f28152 Binary files /dev/null and b/product_import/static/description/assets/modules/6.png differ diff --git a/product_import/static/description/assets/screenshots/1.png b/product_import/static/description/assets/screenshots/1.png new file mode 100644 index 0000000..8b95da2 Binary files /dev/null and b/product_import/static/description/assets/screenshots/1.png differ diff --git a/product_import/static/description/assets/screenshots/3.png b/product_import/static/description/assets/screenshots/3.png new file mode 100644 index 0000000..239f737 Binary files /dev/null and b/product_import/static/description/assets/screenshots/3.png differ diff --git a/product_import/static/description/assets/screenshots/4.png b/product_import/static/description/assets/screenshots/4.png new file mode 100644 index 0000000..4507cad Binary files /dev/null and b/product_import/static/description/assets/screenshots/4.png differ diff --git a/product_import/static/description/assets/screenshots/5.png b/product_import/static/description/assets/screenshots/5.png new file mode 100644 index 0000000..a034045 Binary files /dev/null and b/product_import/static/description/assets/screenshots/5.png differ diff --git a/product_import/static/description/assets/screenshots/6.png b/product_import/static/description/assets/screenshots/6.png new file mode 100644 index 0000000..ee203e2 Binary files /dev/null and b/product_import/static/description/assets/screenshots/6.png differ diff --git a/product_import/static/description/assets/screenshots/hero.gif b/product_import/static/description/assets/screenshots/hero.gif new file mode 100644 index 0000000..8877744 Binary files /dev/null and b/product_import/static/description/assets/screenshots/hero.gif differ diff --git a/product_import/static/description/banner.png b/product_import/static/description/banner.png new file mode 100644 index 0000000..ed99b59 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 0000000..bb53c60 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 0000000..72c97b0 --- /dev/null +++ b/product_import/static/description/index.html @@ -0,0 +1,543 @@ +
+ +
+ +
+
+ Community +
+
+ Enterprise +
+
+ Odoo.sh +
+
+
+ + + +

Product Image from URL

+

Product Image from URL and Path

+ + + +
+ + +
+
+ +
+

Explore This + Module

+
+ + + + +
+
+ +
+

Overview +

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

Features +

+
+
+
+
+ + Load image in product using URL in product view itself. +
+
+ + Import Product image from path and URL. +
+
+
+ + + +
+
+ +
+

Screenshots +

+
+
+
+ +
+

Paste image URL in the view or Path.

+

The image will change when the record gets saved.

+ +
+
+

Choose the type of file to import products.

+ +
+
+

Importing product from CSV file.

+

You can use both URL and path for importing image.

+

The fields in the file must need to be in the following format.

+ +
+
+

Importing product from xlsx file.

+

You can use both URL and path for importing image.

+

The fields in the file must need to be in the following format.

+ +
+
+

The products details with image will be imported.

+ +
+
+

(The example format for csv and xlsx are added in the module.)

+
+ +
+
+ + +
+
+ +
+

Related + 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

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

Support +

+
+
+
+
+
+
+ +
+
+

Need Help?

+

Got questions or need help? Get in touch.

+ +

+ odoo@cybrosys.com

+
+
+
+
+
+
+
+ +
+
+

WhatsApp

+

Say hi to us on WhatsApp!

+ +

+91 86068 + 27707

+
+
+
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/product_import/views/product_product_views.xml b/product_import/views/product_product_views.xml new file mode 100644 index 0000000..62f9f10 --- /dev/null +++ b/product_import/views/product_product_views.xml @@ -0,0 +1,15 @@ + + + + + product.product.only.form.view.inherit.product.import + product.product + + + + + + + diff --git a/product_import/views/product_template_views.xml b/product_import/views/product_template_views.xml new file mode 100644 index 0000000..1ec7216 --- /dev/null +++ b/product_import/views/product_template_views.xml @@ -0,0 +1,15 @@ + + + + + product.template.only.form.view.inherit.product.import + product.template + + + + + + + diff --git a/product_import/wizard/__init__.py b/product_import/wizard/__init__.py new file mode 100644 index 0000000..157975f --- /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 0000000..81d298b --- /dev/null +++ b/product_import/wizard/product_import.py @@ -0,0 +1,128 @@ +# -*- 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 base64 +import binascii +import tempfile +import certifi +import urllib3 +import xlrd +from odoo.exceptions import ValidationError +from odoo import models, fields, _ + + +class ProductImport(models.Model): + """Model to import the product""" + _name = 'product.import' + _description = '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 Exception: + raise ValidationError(_("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: + file_parts = file_item.split(",") + if len(file_parts) >= 5: + name, detailed_type, barcode, list_price, file_path_or_url = file_parts[:5] + product_name = { + 'name': name, + 'detailed_type': detailed_type, + 'barcode': barcode, + 'list_price': list_price, + } + if (file_path_or_url.startswith("http://") or + file_path_or_url.startswith("https://")): + image_response = http.request('GET', + file_path_or_url) + image_thumbnail = base64.b64encode( + image_response.data) + product_name['image_1920'] = image_thumbnail + elif file_path_or_url.startswith('/home'): + with open(file_path_or_url, 'rb') as file: + data = base64.b64encode(file.read()) + product_name['image_1920'] = data + product_temp_data.create(product_name) + else: + raise ValidationError( + _("Add the product which is not available in products") + ) + elif self.option == 'xlsx': + try: + product_temp_data = self.env['product.template'] + 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 ValidationError(_("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 product_temp.id: + raise ValidationError( + _("Add the product which is not available in" + " products")) + 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) + elif "/home" in line[4]: + with open(line[4], 'rb') as file: + image_thumbnail = base64.b64encode(file.read()) + else: + image_thumbnail = False # or None + product_name = { + 'name': line[0], + 'detailed_type': line[1], + 'barcode': line[2], + 'list_price': line[3], + 'image_1920': image_thumbnail, + } + product_temp_data.create(product_name) diff --git a/product_import/wizard/product_import_views.xml b/product_import/wizard/product_import_views.xml new file mode 100644 index 0000000..5a81966 --- /dev/null +++ b/product_import/wizard/product_import_views.xml @@ -0,0 +1,35 @@ + + + + + product.import.view.form + product.import + +
+ + + + +
+
+
+
+
+ + + Import Product + product.import + ir.actions.act_window + tree,form + + {} + new + + + +