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
- Kirjanpito
- Varastointi
- PoS
- Project
- MRP
Tämä kysymys on merkitty
1674
Näkymät
Nautitko keskustelusta? Älä vain lue, vaan osallistu!
Luo tili jo tänään nauttiaksesi yksinoikeusominaisuuksista ja osallistuaksesi mahtavaan yhteisöömme!
RekisteröidyAiheeseen liittyviä artikkeleita | Vastaukset | Näkymät | Toimenpide | |
---|---|---|---|---|
|
0
heinäk. 25
|
254 | ||
|
0
kesäk. 25
|
476 | ||
|
1
kesäk. 25
|
711 | ||
|
1
kesäk. 25
|
733 | ||
|
1
toukok. 25
|
1284 |