\odoo15\server\odoo\addons\base\models\ir_http.py(96)_auth_method_user()
-> raise http.SessionExpiredException("Session expired")
-----------------------------------
I am getting this error when I am not logged in in my website. I am trying to create a form using JS. It works fine when I am logged in.
js code:
odoo.define('call_for_price_website.create', function (require) {
"use strict";
const rpc = require('web.rpc');
var core = require('web.core');
var session = require('web.session');
$('#send_btn').on('click', function(){
var first = $('#first_name').val();
var last = $('#last_name').val();
var product_id = $('#product_id').val();
var product_variant_id = $('#product_variant_id').val();
try{
var product_variant_id = $('#product_variant_id').val();
}
catch(err){
var product_variant_id = 0;
}
var selected_attr_value = $('.custom-select').find(':selected').attr('title');
try{
var selected_attribute = document.querySelector('input[data-attribute_name="Brand"]:checked').getAttribute('title');
}
catch(err){
var selected_attribute = "None";
}
var phone = $('#phone').val();
var email = $('#email').val();
var message = $('#message').val();
var qty = $('#quantity').val();
var start_date = $('#start_date').val();
var end_date = $('#end_date').val();
if(typeof selected_attr_value === 'undefined'){
selected_attr_value = selected_attribute;
}
rpc.query({
model: "my.model",
method: "form_method",
args:[first,last,product_id,selected_attr_value,phone,email,message,qty,start_date,end_date]
}).then(function (something) {
var result = document.getElementById(something);
if (result === null) {
// Element with the specified ID does not exist in the document
document.getElementById('a_block').style.display = "block"
} else {
// Element with the specified ID exists in the document
result.style.display = "block"
}
});
});
});
-----------------------------------------------------------------------
model security:
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_my_model,access_my_model,model_my_model,,1,1,1,1
-------------------------------------------------------------