Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1483 Lượt xem

I am trying to add a product to the cart through an AJAX request. 
Just from the front-end in the website module. 
Is this even possible?

It is not taking in the 'product_id' parameter. 

I can't find any clear documentation on these functions.

Where can I find these resources?

~ Odoo 17.1

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hi Max,

In this query, you did not provide information about the method you wrote, so I assumed you were referring to a method called cart_update_json() within the WebsiteSale class."

The error message you're encountering indicates that the method cart_update_json() in the WebsiteSale class is missing a required positional argument, which is product_id. This suggests that when calling the cart_update_json() method, you're not providing the required product_id argument.

Here's a general understanding of what might be happening and how you can resolve it:

  1. Check Method Signature: Make sure you're calling the cart_update_json() method with the correct number of arguments and in the correct order. If the method expects a product_id argument, ensure that you're passing it when calling the method.
  2. Inspect Code: Look into the definition of the cart_update_json() method in the WebsiteSale class to understand how it's implemented and what arguments it expects. Ensure that you're providing all the required arguments when calling the method.
  3. Debugging: If you're still unsure why the error is occurring, you can add print statements or use a debugger to inspect the values of variables and arguments leading up to the call of cart_update_json(). This can help identify any issues with variable values or argument passing.
  4. Check for Overrides: If you've overridden the cart_update_json() method in a custom module or template, ensure that your implementation still follows the correct signature and usage of the original method.


Hope it helps

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 23
2717
3
thg 5 19
6561
1
thg 12 24
2210
0
thg 10 22
659
0
thg 10 22
379