[18.0][website_sale_empty_cart] TypeError on /shop/cart when website_sale_loyalty is installed

Open Beginner friendly
#1,237 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
backend, web-dev

Research direction

Start in website_sale_empty_cart/controllers/main.py at the cart method and inspect how it calls the parent controller. Check the cart overrides involved when website_sale_loyalty is installed, then reproduce the issue using the listed module installation steps. Done means /shop/cart renders and the empty-cart action works with and without the empty_cart parameter.

Written by the indexing model from the issue text.

Description

bug
Module

website_sale_empty_cart (18.0)

Odoo version

18.0

Current behavior

Accessing /shop/cart raises:

TypeError: WebsiteSale.cart() takes 1 positional argument but 3 were given

Expected behavior

Cart page should render normally, and empty-cart action should work.

Steps to reproduce
  1. Install website_sale
  2. Install website_sale_empty_cart
  3. Install website_sale_loyalty
  4. Go to /shop/cart
  5. Trigger cart route (with or without empty_cart param)
Traceback

Traceback (most recent call last):
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/http.py", line 2167, in _transactioning
return service_model.retrying(func, env=self.env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/service/model.py", line 157, in retrying
result = func()
^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/http.py", line 2134, in _serve_ir_http
response = self.dispatcher.dispatch(rule.endpoint, args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/http.py", line 2295, in dispatch
return self.request.registry['ir.http']._dispatch(endpoint)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/addons/base/models/ir_http.py", line 333, in _dispatch
result = endpoint(**request.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/http.py", line 754, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/extra-addons/e-commerce.git-6916c9356ea0f/website_sale_empty_cart/controllers/main.py", line 18, in cart
return super().cart(access_token, revive, **post)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/var/odoo/staging-ordonnanceur.odoo.kiub.fr/src/odoo/http.py", line 754, in route_wrapper
result = endpoint(self, *args, **params_ok)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: WebsiteSale.cart() takes 1 positional argument but 3 were given

Analysis

website_sale_empty_cart calls parent with positional args:
super().cart(access_token, revive, **post)

In a stack where another controller override defines cart as kwargs-only (e.g. loyalty override), this fails with the positional-argument TypeError.

Proposed fix

Use keyword arguments when calling super:
super().cart(access_token=access_token, revive=revive, **post)

This is compatible with both parent signatures.

Dominant language
HTML
Stars
206
Forks
578
Avg merge
2d 17h
Merged PRs (30d)
15

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from OCA/e-commerce

All issues in OCA/e-commerce

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.