Skip to Content
Menu
This question has been flagged
1642 Views
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 

Avatar
Discard
Related Posts Replies Views Activity
0
Jun 25
308
1
Jun 25
620
1
Jun 25
606
1
May 25
1180
0
Mar 25
668