Skip to content

[IMP] product_multi_image: Handle images in variants#151

Merged
pedrobaeza merged 2 commits intoOCA:8.0from
Tecnativa:8.0-product_multi_image-variants
Jul 1, 2016
Merged

[IMP] product_multi_image: Handle images in variants#151
pedrobaeza merged 2 commits intoOCA:8.0from
Tecnativa:8.0-product_multi_image-variants

Conversation

@pedrobaeza
Copy link
Copy Markdown
Member

With this PR, you can:

  • Add images only in product templates, so no need of duplicating bytes.
  • Select in which variants the images are available.
  • Handle from the variants the addition or removal of images.

@pedrobaeza pedrobaeza force-pushed the 8.0-product_multi_image-variants branch 2 times, most recently from d93060d to be93a7c Compare April 26, 2016 19:25
@pedrobaeza
Copy link
Copy Markdown
Member Author

This one is ready to be reviewed.

cc @carlosdauden @sergio-teruel @yajo @rafaelbn

@pedrobaeza pedrobaeza force-pushed the 8.0-product_multi_image-variants branch from be93a7c to 5bd61f7 Compare April 26, 2016 19:27
@pedrobaeza
Copy link
Copy Markdown
Member Author

The error in Travis is unrelated (due to product_pricelist_fixed_price).

@carlosdauden
Copy link
Copy Markdown
Contributor

👍

@sergio-teruel
Copy link
Copy Markdown
Contributor

👍 Tested and ok.

comodel_name="product.product", string="Visible in these variants",
help="If you leave it empty, all variants will show this image. "
"Selecting one or several of the available variants, you "
"restrict the availability of the image to that variants.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"those variants"

@yajo
Copy link
Copy Markdown
Member

yajo commented Apr 28, 2016

Tested in runbot, I have an issue.

  1. Set an image to a product template.
  2. create the variants.
  3. Image gets lost.

Besides, runbot page displays some errors that seem related:

2016-04-27 01:02:29     ERROR   server  openerp.sql_db:241 execute

bad query:  SELECT "base_multi_image_image"."id" FROM "base_multi_image_image"
                        WHERE "base_multi_image_image".id IN ('one2many_v_id_169')  ORDER BY "base_multi_image_image"."sequence" ,"base_multi_image_image"."owner_model" ,"base_multi_image_image"."owner_id" ,"base_multi_image_image"."id"  

Traceback (most recent call last):
  File "/srv/openerp/instances/openerp-oca-runbot/parts/odoo-extra/runbot/static/build/3146184-151-5bd61f/openerp/sql_db.py", line 234, in execute
    res = self._obj.execute(query, params)
DataError: invalid input syntax for integer: "one2many_v_id_169"
LINE 2: ...            WHERE "base_multi_image_image".id IN ('one2many_...
                                                             ^

Code seems good except for some little remarks.

@pedrobaeza
Copy link
Copy Markdown
Member Author

I'll check your use case. Probably there will be an assignation image=False in the variant creation. We should inhibit the inverse function in that case.

For the error in the log, it seems a bug in the ORM that I have already seen commented by others (I think @hbrunn), so for now I don't think it's important, because it doesn't prevent the normal behaviour, although it's a bit ugly.

@yajo
Copy link
Copy Markdown
Member

yajo commented Apr 28, 2016

In such case an entry to known issues would be enough.

@pedrobaeza
Copy link
Copy Markdown
Member Author

@yajo, I have fixed the user case that was incorrect, and include 2 new tests for testing this case. Please review before you leave tomorrow.

@pedrobaeza pedrobaeza force-pushed the 8.0-product_multi_image-variants branch from 650f187 to d8a5b14 Compare May 4, 2016 20:11
@coveralls
Copy link
Copy Markdown

coveralls commented May 4, 2016

Coverage Status

Coverage increased (+1.09%) to 81.124% when pulling d8a5b14 on Tecnativa:8.0-product_multi_image-variants into 037e77c on OCA:8.0.

@yajo
Copy link
Copy Markdown
Member

yajo commented May 11, 2016

I have this problem now (I don't know if it is expected, but for what I read in the README seems like it's a bug):

  • Create a product.template.
  • Set its main image through the classic mechanism.
  • Create 2 variants.
  • Go to first variant.
  • Change its main image through the classic mechanism.
  • The new image is applied to all variants and the template.

@pedrobaeza
Copy link
Copy Markdown
Member Author

For now, that's the expected behavior:

  • The variant main image is assigned to the first multi-image found.
  • As this image is the first image of the template, then the template also switches this image
  • As this image is available for all variants, the main image of the rest of the variants is switched to this new one.

There are use cases that recommends one strategy or the other... What do you think?

@yajo
Copy link
Copy Markdown
Member

yajo commented May 11, 2016

I think it's good to keep the behavior as close to core as possible. AFAIK core Odoo sets the template image into the variant unless the variant has its own. That should be the same with this module.

However I understand the complexity of this given the current implementation, so if you prefer to add a notice in the known issues and leave this for the future, it's OK for me.

@rafaelbn
Copy link
Copy Markdown
Member

👍

@pedrobaeza
Copy link
Copy Markdown
Member Author

cc @Tecnativa

@atchuthan
Copy link
Copy Markdown
Member

👍

@pedrobaeza pedrobaeza merged commit c54c3d4 into OCA:8.0 Jul 1, 2016
@pedrobaeza pedrobaeza deleted the 8.0-product_multi_image-variants branch July 1, 2016 07:03
@atchuthan
Copy link
Copy Markdown
Member

atchuthan commented Jul 5, 2016

@pedrobaeza For OCA/e-commerce runbot(version 8.0), seems to be failing due to product_multi_image.

Please check version 8.0 of any session in runbot link below:
https://runbot.odoo-community.org/runbot/repo/github-com-oca-e-commerce-113

Not sure why this module is affected in OCA/e-commerce.

I noticed this problem when I created a PR(OCA/e-commerce#115) at OCA/e-commerce where runbot failed. More info on log: https://runbot.odoo-community.org/runbot/build/3150078

@pedrobaeza
Copy link
Copy Markdown
Member Author

Solved in c26675c

Launch rebuilds of the corresponding builds.

@atchuthan
Copy link
Copy Markdown
Member

@pedrobaeza thanks for the quick fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants