@ -0,0 +1,57 @@ |
|||
.. image:: https://img.shields.io/badge/license-LGPL--3-green.svg |
|||
:target: https://www.gnu.org/licenses/lgpl-3.0-standalone.html |
|||
:alt: License: LGPL-3 |
|||
|
|||
Product Image from URL |
|||
====================== |
|||
Product Image from URL and Local Paths. |
|||
|
|||
Features |
|||
======== |
|||
* This module enables to add Product Images from Web URLs and Local Paths. |
|||
|
|||
Configuration |
|||
============= |
|||
Nothing to configure. |
|||
|
|||
License |
|||
------- |
|||
General Public License, Version 3 (LGPL v3). |
|||
(https://www.gnu.org/licenses/lgpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
* Developers: Mohammed Shahil MP, |
|||
(V14) Minhaj T, |
|||
(V15) Minhaj T, |
|||
(V16) Amaya Aravind, |
|||
(V17) Aysha Shalin, |
|||
(V18) Sreerag PM, |
|||
|
|||
Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
* Website : https://cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit `Our Website <https://cybrosys.com/>`__ |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,23 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Sreerag PM (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import wizard |
|||
from . import models |
@ -0,0 +1,45 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Sreerag PM (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'Product Image from URL', |
|||
'version': '18.0.1.0.0', |
|||
'category': 'Sales', |
|||
'summary': 'Product Images from Web URLs and Local Paths', |
|||
'description': """This module enables to add Product Images from Web URLs |
|||
and Local Paths""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': "https://www.cybrosys.com", |
|||
'depends': ['sale'], |
|||
'data': [ |
|||
'security/ir.model.access.csv', |
|||
'views/product_template_views.xml', |
|||
'views/product_product_views.xml', |
|||
'wizard/product_import_views.xml', |
|||
], |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'LGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False, |
|||
} |
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 883 KiB |
@ -0,0 +1,6 @@ |
|||
## Module <product_import> |
|||
|
|||
#### 04.02.2025 |
|||
#### Version 18.0.1.0.0 |
|||
##### ADD |
|||
- Initial Commit for Product Image from URL |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Sreerag PM (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import product_template |
@ -0,0 +1,103 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>) |
|||
# Author: Sreerag PM (odoo@cybrosys.com) |
|||
# |
|||
# You can modify it under the terms of the GNU LESSER |
|||
# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE |
|||
# (LGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
import base64 |
|||
import requests |
|||
from odoo import models, fields, api, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class ProductTemplate(models.Model): |
|||
""" Inheriting 'product.template' for adding image url """ |
|||
_inherit = 'product.template' |
|||
|
|||
image_url = fields.Char(string='Image URL', help="Url of Image") |
|||
image_added = fields.Binary("Image (1920x1920)", |
|||
compute='_compute_image_added', store=True, |
|||
help="Uploaded Image") |
|||
|
|||
@api.depends('image_url') |
|||
def _compute_image_added(self): |
|||
""" Function to load an image from URL or local file path """ |
|||
for record in self: |
|||
image = False |
|||
if record.image_url: |
|||
if record.image_url.startswith(('http://', 'https://')): |
|||
# Load image from URL |
|||
try: |
|||
image = base64.b64encode( |
|||
requests.get(record.image_url).content) |
|||
except Exception as e: |
|||
raise UserError( |
|||
_("Error loading image from URL: %s" % str(e))) |
|||
else: |
|||
# Load image from local file path |
|||
try: |
|||
with open(record.image_url, 'rb') as image_file: |
|||
image = base64.b64encode(image_file.read()) |
|||
except Exception as e: |
|||
raise UserError( |
|||
_("Error loading image from local path: %s" % str( |
|||
e))) |
|||
|
|||
# Set the binary image fields |
|||
if image: |
|||
record.image_1920 = image |
|||
record.image_added = image # To update your custom field too |
|||
|
|||
|
|||
class ProductVariantImage(models.Model): |
|||
""" Inheriting 'product.product' for adding image url """ |
|||
_inherit = 'product.product' |
|||
|
|||
image_url = fields.Char(string='Image URL', help="Url of Image") |
|||
image_added = fields.Binary("Image (1920x1920)", |
|||
compute='_compute_image_added', store=True, |
|||
help="Uploaded Image") |
|||
|
|||
@api.depends('image_url') |
|||
def _compute_image_added(self): |
|||
""" Function to load an image from URL or local file path """ |
|||
for record in self: |
|||
image = False |
|||
if record.image_url: |
|||
if record.image_url.startswith(('http://', 'https://')): |
|||
# Load image from URL |
|||
try: |
|||
image = base64.b64encode( |
|||
requests.get(record.image_url).content) |
|||
except Exception as e: |
|||
raise UserError( |
|||
_("Error loading image from URL: %s" % str(e))) |
|||
else: |
|||
# Load image from local file path |
|||
try: |
|||
with open(record.image_url, 'rb') as image_file: |
|||
image = base64.b64encode(image_file.read()) |
|||
except Exception as e: |
|||
raise UserError( |
|||
_("Error loading image from local path: %s" % str( |
|||
e))) |
|||
|
|||
# Set the binary image fields |
|||
if image: |
|||
record.image_1920 = image |
|||
record.image_added = image # To update your custom field too |
|
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 628 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 209 KiB |
After Width: | Height: | Size: 109 KiB |
After Width: | Height: | Size: 495 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 624 B |
After Width: | Height: | Size: 136 KiB |
After Width: | Height: | Size: 214 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 929 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 542 B |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 600 B |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 462 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 926 B |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 800 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 189 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 875 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 710 KiB |
After Width: | Height: | Size: 776 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 738 KiB |
After Width: | Height: | Size: 131 KiB |
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 150 KiB |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 148 KiB |
After Width: | Height: | Size: 134 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 316 KiB |
After Width: | Height: | Size: 117 KiB |
After Width: | Height: | Size: 356 KiB |
After Width: | Height: | Size: 660 KiB |
After Width: | Height: | Size: 880 KiB |
After Width: | Height: | Size: 714 KiB |
After Width: | Height: | Size: 41 KiB |
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<!-- Adding field for image url in form view of 'product.product' --> |
|||
<record id="product_normal_form_view" model="ir.ui.view"> |
|||
<field name="name">product.normal.form.view.inherit.product.import</field> |
|||
<field name="model">product.product</field> |
|||
<field name="inherit_id" ref="product.product_normal_form_view"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="name" position="after"> |
|||
<field name="image_url" class="oe_edit_only"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="UTF-8" ?> |
|||
<odoo> |
|||
<!-- Adding field for image url in form view of 'product.template' --> |
|||
<record id="product_template_only_form_view" model="ir.ui.view"> |
|||
<field name="name">product.template.only.form.view.inherit.product.import</field> |
|||
<field name="model">product.template</field> |
|||
<field name="inherit_id" ref="product.product_template_only_form_view"/> |
|||
<field name="arch" type="xml"> |
|||
<field name="name" position="after"> |
|||
<field name="image_url" class="oe_edit_only"/> |
|||
</field> |
|||
</field> |
|||
</record> |
|||
</odoo> |