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
- Akuntansi
- Inventaris
- PoS
- Project
- MRP
Pertanyaan ini telah diberikan tanda
1671
Tampilan
Menikmati diskusi? Jangan hanya membaca, ikuti!
Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!
DaftarPost Terkait | Replies | Tampilan | Aktivitas | |
---|---|---|---|---|
|
0
Jul 25
|
220 | ||
|
0
Jun 25
|
445 | ||
How to use multi label switching interface in Odoo
Diselesaikan
|
|
1
Jun 25
|
690 | |
|
1
Jun 25
|
717 | ||
|
1
Mei 25
|
1262 |