From 0aab88c917e44f0d908b0bbbd9773e573d2d624b Mon Sep 17 00:00:00 2001 From: dsolanki Date: Mon, 24 May 2021 16:31:50 +0530 Subject: [PATCH] [MIG] Migrate module pos_reset_search to v14. --- pos_reset_search/__manifest__.py | 2 +- pos_reset_search/readme/CONTRIBUTORS.rst | 2 ++ pos_reset_search/static/src/js/reset.js | 38 ++++++++++++++++++------ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/pos_reset_search/__manifest__.py b/pos_reset_search/__manifest__.py index f66c54bd54..727c868d06 100644 --- a/pos_reset_search/__manifest__.py +++ b/pos_reset_search/__manifest__.py @@ -2,7 +2,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Point of Sale - Clear product search on click", - "version": "12.0.1.0.0", + "version": "14.0.1.0.0", "category": "Point of Sale", "summary": "Point of Sale - Clear product search when user clicks on a product.", "author": "Le Nid, Odoo Community Association (OCA)", diff --git a/pos_reset_search/readme/CONTRIBUTORS.rst b/pos_reset_search/readme/CONTRIBUTORS.rst index 250f9dd1c3..13a8787ed3 100644 --- a/pos_reset_search/readme/CONTRIBUTORS.rst +++ b/pos_reset_search/readme/CONTRIBUTORS.rst @@ -1,2 +1,4 @@ - Le Nid - CoopITEasy + +* Dhara Solanki diff --git a/pos_reset_search/static/src/js/reset.js b/pos_reset_search/static/src/js/reset.js index 4e81bbfe64..c37349e574 100644 --- a/pos_reset_search/static/src/js/reset.js +++ b/pos_reset_search/static/src/js/reset.js @@ -1,12 +1,32 @@ odoo.define("product_click_search_reset", function (require) { "use strict"; - var screens = require("point_of_sale.screens"); - - screens.ProductScreenWidget.include({ - click_product: function (product) { - var self = this; - self._super(product); - self.product_categories_widget.clear_search(); - }, - }); + + const ProductScreen = require("point_of_sale.ProductScreen"); + const Registries = require("point_of_sale.Registries"); + + const PosProductScreen = (ProductScreen) => + class extends ProductScreen { + async _clickProduct(event) { + const ProductScreenChildren = this.__owl__.children; + + const ProductWidget = ProductScreenChildren.find( + (child) => child.el.className === "products-widget" + ); + if (ProductWidget) { + const ProductWidgetChildren = ProductWidget.__owl__.children; + + const ProductsWidgetControlPanel = ProductWidgetChildren.find( + (child) => child.el.className === "products-widget-control" + ); + if (ProductsWidgetControlPanel) { + ProductsWidgetControlPanel.clearSearch(); + } + } + return super._clickProduct(event); + } + }; + + Registries.Component.extend(ProductScreen, PosProductScreen); + + return ProductScreen; });