Skip to content

Commit

Permalink
[MIG] product_multi_image: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
IJOL committed Aug 19, 2024
1 parent 8a7da77 commit e4b0c54
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion product_multi_image/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl-3).

from . import models
from .hooks import pre_init_hook, uninstall_hook
from .hooks import post_init_hook, uninstall_hook
4 changes: 2 additions & 2 deletions product_multi_image/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

{
"name": "Multiple Images in Products",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"author": "Antiun Ingeniería, "
"Tecnativa, "
"LasLabs, "
"Odoo Community Association (OCA)",
"license": "AGPL-3",
"website": "https://github.com/OCA/product-attribute",
"category": "Sales Management",
"pre_init_hook": "pre_init_hook",
"pre_init_hook": "post_init_hook",
"uninstall_hook": "uninstall_hook",
"depends": [
"base_multi_image",
Expand Down
8 changes: 4 additions & 4 deletions product_multi_image/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@

try:
from odoo.addons.base_multi_image.hooks import (
pre_init_hook_for_submodules,
post_init_hook_for_submodules,
uninstall_hook_for_submodules,
)
except ImportError:
_logger.info("Cannot import base_multi_image hooks")


def pre_init_hook(cr):
pre_init_hook_for_submodules(cr, "product.template", "image_1920")
pre_init_hook_for_submodules(cr, "product.product", "image_variant_1920")
def post_init_hook(cr):
post_init_hook_for_submodules(cr, "product.template", "image_1920")
post_init_hook_for_submodules(cr, "product.product", "image_variant_1920")


def uninstall_hook(cr, registry):
Expand Down
4 changes: 2 additions & 2 deletions product_multi_image/models/product_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _compute_image_ids(self):
)
product.image_ids = [(6, 0, images.ids)]
if product.image_ids:
product.image_1920 = product.image_ids[0].image_main
product.image_1920 = product.with_context(bin_size=False).image_ids[0].image_1920

def _inverse_image_ids(self):
for product in self:
Expand Down Expand Up @@ -66,7 +66,7 @@ def _inverse_image_ids(self):
# Leave the images for the rest of the variants
image.product_variant_ids = [(6, 0, variants.ids)]
product.image_1920 = (
False if len(product.image_ids) < 1 else product.image_ids[0].image_main
False if len(product.image_ids) < 1 else product.image_ids[0].image_1920
)

def unlink(self):
Expand Down
6 changes: 3 additions & 3 deletions product_multi_image/views/image_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="inherit_id" ref="base_multi_image.image_form_view" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="file_db_store" position="after">
<field name="load_from" position="after">
<field
name="product_variant_ids"
widget="many2many_tags"
Expand All @@ -26,11 +26,11 @@
<field name="inherit_id" ref="base_multi_image.image_kanban_view" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<xpath expr="/kanban/field[@name='storage']" position="after">
<xpath expr="/kanban/field[@name='name']" position="after">
<field name="product_variant_ids" />
<field name="product_variant_count" />
</xpath>
<xpath expr="//field[@name='storage']/../.." position="after">
<xpath expr="//field[@name='name']/../.." position="after">
<tr>
<td>
<span t-if="record.product_variant_count.value == 0">
Expand Down
1 change: 1 addition & 0 deletions setup/product_multi_image/odoo/addons/product_multi_image
6 changes: 6 additions & 0 deletions setup/product_multi_image/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)

0 comments on commit e4b0c54

Please sign in to comment.