From df44242391045398dee913c4e91effd9ef09720a Mon Sep 17 00:00:00 2001 From: AjmalCybro Date: Mon, 13 Nov 2023 16:15:06 +0530 Subject: [PATCH] Nov 13 : [FIX] Bug Fixed 'call_for_price_website' --- call_for_price_website/README.rst | 4 +- call_for_price_website/__manifest__.py | 1 + .../static/src/js/create_call_form.js | 3 +- .../static/src/js/variant_mixin.js | 25 +- .../views/call_for_price_views.xml | 3 +- .../views/shop_hide_call_price_template.xml | 76 ----- .../views/website_product_template.xml | 260 ++++++++++++++++++ 7 files changed, 282 insertions(+), 90 deletions(-) create mode 100644 call_for_price_website/views/website_product_template.xml diff --git a/call_for_price_website/README.rst b/call_for_price_website/README.rst index a13711ee4..ae6a4e33a 100644 --- a/call_for_price_website/README.rst +++ b/call_for_price_website/README.rst @@ -16,7 +16,9 @@ Company Credits ------- -Developers: Raneesha M K @cybrosys, Muhsina V @cybrosys, Contact: odoo@cybrosys.com +Developers: Raneesha M K @cybrosys, + Muhsina V @cybrosys, Contact: odoo@cybrosys.com, + Farhana Jahan PT @cybrosys, Contact: odoo@cybrosys.com Contacts -------- diff --git a/call_for_price_website/__manifest__.py b/call_for_price_website/__manifest__.py index 73ff077d1..2be9d9a5c 100644 --- a/call_for_price_website/__manifest__.py +++ b/call_for_price_website/__manifest__.py @@ -39,6 +39,7 @@ 'views/compare_hide_price_template.xml', 'views/call_for_price_views.xml', 'views/product_product_views.xml', + 'views/website_product_template.xml' ], 'assets': { 'web.assets_frontend': [ diff --git a/call_for_price_website/static/src/js/create_call_form.js b/call_for_price_website/static/src/js/create_call_form.js index eb660cb82..06646eaff 100644 --- a/call_for_price_website/static/src/js/create_call_form.js +++ b/call_for_price_website/static/src/js/create_call_form.js @@ -116,7 +116,6 @@ odoo.define('call_for_price_website.create_call_form', function(require) { this.$el.find('#quantity').val(''); this.$el.find('#message').val(''); }, - }); return publicWidget.registry.CallForPrice; -}); \ No newline at end of file +}); diff --git a/call_for_price_website/static/src/js/variant_mixin.js b/call_for_price_website/static/src/js/variant_mixin.js index b7d18a233..e52a5cf95 100644 --- a/call_for_price_website/static/src/js/variant_mixin.js +++ b/call_for_price_website/static/src/js/variant_mixin.js @@ -8,9 +8,10 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) { // Import the VariantMixin from website_sale module var VariantMixin = require('website_sale.VariantMixin'); // Store a reference to the original onChangeCombination function - const originalOnChangeCombination = VariantMixin._onChangeCombination; + const oldOnChangeCombination = VariantMixin._onChangeCombination; // Override the onChangeCombination function to implement custom behavior VariantMixin._onChangeCombination = function(ev, $parent, combination) { + const result = oldOnChangeCombination.apply(this, arguments); const $pricePerUom = $parent.find(".o_base_unit_price:first .oe_currency_value"); if ($pricePerUom) { if (combination.is_combination_possible !== false && combination.base_unit_price != 0) { @@ -36,25 +37,31 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) { const quantity = $parent.find('.css_quantity'); const product_unavailable = $parent.find('#product_unavailable'); const price_call_div = $parent.find('#price_call_hide'); - if (combination.prevent_zero_price_sale) { productPrice.removeClass('d-inline-block').addClass('d-none'); quantity.removeClass('d-inline-flex').addClass('d-none'); addToCart.removeClass('d-inline-flex').addClass('d-none'); contactUsButton.removeClass('d-none').addClass('d-flex'); - product_unavailable.removeClass('d-none').addClass('d-flex') - } else if (combination.price_call) { - productPrice.removeClass('d-inline-block').addClass('d-none'); + product_unavailable.removeClass('d-none').addClass('d-flex'); + this.$el.find('.product_price_visible').removeClass('d-none').addClass('d-block'); + this.$el.find('.product_price').remove(); + } + if (combination.price_call) { quantity.removeClass('d-inline-flex').addClass('d-none'); addToCart.removeClass('d-inline-flex').addClass('d-none'); contactUsButton.removeClass('d-none').addClass('d-flex'); price_call_div.removeClass('d-none').addClass('d-flex'); + this.$el.find('#contact_us_wrapper').remove(); this.$el.find('#add_to_cart').removeClass('d-block').addClass('d-none'); + this.$el.find('.product_price').removeClass('d-inline-block').addClass('d-none'); this.$el.find('#price_of_product').removeClass('d-block').addClass('d-none'); this.$el.find('#price_of_product').removeClass('d-block').addClass('d-none'); this.$el.find('.js_add_cart_json').removeClass('d-block').addClass('d-none'); - this.$el.find('.quantity').removeClass('d-block').addClass('d-none'); - } else { + this.$el.find('.css_quantity').removeClass('d-block').addClass('d-none'); + this.$el.find('.product_price_visible').removeClass('d-block').addClass('d-none'); + this.$el.find('.product_price').remove(); + } + else { productPrice.removeClass('d-none').addClass('d-inline-block'); quantity.removeClass('d-none').addClass('d-inline-flex'); addToCart.removeClass('d-none').addClass('d-inline-flex'); @@ -66,8 +73,8 @@ odoo.define('call_for_price_website.CustomVariantMixin', function(require) { this.$el.find('#price_of_product').removeClass('d-none').addClass('d-block'); this.$el.find('.js_add_cart_json').removeClass('d-none').addClass('d-block'); this.$el.find('.quantity').removeClass('d-none').addClass('d-block'); + this.$el.find('.product_price_visible').removeClass('d-none').addClass('d-block'); } - // Call the original onChangeCombination function - originalOnChangeCombination.apply(this, [ev, $parent, combination]); + return result }; }); \ No newline at end of file diff --git a/call_for_price_website/views/call_for_price_views.xml b/call_for_price_website/views/call_for_price_views.xml index a91f31a8e..71c25cded 100644 --- a/call_for_price_website/views/call_for_price_views.xml +++ b/call_for_price_website/views/call_for_price_views.xml @@ -51,9 +51,8 @@ call.price tree,form - - \ No newline at end of file + diff --git a/call_for_price_website/views/shop_hide_call_price_template.xml b/call_for_price_website/views/shop_hide_call_price_template.xml index e21121bf0..839cf106a 100644 --- a/call_for_price_website/views/shop_hide_call_price_template.xml +++ b/call_for_price_website/views/shop_hide_call_price_template.xml @@ -42,82 +42,6 @@ - -