extend js
unknown
javascript
a month ago
2.2 kB
30
Indexable
Never
Here is the original js code that is in the sale_variant_mixin.js file of the website_sale module _onChangeCombination: function (ev, $parent, combination) { var self = this; var $price = $parent.find(".oe_price:first .oe_currency_value"); var $default_price = $parent.find(".oe_default_price:first .oe_currency_value"); var $optional_price = $parent.find(".oe_optional:first .oe_currency_value"); $price.text(self._priceToStr(combination.price)); $default_price.text(self._priceToStr(combination.list_price)); $default_price.text(self._priceToStr(combination.standard_price)); var isCombinationPossible = true; if (typeof combination.is_combination_possible !== "undefined") { isCombinationPossible = combination.is_combination_possible; } this._toggleDisable($parent, isCombinationPossible); if (combination.has_discounted_price && !combination.compare_list_price) { $default_price .closest('.oe_website_sale') .addClass("discount"); $optional_price .closest('.oe_optional') .removeClass('d-none') .css('text-decoration', 'line-through'); $default_price.parent().removeClass('d-none'); } else { $default_price .closest('.oe_website_sale') .removeClass("discount"); $optional_price.closest('.oe_optional').addClass('d-none'); $default_price.parent().addClass('d-none'); } var rootComponentSelectors = [ 'tr.js_product', '.oe_website_sale', '.o_product_configurator' ]; I need to modify the code where the prices are updated: $price.text(self._priceToStr(combination.price)); $default_price.text(self._priceToStr(combination.list_price)); I want to add something like this: $standard_price.text(self._priceToStr(combination.standard_price)); I want to make this change within my custom module, but I'm not sure how to properly extend this function in Odoo 17. I read about extends and patch but i do not know what to use. Could someone guide me on how to achieve this?
Leave a Comment