Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FW][FIX] website_sale: prevent typeerror when ribbon background color is False #159409

Conversation

fw-bot
Copy link
Contributor

@fw-bot fw-bot commented Mar 27, 2024

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

Traceback:

TypeError: argument of type 'bool' is not iterable
  File "odoo/http.py", line 2251, in __call__
    response = request._serve_db()
  File "odoo/http.py", line 1826, in _serve_db
    return self._transactioning(_serve_ir_http, readonly=ro)
  File "odoo/http.py", line 1847, in _transactioning
    return service_model.retrying(func, env=self.env)
  File "odoo/service/model.py", line 134, in retrying
    result = func()
  File "odoo/http.py", line 1824, in _serve_ir_http
    return self._serve_ir_http(rule, args)
  File "odoo/http.py", line 1832, in _serve_ir_http
    response = self.dispatcher.dispatch(rule.endpoint, args)
  File "odoo/http.py", line 2057, in dispatch
    result = self.request.registry['ir.http']._dispatch(endpoint)
  File "odoo/addons/base/models/ir_http.py", line 222, in _dispatch
    result = endpoint(**request.params)
  File "odoo/http.py", line 740, in route_wrapper
    result = endpoint(self, *args, **params_ok)
  File "addons/web/controllers/dataset.py", line 34, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "addons/web/controllers/dataset.py", line 30, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "odoo/api.py", line 458, in call_kw
    result = getattr(recs, name)(*args, **kwargs)
  File "addons/web/models/models.py", line 74, in web_save
    self = self.create(vals)
  File "<decorator-gen-471>", line 2, in create
  File "odoo/api.py", line 420, in _model_create_multi
    return create(self, [arg])
  File "addons/website_sale/models/product_ribbon.py", line 24, in create
    if 'bg_color' in vals and not '!important' in vals['bg_color']:

if 'bg_color' in vals and not '!important' in vals['bg_color']:
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


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #158561

… 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: e9021f1
@robodoo
Copy link
Contributor

robodoo commented Mar 27, 2024

@robodoo robodoo added the forwardport This PR was created by @fw-bot label Mar 27, 2024
@C3POdoo C3POdoo added the RD research & development, internal work label Mar 27, 2024
@reka-odoo
Copy link
Contributor

@fw-bot r+

@reka-odoo
Copy link
Contributor

@fw-bot r+

@adwid
Copy link
Contributor

adwid commented Mar 29, 2024

@reka-odoo
Don't worry, the command has already been correctly received the first time you sent it
There is just a huge waiting queue on the merge page
2024-03-29_08-51
See https://mergebot.odoo.com/runbot_merge

@robodoo
Copy link
Contributor

robodoo commented Mar 29, 2024

@reka-odoo @AntoineVDV unable to stage: merge conflict

@AntoineVDV
Copy link
Contributor

Superseded by #145562

@AntoineVDV AntoineVDV closed this Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants