Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

product_multi_image broken if no image is on the template #228

Closed
simahawk opened this issue Feb 8, 2017 · 7 comments
Closed

product_multi_image broken if no image is on the template #228

simahawk opened this issue Feb 8, 2017 · 7 comments

Comments

@simahawk
Copy link
Contributor

simahawk commented Feb 8, 2017

Context:

  • v9
  • template with no images, variant with no images

Issue:
If you add an image to a variant:

  File "/opt/odoo/external-src/product-attribute/product_multi_image/models/product_product.py", line 44, in _inverse_main_image_medium
    product._inverse_main_image(product.image_main_medium)
  File "/opt/odoo/src/openerp/api.py", line 248, in wrapper
    return new_api(self, *args, **kwargs)
  File "/opt/odoo/external-src/product-attribute/product_multi_image/models/product_product.py", line 29, in _inverse_main_image
    product.image_ids[0].write({
  File "/opt/odoo/src/openerp/models.py", line 5756, in __getitem__
    return self._browse(self.env, (self._ids[key],))
IndexError: tuple index out of range

We miss a safe check here https://github.com/OCA/product-attribute/blob/9.0/product_multi_image/models/product_product.py#L28

@pedrobaeza
Copy link
Member

Well, it's supposed that if you have an image, automatically gets the first image also on multi-images, so this is the part we have to check. Why don't you have this first image? Maybe some piece of code that makes it?

@simahawk
Copy link
Contributor Author

simahawk commented Feb 8, 2017

hmm, I don't get this :)

It's pretty easy to replicate:

  1. create a product template w/ variants
  2. go to one of the variants
  3. add an image
  4. save => kabooom! :)

So, are we expecting to not be able to add images to variants IF the template has no image? If yes, we should make variant field readonly, otherwise we need to fix that method to write on image_ids only if there's something there or to add a new image if none.

@pedrobaeza
Copy link
Member

Uhm, let me check then. The initial idea is:

  • When you add an image on a variant, that image is registered also on the template, but with only that variant allowed.
  • When you add an image on the template, all variants get this image, and no variant restriction is applied.
  • From template, you can change the variants that are going to use this image.
  • From a variant, if you upload again an existing image, it's matched and the existing image adds the variant as allowed to see that image.

In this logic, that was made for v8, I don't know if something has changed in the port to v9.

simahawk added a commit to simahawk/product-attribute that referenced this issue Feb 8, 2017
@simahawk
Copy link
Contributor Author

simahawk commented Feb 8, 2017

That makes sense, the problem is that it's broken because it tries to write on product.image_ids[0] only because image is valued. Adding a new image is not taken into account at all.

@simahawk
Copy link
Contributor Author

simahawk commented Feb 8, 2017

lasley pushed a commit to LasLabs/product-attribute that referenced this issue Feb 11, 2017
@lasley
Copy link

lasley commented Feb 15, 2017

@simahawk - Can this be closed now?

@simahawk
Copy link
Contributor Author

yup!

lasley pushed a commit to LasLabs/product-attribute that referenced this issue Mar 2, 2017
P4R pushed a commit to diagramsoftware/product-attribute that referenced this issue Jan 4, 2018
qtheuret pushed a commit to qtheuret/product-attribute that referenced this issue Jun 8, 2018
qtheuret pushed a commit to qtheuret/product-attribute that referenced this issue Jun 12, 2018
FFernandez-PlanetaTIC pushed a commit to PlanetaTIC/product-attribute that referenced this issue Jul 2, 2018
pedrobaeza pushed a commit to PlanetaTIC/product-attribute that referenced this issue Jul 21, 2018
FFernandez-PlanetaTIC pushed a commit to PlanetaTIC/product-attribute that referenced this issue Apr 11, 2019
MPoch-PlanetaTIC pushed a commit to PlanetaTIC/product-attribute that referenced this issue Jun 12, 2020
hailangvn pushed a commit to hailangvn/product-attribute that referenced this issue May 21, 2021
hailangvn pushed a commit to hailangvn/product-attribute that referenced this issue Jan 24, 2022
MPoch-PlanetaTIC pushed a commit to PlanetaTIC/product-attribute that referenced this issue Feb 16, 2022
hailangvn pushed a commit to hailangvn/product-attribute that referenced this issue Mar 18, 2022
hailangvn pushed a commit to hailangvn/product-attribute that referenced this issue Apr 29, 2022
flachica pushed a commit to flachica/product-attribute that referenced this issue May 6, 2022
flachica pushed a commit to flachica/product-attribute that referenced this issue May 6, 2022
ilyasProgrammer pushed a commit to ilyasProgrammer/product-attribute that referenced this issue May 17, 2022
cubells pushed a commit to cubells/product-attribute that referenced this issue Jul 10, 2022
flachica pushed a commit to flachica/product-attribute that referenced this issue Aug 8, 2022
flachica pushed a commit to flachica/product-attribute that referenced this issue Aug 17, 2022
clb-openfire pushed a commit to odof/product-attribute that referenced this issue Apr 4, 2023
yibudak pushed a commit to yibudak/product-attribute that referenced this issue Apr 26, 2023
Ricardoalso pushed a commit to camptocamp/product-attribute that referenced this issue May 4, 2023
Ricardoalso pushed a commit to camptocamp/product-attribute that referenced this issue May 4, 2023
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Aug 9, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Aug 19, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Sep 11, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Sep 19, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Sep 19, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Sep 30, 2024
IJOL pushed a commit to BITVAX/product-attribute that referenced this issue Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants