|
diff --git a/addons/sale/views/sale_views.xml b/addons/sale/views/sale_views.xml
index bafa4d12384..4d96f56f38a 100644
--- a/addons/sale/views/sale_views.xml
+++ b/addons/sale/views/sale_views.xml
@@ -94,18 +94,6 @@
-
-
-
-
@@ -290,7 +278,6 @@
-
diff --git a/addons/sale/wizard/sale_product_configurator.py b/addons/sale/wizard/sale_product_configurator.py
index 000897b5c59..7d2ae77ec51 100644
--- a/addons/sale/wizard/sale_product_configurator.py
+++ b/addons/sale/wizard/sale_product_configurator.py
@@ -10,4 +10,5 @@ class SaleProductConfigurator(models.TransientModel):
product_template_id = fields.Many2one(
'product.template', string="Product",
- required=True, domain=['|', ('attribute_line_ids', '!=', False), ('optional_product_ids', '!=', False)])
+ required=True, domain=[('sale_ok', '=', True), '|', ('attribute_line_ids', '!=', False), ('optional_product_ids', '!=', False)])
+ pricelist_id = fields.Many2one('product.pricelist', 'Pricelist', readonly=True)
diff --git a/addons/sale_management/views/sale_management_views.xml b/addons/sale_management/views/sale_management_views.xml
index c46f8f9fb36..654c5fc1a21 100644
--- a/addons/sale_management/views/sale_management_views.xml
+++ b/addons/sale_management/views/sale_management_views.xml
@@ -21,12 +21,6 @@
-
-
diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py
index 6558ac9c9cf..24be13bf049 100644
--- a/addons/website_sale/controllers/main.py
+++ b/addons/website_sale/controllers/main.py
@@ -394,11 +394,15 @@ class WebsiteSale(ProductConfiguratorController):
@http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True, csrf=False)
def cart_update(self, product_id, add_qty=1, set_qty=0, **kw):
+ product_custom_attribute_values = None
+ if kw.get('product_custom_attribute_values'):
+ product_custom_attribute_values = json.loads(kw.get('product_custom_attribute_values'))
+
request.website.sale_get_order(force_create=1)._cart_update(
product_id=int(product_id),
add_qty=add_qty,
set_qty=set_qty,
- product_custom_attribute_values=json.loads(kw.get('product_custom_attribute_values', '{}'))
+ product_custom_attribute_values=product_custom_attribute_values
)
return request.redirect("/shop/cart")
@@ -1078,7 +1082,9 @@ class WebsiteSale(ProductConfiguratorController):
if "optional-product-" in k and int(kw.get(k.replace("product", "add"))):
optional_product_ids.append(int(v))
- custom_values = json.loads(kw.get('custom_values'))
+ custom_values = []
+ if kw.get('custom_values'):
+ custom_values = json.loads(kw.get('custom_values'))
value = {}
if add_qty or set_qty:
diff --git a/addons/website_sale/static/src/js/website_sale_options.js b/addons/website_sale/static/src/js/website_sale_options.js
index a846727952e..c671972abf6 100644
--- a/addons/website_sale/static/src/js/website_sale_options.js
+++ b/addons/website_sale/static/src/js/website_sale_options.js
@@ -62,21 +62,12 @@ sAnimations.registry.WebsiteSaleOptions = sAnimations.Class.extend(ProductConfig
'input[type="radio"][name="product_id"]:checked'
];
- var productId = parseInt($form.find(productSelector.join(', ')).first().val(), 10);
-
- var productReady = $.Deferred();
- if (productId){
- productReady.resolve(productId);
- } else {
- productReady = self._rpc({
- model: 'product.template',
- method: 'create_product_variant',
- args: [
- $form.find('.product_template_id').val(),
- JSON.stringify(self.getSelectedVariantValues($form))
- ],
- });
- }
+ var productReady = this.selectOrCreateProduct(
+ $form,
+ parseInt($form.find(productSelector.join(', ')).first().val(), 10),
+ $form.find('.product_template_id').val(),
+ false
+ );
productReady.done(function (productId){
$form.find(productSelector.join(', ')).val(productId);
diff --git a/addons/website_sale/static/src/scss/website_sale_frontend.scss b/addons/website_sale/static/src/scss/website_sale_frontend.scss
index 613f247a780..6993c1e2fa8 100644
--- a/addons/website_sale/static/src/scss/website_sale_frontend.scss
+++ b/addons/website_sale/static/src/scss/website_sale_frontend.scss
@@ -138,3 +138,8 @@ $o-wsale-wizard-label-completed: $success;
}
}
}
+
+table.js_cart_lines .td-img img {
+ // allows sizing the placeholder image to the "image_small" size of 64px
+ max-height: 64px;
+}
\ No newline at end of file
diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml
index 61d73e8c579..010b517c291 100644
--- a/addons/website_sale/views/templates.xml
+++ b/addons/website_sale/views/templates.xml
@@ -121,7 +121,7 @@
|
-
+
diff --git a/addons/website_sale_comparison/static/src/js/website_sale_comparison.js b/addons/website_sale_comparison/static/src/js/website_sale_comparison.js
index 80b24aaa9bb..a52d548cb77 100644
--- a/addons/website_sale_comparison/static/src/js/website_sale_comparison.js
+++ b/addons/website_sale_comparison/static/src/js/website_sale_comparison.js
@@ -4,13 +4,17 @@ odoo.define('website_sale_comparison.comparison', function (require) {
var core = require('web.core');
var utils = require('web.utils');
var Widget = require('web.Widget');
+var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin');
var sAnimations = require('website.content.snippets.animation');
var website_sale_utils = require('website_sale.utils');
var qweb = core.qweb;
var _t = core._t;
-var ProductComparison = Widget.extend({
+// ProductConfiguratorMixin events are overridden on purpose here
+// to avoid registering them more than once since they are already registered
+// in website_sale.js
+var ProductComparison = Widget.extend(ProductConfiguratorMixin, {
xmlDependencies: ['/website_sale_comparison/static/src/xml/comparison.xml'],
template: 'product_comparison_template',
@@ -82,20 +86,38 @@ var ProductComparison = Widget.extend({
* @param {jQuery} $elem
*/
handleCompareAddition: function ($elem) {
+ var self = this;
if (this.comparelist_product_ids.length < this.product_compare_limit) {
- var prod = $elem.data('product-product-id');
+ var productId = $elem.data('product-product-id');
if ($elem.hasClass('o_add_compare_dyn')) {
- prod = $elem.parent().find('.product_id').val();
- if (!prod) { // case List View Variants
- prod = $elem.parent().find('input:checked').first().val();
+ productId = $elem.parent().find('.product_id').val();
+ if (!productId) { // case List View Variants
+ productId = $elem.parent().find('input:checked').first().val();
}
- prod = parseInt(prod, 10);
}
- if (!prod) {
- return;
- }
- this._addNewProducts(prod);
- website_sale_utils.animateClone($('#comparelist .o_product_panel_header'), $elem.closest('form'), -50, 10);
+
+ var productReady = this.selectOrCreateProduct(
+ $elem.closest('form'),
+ productId,
+ $elem.closest('form').find('.product_template_id').val(),
+ false
+ );
+
+ productReady.done(function (productId) {
+ productId = parseInt(productId, 10);
+
+ if (!productId) {
+ return;
+ }
+
+ self._addNewProducts(productId);
+ website_sale_utils.animateClone(
+ $('#comparelist .o_product_panel_header'),
+ $elem.closest('form'),
+ -50,
+ 10
+ );
+ });
} else {
this.$('.o_comparelist_limit_warning').show();
$('#comparelist .o_product_panel_header').popover('show');
diff --git a/addons/website_sale_comparison/views/website_sale_comparison_template.xml b/addons/website_sale_comparison/views/website_sale_comparison_template.xml
index c25bfa94b7c..cc9d68d6aa6 100644
--- a/addons/website_sale_comparison/views/website_sale_comparison_template.xml
+++ b/addons/website_sale_comparison/views/website_sale_comparison_template.xml
@@ -10,14 +10,14 @@
-
+
-
+
diff --git a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js
index 5c2cbc1a7b4..295d1382f1d 100644
--- a/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js
+++ b/addons/website_sale_wishlist/static/src/js/website_sale_wishlist.js
@@ -3,17 +3,22 @@ odoo.define('website_sale_wishlist.wishlist', function (require) {
var sAnimations = require('website.content.snippets.animation');
var wSaleUtils = require('website_sale.utils');
+var ProductConfiguratorMixin = require('sale.ProductConfiguratorMixin');
-sAnimations.registry.ProductWishlist = sAnimations.Class.extend({
+// ProductConfiguratorMixin events are overridden on purpose here
+// to avoid registering them more than once since they are already registered
+// in website_sale.js
+sAnimations.registry.ProductWishlist = sAnimations.Class.extend(ProductConfiguratorMixin, {
selector: '.oe_website_sale',
read_events: {
'click #my_wish': '_onClickMyWish',
'click .o_add_wishlist, .o_add_wishlist_dyn': '_onClickAddWish',
- 'change input.js_variant_change, select.js_variant_change, ul[data-attribute_exclusions]': '_onChangeVariant',
+ 'change input.product_id': '_onChangeVariant',
'change input.js_product_change': '_onChangeProduct',
'click .wishlist-section .o_wish_rm': '_onClickWishRemove',
'click .wishlist-section .o_wish_add': '_onClickWishAdd',
},
+ events: sAnimations.Class.events,
start: function () {
var self = this;
@@ -48,23 +53,39 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend({
*/
_addNewProducts: function ($el) {
var self = this;
- var productID = parseInt($el.data('product-product-id'), 10);
- if (!productID && $el.hasClass('o_add_wishlist_dyn')) {
- productID = parseInt($el.parent().find('.product_id').val());
- }
- if (productID && !_.contains(self.wishlistProductIDs, productID)) {
- return this._rpc({
- route: '/shop/wishlist/add',
- params: {
- product_id: productID,
- },
- }).then(function () {
- self.wishlistProductIDs.push(productID);
- self._updateWishlistView();
- wSaleUtils.animateClone($('#my_wish'), $el.closest('form'), 25, 40);
- $el.prop("disabled", true).addClass('disabled');
- });
+ var productID = $el.data('product-product-id');
+ if ($el.hasClass('o_add_wishlist_dyn')) {
+ productID = $el.parent().find('.product_id').val();
+ if (!productID) { // case List View Variants
+ productID = $el.parent().find('input:checked').first().val();
+ }
+ productID = parseInt(productID, 10);
}
+
+ var productReady = this.selectOrCreateProduct(
+ $el.closest('form'),
+ productID,
+ $el.closest('form').find('.product_template_id').val(),
+ false
+ );
+
+ productReady.done(function (productId) {
+ productId = parseInt(productId, 10);
+
+ if (productId && !_.contains(self.wishlistProductIDs, productId)) {
+ return self._rpc({
+ route: '/shop/wishlist/add',
+ params: {
+ product_id: productId,
+ },
+ }).then(function () {
+ self.wishlistProductIDs.push(productId);
+ self._updateWishlistView();
+ wSaleUtils.animateClone($('#my_wish'), $el.closest('form'), 25, 40);
+ $el.prop("disabled", true).addClass('disabled');
+ });
+ }
+ });
},
/**
* @private
@@ -175,16 +196,15 @@ sAnimations.registry.ProductWishlist = sAnimations.Class.extend({
* @param {Event} ev
*/
_onChangeVariant: function (ev) {
- var $ul = $(ev.target).closest('.js_add_cart_variants');
- var $parent = $ul.closest('.js_product');
- var $productID = $parent.find('.product_id').first();
+ var $input = $(ev.target);
+ var $parent = $input.closest('.js_product');
var $el = $parent.find("[data-action='o_wishlist']");
- if (!_.contains(this.wishlistProductIDs, parseInt($productID.val(), 10))) {
+ if (!_.contains(this.wishlistProductIDs, parseInt($input.val(), 10))) {
$el.prop("disabled", false).removeClass('disabled').removeAttr('disabled');
} else {
$el.prop("disabled", true).addClass('disabled').attr('disabled', 'disabled');
}
- $el.data('product-product-id', parseInt($productID.val(), 10));
+ $el.data('product-product-id', parseInt($input.val(), 10));
},
/**
* @private
diff --git a/addons/website_sale_wishlist/static/src/scss/website_sale_wishlist.scss b/addons/website_sale_wishlist/static/src/scss/website_sale_wishlist.scss
index e43943a8aa5..13a1ec4b04d 100644
--- a/addons/website_sale_wishlist/static/src/scss/website_sale_wishlist.scss
+++ b/addons/website_sale_wishlist/static/src/scss/website_sale_wishlist.scss
@@ -15,4 +15,9 @@
width: 100px;
}
}
+}
+
+table.table-comparator .td-img img {
+ // allows sizing the placeholder image to the "image" size of 100px
+ max-height: 100px;
}
\ No newline at end of file
diff --git a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml
index 5ff34c4d5cf..28d493f7142 100644
--- a/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml
+++ b/addons/website_sale_wishlist/views/website_sale_wishlist_template.xml
@@ -12,7 +12,7 @@
-
+
@@ -20,7 +20,7 @@
-
+
|