I tried using javascript to fetch user's selection on a drop down selection inside Odoo's website, but I got the error in the title while doing it. Here is my code:
JS:
odoo.define("my-module.Custom", function (require) {
"use strict";
var ajax = require("web.ajax");
var value = document.getElementById("selection").value;
return ajax.jsonRpc("/shop/cart/update_json", "call", {
'value': value,
})
});
Part of XML:
select class="selection" name="selection" id="selection"
option selected="true" t-att-value="line.some_fields" t-esc="line.some_fields"/
t-foreach="request.env['res.partner'].sudo().search([])" t-as="x"
t-foreach="x.subpoint_id" t-as="y"
t-if="y.name"
t-if="(request.env.user.partner_id.member_id in y.name)"
t t-set="current_alloc" t-value="y.name"/
option t-att-value="y.name" t-esc="y.name"/
/
/
/
/
/select
Part of Controller (inheriting WebsiteSales):
_logger.info("Test")
value = kw.get("value")
if value:
_logger.info("Test1")
abc = 0
for line in request.website.sale_get_order(force_create=True).order_line:
_logger.info(abc)
abc += 1
line.write({
'some_field': value
})
In the code above, my drop down selection doesnt seem to grab the user's selection upon a change, and it gives me error when I click add/subtract product quantity more than once.
Error:
UncaughtClientError
Uncaught Javascript Error > Service my-script already defined
Error: Service my-script already defined
at odoo.define
at :1:6
at DOMEval
at Function.globalEval
at text script
at ajaxConvert
at done
at XMLHttpRequest.
at Object.send
at Function.ajax
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
1757
Lượt xem
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 7 25
|
320 | ||
|
1
thg 7 25
|
5123 | ||
|
0
thg 7 25
|
681 | ||
|
0
thg 6 25
|
738 | ||
|
1
thg 6 25
|
909 |