Ir al contenido
Menú
Se marcó esta pregunta

I created a drop down menu inside odoo website module's checkout page (/shop/cart, code shown below), how can I fetch the user's selection and save it to a field inside my model? Current using latest version of Odoo 16


XML:

If the XML is empty/looks weird... its because the forum keep eating my code away...

(edit: I posted this question on stackoverflow as well, and I cant post link so Ima just put the title of the question here: "How to Fetch User Selection in Drop Down Selection in Odoo Website Module")


My attempt on JS:

$('#some123').on('change', 'select.some1', function(e) {

e.preventDefault();

var value = $( ".some1" ).val();

var ID = $( ".temp" ).val();

});


My attempt on controller (inherited cart_update_json method in WebsiteSale class):

value = kw.get('value')
current_line = kw.get('ID')
record = request.env['sale.order.line'].sudo().search([('product_id', '=', current_line)])
if record:
record.write({'some_field': value})
else:
print("Test")
Avatar
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
1
ago 20
8769
2
jun 20
3776
2
jul 24
989
2
jun 23
41932
1
dic 22
3046