[FIX] website_sale: add !important to ribbon color

Before this commit, the bg-primary class was overwriting the bg_color
set by the user after saving changes as it has the !important tag.

Steps to reproduce the issue:
    1. Go to Shop page on website
    2. Enable edit mode
    3. Pick a product and create a new Badge (ribbon)
    4. Change the background color and save changes
        -> color reverts to bg-primary

This commit fixes this behavior by adding the !important tag to the
bg_color so that it properly overwrites the bg-primary color.

opw-3734598

closes odoo/odoo#155274

X-original-commit: 9ee115b58342b3e0dbc11081e7ff752c10f8bfa9
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Simon Goffaux (sigo) <sigo@odoo.com>
This commit is contained in:
Simon Goffaux (sigo)
2024-03-01 08:45:43 +00:00
parent 5704cce223
commit dbbc90e9ea
@@ -17,3 +17,15 @@ class ProductRibbon(models.Model):
bg_color = fields.Char(string='Ribbon background color', required=False)
text_color = fields.Char(string='Ribbon text color', required=False)
html_class = fields.Char(string='Ribbon class', required=True, default='')
@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']:
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']:
data['bg_color'] += ' !important'
return super().write(data)