Browse Source

Oct 26 : [FIX] Bug Fixed 'website_hide_variants'

pull/295/head
AjmalCybro 2 years ago
parent
commit
d5b90249c5
  1. 3
      website_hide_variants/__manifest__.py
  2. 2
      website_hide_variants/doc/RELEASE_NOTES.md
  3. 6
      website_hide_variants/models/product.py
  4. 16
      website_hide_variants/static/src/js/variants.js

3
website_hide_variants/__manifest__.py

@ -35,7 +35,8 @@
'website_sale', 'website_sale',
'sale_management' 'sale_management'
], ],
'data': ['views/product_views.xml'], 'data': ['views/product_views.xml',
],
'assets': { 'assets': {
'web.assets_frontend': [ 'web.assets_frontend': [

2
website_hide_variants/doc/RELEASE_NOTES.md

@ -1,6 +1,6 @@
## Module <website_hide_variants> ## Module <website_hide_variants>
#### 11.08.2023 #### 17.10.2023
#### Version 16.0.1.0.0 #### Version 16.0.1.0.0
#### ADD #### ADD
- Initial commit for Odoo 16 Hide Variants - Initial commit for Odoo 16 Hide Variants

6
website_hide_variants/models/product.py

@ -30,3 +30,9 @@ class ProductProduct(models.Model):
help="Check right if you want to " help="Check right if you want to "
"hide the variant in your " "hide the variant in your "
"website") "website")
def product_read(self, data):
if data.get('id', False):
prod_id = int(data.get('id'))
product = self.sudo().browse(prod_id).read(["website_hide_variants"])
return product

16
website_hide_variants/static/src/js/variants.js

@ -13,26 +13,30 @@ odoo.define('website_hide_variants.VariantMixin', function (require) {
'use strict'; 'use strict';
var session = require('web.session');
var VariantMixin = require('sale.VariantMixin') 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')
var ajax = require('web.ajax');
VariantMixin._onChangeCombination = async function(ev, $parent, combination) { 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
var product = combination.product_id
if (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
} }
}); });

Loading…
Cancel
Save