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

12.0 configurator seb #28079

Open
wants to merge 9 commits into
base: 12.0
from

Conversation

Projects
None yet
6 participants
@seb-odoo
Contributor

seb-odoo commented Oct 23, 2018

Description of the issue/feature this PR addresses:

Current behavior before PR:

Desired behavior after PR is merged:

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@seb-odoo seb-odoo self-assigned this Oct 23, 2018

@seb-odoo seb-odoo requested review from JKE-be, aab-odoo and rdeodoo Oct 23, 2018

@robodoo robodoo added the seen 🙂 label Oct 23, 2018

@aab-odoo aab-odoo requested a review from qsm-odoo Oct 24, 2018

@aab-odoo

This comment has been minimized.

Contributor

aab-odoo commented Oct 24, 2018

i think @qsm-odoo is the best candidate to review this PR

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 24, 2018

[IMP] web_tour: allow simulating click without leave
This is important if the mouse must stay on the element after it has been
clicked. This is the case for the product image zoom, which will be tested in
the following commit.

PR: odoo#28079

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 24, 2018

[FIX] website_sale: fix product variant image zoom
The product image zoom was computed in the start method, and an "on load" event
was set in some but not all cases.

This commit makes sure the load event is always set, to correctly recompute the
zoom feature when the image is later changed (for example, changing variant).

PR: odoo#28079

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 24, 2018

[FIX] product,(website_)sale(*): fix variant filter and order
The goal of this commit is to make consistent the filtering and ordering of
product variants.

Filter
======

On the website, we don't want to show variants that have exclusion rules.

While it is possible to select impossible combination with the matrix (which we
want to keep to allow the user to easily go from one variant to the other),
what we definitely don't want is the first combination shown to be impossible.

When activating the customize "list view of variants", we also don't want to
shown impossible combination on the list.

Order
=====

We want the variant order to be consistent with what the user selected with the
sequence fields. The display order on the website should be the same than the
display on the various backend views.

This implies also fixing the order of:
- product.attribute
- product.attribute.value
- product.template.attribute.line
- product.template.attribute.value

The general order is now: parent, sequence, name, id.

Before, it was already a mix of those, but not always in the same order, and not
every key for every model.

PR: odoo#28079

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 25, 2018

[IMP] web_tour: allow simulating click without leave
This is important if the mouse must stay on the element after it has been
clicked. This is the case for the product image zoom, which will be tested in
the following commit.

PR: odoo#28079

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 25, 2018

[FIX] website_sale: fix product variant image zoom
The product image zoom was computed in the start method, and an "on load" event
was set in some but not all cases.

This commit makes sure the load event is always set, to correctly recompute the
zoom feature when the image is later changed (for example, changing variant).

PR: odoo#28079

seb-odoo added a commit to odoo-dev/odoo that referenced this pull request Oct 25, 2018

[FIX] product,(website_)sale(*): fix variant filter and order
The goal of this commit is to make consistent the filtering and ordering of
product variants.

Filter
======

On the website, we don't want to show variants that have exclusion rules.

While it is possible to select impossible combination with the matrix (which we
want to keep to allow the user to easily go from one variant to the other),
what we definitely don't want is the first combination shown to be impossible.

When activating the customize "list view of variants", we also don't want to
shown impossible combination on the list.

Order
=====

We want the variant order to be consistent with what the user selected with the
sequence fields. The display order on the website should be the same than the
display on the various backend views.

This implies also fixing the order of:
- product.attribute
- product.attribute.value
- product.template.attribute.line
- product.template.attribute.value

The general order is now: parent, sequence, name, id.

Before, it was already a mix of those, but not always in the same order, and not
every key for every model.

PR: odoo#28079

seb-odoo added some commits Nov 16, 2018

[FIX] sale_quotation_builder: remove warning when installed
We don't need to clutter the interface with this warning once the module is installed.
[IMP] product: improve variant demo data
Activate variant by default with demo data: since we have demo data creating
variants, the database will be more consistent if the option is also activated
by default. It also allows to gain time when making a demo or testing feature
using them on a new database.

PR: #
[IMP] web_tour: allow simulating click without leave
This is important if the mouse must stay on the element after it has been
clicked. This is the case for the product image zoom, which will be tested in
the following commit.

PR: #
[FIX] website_sale: fix product variant image zoom
The product image zoom was computed in the start method, and an "on load" event
was set in some but not all cases.

This commit makes sure the load event is always set, to correctly recompute the
zoom feature when the image is later changed (for example, changing variant).

PR: #
[FIX] sale,website: fix variant alert style
It should be warning instead of danger, and use appropriate BS4 classes.

Without this commit, the resulting style might be wrong with some themes.

PR: #
[FIX] sale: fix indent of product configurator templates
This will make the diff of the following commit easier to read.

PR: #
[FIX] product,(website_)sale(*): fix product configurator
This commit has several parts: fix ordering, fix/create python logic (notably
price compute), fix currency, display correct info on the views without the
need of JS (prevent flickering), fix various issues with website and SO, and
add tests (both unit and tour).

================================================================================

*** Make consistent the filtering and ordering of product variants ***

Filter
======

On the website when activating the customize "list view of variants", we don't
want to show impossible combination on the list.

Order
=====

We want the variant order to be consistent with what the user selected with the
sequence fields. The display order on the website should be the same than the
display on the various backend views.

This implies also fixing the order of:
- product.attribute
- product.attribute.value
- product.template.attribute.line
- product.template.attribute.value

The general order is now: parent, sequence, name, id.

Before, it was already a mix of those, but not always in the same order, and not
every key for every model.

On the website, the first combination shown by the python should be the same as
the one that will be computed by the JS to prevent flickering.

Ideally there should be no RPC at page loading if the python has computed
everything correctly, but it is currently not possible to achieve because the
view logic for website_sale_stock is only in JS.

================================================================================

*** Fix product template and variant price computation ***

Improve the get_combination_info method:

- take into account tax included/excluded settings (B2B/B2C)
- take into account pricelist discount policy (striked price)
- fix inconsistencies when price after pricelist would be 0
- use proper rounding and discount compute with the currency helper methods
- fix an issue where context "partner" would have a mix of id and recordset
- added tests

================================================================================

*** Fix currency conversions ***

The list_price and lst_price of a product are always encoded using the currency
of the product.

The results of "combination info" are always returned using the currency of the
pricelist if given, or the currency of the product.

The prices on an order (line) are encoded with the currency of its pricelist.

================================================================================

*** Fix dynamic variants access rights ***

Public users on the e-commerce should be able to create product variants if the
configuration of the attributes of the product template is set as "dynamic".

This uses "sudo" to bypass create security rules for public users.
Multiple checks are done to ensure that it creates a valid product variant.

================================================================================

*** Miscellaneous bugs, tracebacks and necessary improvements ***

- in general: correctly show warning when no variant is possible, don't let user
add to cart an impossible variant from the optional product modal.

- sale order: fix traceback when emptying the product_id field from configurator

- website_sale: correctly compute first image / carousel as well as first
variant to show

- website_sale_wishlist: fix it with dynamic variants

- website_sale_comparison: fix it with dynamic variants
	(comparison and alternative products)

- website_sale_stock: fix it in general (some flickering still present)

- deprecate unnecessary _website specific methods

- fix as much flickering as possible by correctly pre-computing in python/views

- move business logic from controllers to models

================================================================================

Authored by @seb-odoo with contribution from @awa-odoo

PR: #

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Nov 19, 2018

_inherit = 'product.template'
@api.multi
def _is_in_wishlist(self):

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

to move in master

@@ -11,16 +11,18 @@
<template id="add_to_wishlist" inherit_id="website_sale.products_item" active="True" customize_show="True" name="Wishlist" priority="20">
<xpath expr="//div[hasclass('product_price')]" position="inside">
<t t-set="in_wish" t-value="product.product_variant_ids &amp; request.env['product.wishlist'].current().mapped('product_id')"/>
<button type="button" role="button" class="btn btn-secondary btn-sm o_add_wishlist" t-att-disabled='in_wish or None' title="Add to Wishlist" t-att-data-product-product-id="product.product_variant_ids[0].id if product.product_variant_ids else '0'" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span></button>
<t t-set="in_wish" t-value="product._is_in_wishlist()"/>

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

free diff for master

</xpath>
</template>
<template id="product_add_to_wishlist" name='Add to wishlist in product page' inherit_id="website_sale.product" priority="20">
<xpath expr="//a[@id='add_to_cart']" position="after">
<t t-if="product.env.ref('website_sale_wishlist.add_to_wishlist').active">
<t t-set="in_wish" t-value="product.product_variant_ids &amp; request.env['product.wishlist'].current().mapped('product_id')"/>
<button type="button" role="button" class="btn btn-secondary btn-lg mt8 o_add_wishlist_dyn" t-att-disabled='in_wish or None' title="Add to Wishlist" t-att-data-product-product-id="product.product_variant_ids[0].id if product.product_variant_ids else '0'" data-action="o_wishlist"><span class="fa fa-heart" role="img" aria-label="Add to wishlist"></span></button>
<t t-set="in_wish" t-value="product._is_in_wishlist()"/>

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

free diff for master

@@ -65,7 +67,8 @@
<button type="button" class="btn btn-link o_wish_rm no-decoration"><small><i class='fa fa-trash-o'></i> Remove</small></button>
</td>
<td>
<t t-esc="wish.product_id.website_price" t-options="{'widget': 'monetary', 'display_currency': website.pricelist_id.currency_id}"/>
<t t-set="combination_info" t-value="wish.product_id.product_tmpl_id._get_combination_info(wish.product_id.product_template_attribute_value_ids, wish.product_id.id)"/>

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

do helper in product.product ?

@@ -198,7 +198,7 @@ def _convert(self, from_amount, to_currency, company, date, round=True):
assert self, "convert amount from unknown currency"
assert to_currency, "convert amount to unknown currency"
assert company, "convert amount from unknown company"
assert date, "convert amount from unknown date"
date = date or fields.Date.today()

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

bad idea and btw not in stable

You need to know the date from when it has been converted
That will avoid 'forgot' argument if you keep assert

p = request.env['product.product'].with_context(pricelist_context, display_default_code=False).browse(product_id)
price = p.website_price
price = p.product_tmpl_id._get_combination_info(p.product_template_attribute_value_ids, p.id)['price']

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

helper on product ?

product and every alternative product because the product
comparator need the variants and not the templates.
-->
<!-- TODO SEB this should compare the currently selected variant (with JS) instead of the first one. -->

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

remove me

product = product.with_context(self._get_product_context(pricelist, **kw))
no_variant_attribute_values = request.env['product.template.attribute.value'].browse(variant_values).filtered(
combination = request.env['product.template.attribute.value'].browse(variant_values)
no_variant_attribute_values = combination.filtered(

This comment has been minimized.

@JKE-be

JKE-be Nov 19, 2018

Contributor

use _without_no_variant_attributes?

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Nov 19, 2018

seb-odoo added some commits Nov 19, 2018

@robodoo robodoo removed the CI 🤖 label Nov 20, 2018

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