[FIX] website_sale_comparison: Ensure product_data available
Check whether the product ID of the first item exists inside product_data before trying to access it. Although it means the first item still does not appear, both products will be present in the user's cookies. When the user refreshes the page or navigates away, both products will be visible in the comparison panel. closes odoo/odoo#97152 X-original-commit: 5c6a92d0eb1e61cc2225a1b84ca1fb6c11365f2b Signed-off-by: William Braeckman (wbr) <wbr@odoo.com>
This commit is contained in:
committed by
William Braeckman
parent
a15ecc8afa
commit
d360b45737
@@ -195,8 +195,12 @@ var ProductComparison = publicWidget.Widget.extend(VariantMixin, {
|
||||
var self = this;
|
||||
this.$('.o_comparelist_products .o_product_row').remove();
|
||||
_.each(this.comparelist_product_ids, function (res) {
|
||||
var $template = self.product_data[res].render;
|
||||
self.$('.o_comparelist_products').append($template);
|
||||
if (self.product_data.hasOwnProperty(res)) {
|
||||
// It is possible that we do not have the required product_data for all IDs in
|
||||
// comparelist_product_ids
|
||||
var $template = self.product_data[res].render;
|
||||
self.$('.o_comparelist_products').append($template);
|
||||
}
|
||||
});
|
||||
if (force !== 'hide' && (this.comparelist_product_ids.length > 1 || force === 'show')) {
|
||||
$('#comparelist .o_product_panel_header').popover('show');
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
Australia, 2022-01-15
|
||||
|
||||
I hereby agree to the terms of the Odoo Individual Contributor License
|
||||
Agreement v1.0.
|
||||
|
||||
I declare that I am authorized and able to make this agreement and sign this
|
||||
declaration.
|
||||
|
||||
Signed,
|
||||
|
||||
Andrew Chau ky@andrewchau.com https://github.com/AndrewChau
|
||||
Reference in New Issue
Block a user