From cb0efa815d43dc64b4116c17beb2cd488285ae8d Mon Sep 17 00:00:00 2001 From: vlst-odoo Date: Tue, 30 Jan 2024 16:40:44 +0100 Subject: [PATCH] [IMP] point_of_sale: allow hiding images In this commit we add the ability to toggle between showing and not showing product and category images in the pos ui. Because this change is done in stable, we store the user's selection in `ir.config.parameter`. In the forward port, this will be removed and the settings will be stored in `pos.config` Task 3704416 closes odoo/odoo#151823 Signed-off-by: Joseph Caburnay (jcb) --- addons/point_of_sale/models/pos_config.py | 4 + addons/point_of_sale/models/pos_session.py | 2 + .../category_selector/category_selector.js | 2 +- .../product_card/product_card.js | 2 +- .../static/src/app/navbar/navbar.xml | 14 +++- .../product_list/product_list.js | 1 + .../product_list/product_list.xml | 2 +- .../static/src/app/store/pos_store.js | 81 +++++++++++++------ 8 files changed, 81 insertions(+), 27 deletions(-) diff --git a/addons/point_of_sale/models/pos_config.py b/addons/point_of_sale/models/pos_config.py index 34f16a615ca..69d67883352 100644 --- a/addons/point_of_sale/models/pos_config.py +++ b/addons/point_of_sale/models/pos_config.py @@ -814,6 +814,10 @@ class PosConfig(models.Model): except (TypeError, ValueError, OverflowError): return default_limit + def toggle_images(self, for_products, for_categories): + self.env['ir.config_parameter'].sudo().set_param('point_of_sale.show_product_images', for_products) + self.env['ir.config_parameter'].sudo().set_param('point_of_sale.show_category_images', for_categories) + def get_limited_partners_loading(self): self.env.cr.execute(""" WITH pm AS diff --git a/addons/point_of_sale/models/pos_session.py b/addons/point_of_sale/models/pos_session.py index e68604972d3..a08fd1f26c9 100644 --- a/addons/point_of_sale/models/pos_session.py +++ b/addons/point_of_sale/models/pos_session.py @@ -1687,6 +1687,8 @@ class PosSession(models.Model): loaded_data['pos_special_products_ids'] = self.env['pos.config']._get_special_products().ids loaded_data['open_orders'] = self.env['pos.order'].search([('session_id', '=', self.id), ('state', '=', 'draft')]).export_for_ui() loaded_data['partner_commercial_fields'] = self.env['res.partner']._commercial_fields() + loaded_data['show_product_images'] = self.env['ir.config_parameter'].sudo().get_param('point_of_sale.show_product_images', 'yes') + loaded_data['show_category_images'] = self.env['ir.config_parameter'].sudo().get_param('point_of_sale.show_category_images', 'yes') @api.model def _pos_ui_models_to_load(self): diff --git a/addons/point_of_sale/static/src/app/generic_components/category_selector/category_selector.js b/addons/point_of_sale/static/src/app/generic_components/category_selector/category_selector.js index 4c747263912..12a8d72af6e 100644 --- a/addons/point_of_sale/static/src/app/generic_components/category_selector/category_selector.js +++ b/addons/point_of_sale/static/src/app/generic_components/category_selector/category_selector.js @@ -22,7 +22,7 @@ export class CategorySelector extends Component { icon: { type: String, optional: true }, separator: { type: String, optional: true }, showSeparator: { type: Boolean, optional: true }, - imageUrl: { type: String, optional: true }, + imageUrl: { type: [String, Boolean], optional: true }, }, }, class: { type: String, optional: true }, diff --git a/addons/point_of_sale/static/src/app/generic_components/product_card/product_card.js b/addons/point_of_sale/static/src/app/generic_components/product_card/product_card.js index 69f5e5119a3..d6dd622f3ad 100644 --- a/addons/point_of_sale/static/src/app/generic_components/product_card/product_card.js +++ b/addons/point_of_sale/static/src/app/generic_components/product_card/product_card.js @@ -9,7 +9,7 @@ export class ProductCard extends Component { name: String, productId: Number, price: String, - imageUrl: String, + imageUrl: [String, Boolean], productInfo: { Boolean, optional: true }, onClick: { type: Function, optional: true }, onProductInfoClick: { type: Function, optional: true }, diff --git a/addons/point_of_sale/static/src/app/navbar/navbar.xml b/addons/point_of_sale/static/src/app/navbar/navbar.xml index c3f8199bcea..5ab32f9f20f 100644 --- a/addons/point_of_sale/static/src/app/navbar/navbar.xml +++ b/addons/point_of_sale/static/src/app/navbar/navbar.xml @@ -23,7 +23,7 @@