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
Se marcó esta pregunta
2762
Vistas
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
Registrarse| Publicaciones relacionadas | Respuestas | Vistas | Actividad | |
|---|---|---|---|---|
|
|
0
abr 26
|
18 | ||
|
|
0
abr 26
|
7 | ||
|
|
0
mar 26
|
5 | ||
|
|
0
nov 25
|
195 | ||
|
|
2
nov 25
|
2082 |