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

[11.0][NEW] website_sale_product_detail_attribute_image: new module #288

Conversation

sergio-teruel
Copy link
Contributor

New module for display attribute image in produts detail shop view
cc @Tecnativa

@sergio-teruel
Copy link
Contributor Author

I have added free images for demo data from https://www.iconfinder.com/, Where I put this images information?

@sergio-teruel sergio-teruel force-pushed the 11.0-PR-website_sale_product_detail_attribute_image branch from bf91388 to bb20c2c Compare May 15, 2019 22:29
@pedrobaeza
Copy link
Member

Put them on CREDITS.rst

@pedrobaeza pedrobaeza added this to the 11.0 milestone May 16, 2019
@sergio-teruel sergio-teruel force-pushed the 11.0-PR-website_sale_product_detail_attribute_image branch from bb20c2c to 1764517 Compare May 16, 2019 08:51
@@ -0,0 +1,2 @@
This module extends the functionality of website sale module to allow display
Copy link
Member

Choose a reason for hiding this comment

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

s/to allow/to allow to

@@ -0,0 +1,2 @@
This module extends the functionality of website sale module to allow display
product attributes images in shop product detail.
Copy link
Member

Choose a reason for hiding this comment

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

s/product attributes images in shop product detail/images related to product attributes in e-commerce product page

string='Website detail image',
attachment=True,
help='Small-sized image of the attribute for shop online product '
'detail. It is automatically resized as a 64x64 px image, with '
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't resize this automatically. What about if someone wants it to 128x128? If automatic resize, you have to put a configuration option to select the preferred size.

'detail. It is automatically resized as a 64x64 px image, with '
'aspect ratio preserved.',
)
website_product_detail_display = fields.Boolean(
Copy link
Member

Choose a reason for hiding this comment

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

Being homogeneous with other namings, I would call this website_product_detail_image_published

res = super().product(
product, category=category, search=search, **kwargs)
image_attributes = product.attribute_line_ids.filtered(
lambda x: x.attribute_id.website_product_detail_display)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't better to populate images directly:

attribute_images = product.attribute_line_ids.filtered(
    lambda x: x.attribute_id.website_product_detail_display
).mapped('website_product_detail_image')

Copy link
Member

Choose a reason for hiding this comment

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

I self-answer: you are also displaying the attribute name. Not sure about this being coupled between backend and frontend. It's better to have an extra translate field for website display, but fallbacking to this one if not set.

}
.product-detail-attributes div {
font-size: 85%;
/*line-height: 1;*/
Copy link
Member

Choose a reason for hiding this comment

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

Remove this if not used


class TestProductAttribute(SavepointCase):
at_install = False
post_install = True
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

def test_write_image_for_attribute(self):
self.attribute.website_product_detail_image = self.image
self.assertEqual(
self.attribute.website_product_detail_image, self.image)
Copy link
Member

Choose a reason for hiding this comment

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

This is not testing actually the resize

<field name="inherit_id" ref="product.attribute_tree_view"/>
<field name="arch" type="xml">
<field name="create_variant" position="after">
<field name="website_product_detail_display"/>
Copy link
Member

Choose a reason for hiding this comment

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

widget switch or boolean?

t-attf-src="/web/image/product.attribute/#{image_attribute.attribute_id.id}/website_product_detail_image"/>
</div>
<t t-foreach="image_attribute.value_ids" t-as="value">
<div class="text-center"> <span t-field="value.name"/> </div>
Copy link
Member

Choose a reason for hiding this comment

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

The same about showing these backend string here. You are not mentioning this in the README, nor the label of the attribute.

@sergio-teruel sergio-teruel force-pushed the 11.0-PR-website_sale_product_detail_attribute_image branch from 1764517 to c0f648e Compare May 17, 2019 08:51
@sergio-teruel
Copy link
Contributor Author

Changes done.

@sergio-teruel sergio-teruel force-pushed the 11.0-PR-website_sale_product_detail_attribute_image branch from c0f648e to f7a33e0 Compare May 17, 2019 08:55
<field name="inherit_id" ref="product.attribute_tree_view"/>
<field name="arch" type="xml">
<field name="create_variant" position="after">
<field name="website_product_detail_image"/>
Copy link
Member

Choose a reason for hiding this comment

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

Why not uses widget='image' here? size?

Copy link
Member

Choose a reason for hiding this comment

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

is it working on trees?

Copy link
Member

Choose a reason for hiding this comment

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

Work but without resize image :/ perhaps can use: https://github.com/OCA/web/tree/11.0/web_tree_image

Copy link
Member

Choose a reason for hiding this comment

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

Well, maybe too much overhead for this, don't you think? Let Sergio decides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't want dependencies of other modules, If the user wants to view the image only has to do click on record, also this model, once it has been configured the user not will coming back to see the images every day.
But I thought so too 😄

@sergio-teruel sergio-teruel force-pushed the 11.0-PR-website_sale_product_detail_attribute_image branch from f7a33e0 to b491d67 Compare May 17, 2019 21:23
@sergio-teruel
Copy link
Contributor Author

Changes done

Copy link
Member

@Tardo Tardo left a comment

Choose a reason for hiding this comment

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

LGTM, tested on runbot

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

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

Tested in runbot 👍

@rafaelbn rafaelbn merged commit 4d30933 into OCA:11.0 May 28, 2019
@rafaelbn rafaelbn deleted the 11.0-PR-website_sale_product_detail_attribute_image branch May 28, 2019 09:13
sergio-teruel added a commit to Tecnativa/e-commerce that referenced this pull request Oct 30, 2019
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
CarlosRoca13 pushed a commit to Tecnativa/e-commerce that referenced this pull request Jun 3, 2020
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
CarlosRoca13 pushed a commit to Tecnativa/e-commerce that referenced this pull request Jun 3, 2020
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
CarlosRoca13 pushed a commit to Tecnativa/e-commerce that referenced this pull request Jun 3, 2020
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
miguel-S73 pushed a commit to Studio73/e-commerce that referenced this pull request Jan 14, 2021
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
CarlosRoca13 pushed a commit to Tecnativa/e-commerce that referenced this pull request May 23, 2022
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
CarlosRoca13 pushed a commit to Tecnativa/e-commerce that referenced this pull request May 23, 2022
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
pilarvargas-tecnativa pushed a commit to Tecnativa/e-commerce that referenced this pull request Jan 24, 2023
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
Segui-S73 pushed a commit to Studio73/e-commerce that referenced this pull request Feb 22, 2023
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
Segui-S73 pushed a commit to Studio73/e-commerce that referenced this pull request Jul 7, 2023
…CA#288)

* [11.0][NEW] website_sale_product_detail_attribute_image: new module

* [11.0][IMP] website_sale_product_detail_attribute_image: Remove boolean_widget from tree view
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.

None yet

5 participants