From 8bac60cecd2e7ce081a0d367a53e0114258c5ab5 Mon Sep 17 00:00:00 2001 From: reka-odoo Date: Thu, 21 Mar 2024 16:01:21 +0530 Subject: [PATCH] [FIX] website_sale: prevent typeerror when ribbon background color is False When the user creates a new ribbon without a background color, a traceback will appear. Steps to reproduce the error: - Install "website_sale" - Go to Website > eCommerce > Products - Pick a product > Sales > Create a new ribbon without a background color - Save & Close Error: A traceback appears: "TypeError: argument of type 'bool' is not iterable" https://github.com/odoo/odoo/blob/806a60d9766e4e04f461a0fb7c824cf5f5c7d5ae/addons/website_sale/models/product_ribbon.py#L24 Here, when the user creates a new ribbon without a background color, "bg_color" will be False, so when it tries to check "vals['bg_color']". It will lead to the above traceback. sentry-5077714703 X-original-commit: e9021f1332b49042733cf263e8cb62218ccc2965 --- addons/website_sale/models/product_ribbon.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/website_sale/models/product_ribbon.py b/addons/website_sale/models/product_ribbon.py index 65683503e3798..6fe793c26c007 100644 --- a/addons/website_sale/models/product_ribbon.py +++ b/addons/website_sale/models/product_ribbon.py @@ -24,11 +24,11 @@ def _compute_display_name(self): @api.model_create_multi def create(self, vals_list): for vals in vals_list: - if 'bg_color' in vals and not '!important' in vals['bg_color']: + if vals.get('bg_color') and not '!important' in vals['bg_color']: vals['bg_color'] += ' !important' return super().create(vals_list) def write(self, data): - if 'bg_color' in data and not '!important' in data['bg_color']: + if data.get('bg_color') and not '!important' in data['bg_color']: data['bg_color'] += ' !important' return super().write(data)