|
@ -9,30 +9,34 @@ |
|
|
* @requires web.rpc |
|
|
* @requires web.rpc |
|
|
* @augments sale.VariantMixin |
|
|
* @augments sale.VariantMixin |
|
|
*/ |
|
|
*/ |
|
|
odoo.define('website_hide_variants.VariantMixin', function (require) { |
|
|
odoo.define('website_hide_variants.VariantMixin', function(require) { |
|
|
'use strict'; |
|
|
'use strict'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var VariantMixin =require('sale.VariantMixin') |
|
|
var session = require('web.session'); |
|
|
|
|
|
var VariantMixin = require('sale.VariantMixin') |
|
|
var core = require('web.core') |
|
|
var core = require('web.core') |
|
|
var rpc = require('web.rpc') |
|
|
var rpc = require('web.rpc') |
|
|
VariantMixin._onChangeCombination = async function (ev, $parent, combination) { |
|
|
var ajax = require('web.ajax'); |
|
|
|
|
|
VariantMixin._onChangeCombination = async function(ev, $parent, combination) { |
|
|
var count = false |
|
|
var count = false |
|
|
// Check if the selected combination has a valid product ID
|
|
|
// Check if the selected combination has a valid product ID
|
|
|
if(combination.product_id){ |
|
|
var product = combination.product_id |
|
|
|
|
|
if (combination.product_id) { |
|
|
|
|
|
var data = { |
|
|
|
|
|
'id': combination.product_id |
|
|
|
|
|
} |
|
|
await rpc.query({ |
|
|
await rpc.query({ |
|
|
model: 'product.product', |
|
|
model: 'product.product', |
|
|
method: 'search_read', |
|
|
method: 'product_read', |
|
|
args: [[['id','=',parseInt(combination.product_id)]]], |
|
|
args: [ |
|
|
|
|
|
[], data |
|
|
}).then(function (res) { |
|
|
], |
|
|
|
|
|
}).then(function(res) { |
|
|
// Check if the product is marked as "website_hide_variants"
|
|
|
// Check if the product is marked as "website_hide_variants"
|
|
|
|
|
|
if (res[0].website_hide_variants) { |
|
|
if(res[0].website_hide_variants){ |
|
|
|
|
|
// Disable the combination and display an appropriate message to the user
|
|
|
// Disable the combination and display an appropriate message to the user
|
|
|
|
|
|
|
|
|
combination.is_combination_possible = false |
|
|
combination.is_combination_possible = false |
|
|
|
|
|
|
|
|
count = true |
|
|
count = true |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
@ -89,12 +93,12 @@ odoo.define('website_hide_variants.VariantMixin', function (require) { |
|
|
this.handleCustomValues($(ev.target)); |
|
|
this.handleCustomValues($(ev.target)); |
|
|
// Display appropriate message to the user based on the availability of the selected variant
|
|
|
// Display appropriate message to the user based on the availability of the selected variant
|
|
|
|
|
|
|
|
|
if(count){ |
|
|
if (count) { |
|
|
$('.css_not_available_msg')[0].innerText = "This Product is Out-of-stock." |
|
|
$('.css_not_available_msg')[0].innerText = "This Product is Out-of-stock." |
|
|
|
|
|
|
|
|
}else{ |
|
|
} else { |
|
|
$('.css_not_available_msg')[0].innerText = "This combination does not exist." |
|
|
$('.css_not_available_msg')[0].innerText = "This combination does not exist." |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |