Firstly, I'm using Odoo 13 Enterprise, hosted by Odoo (SaaS.)
I want to create a customized product page for our eCommerce store. I would like to use JQuery to control the page elements. Since I use the SaaS version of Odoo, I do not have the option of including Python code in my custom modules, so I can't create a custom Python controller to pass the database values to my JavaScript module.
I want to be able to access specific product information in my JavaScript module, very similar to what Odoo has set up with the "product.template" model.
I found the RPC section in the documentation, and it works great to get the values I need, except for when a user is NOT logged in. Apparently, you have to be logged in to make RPC calls to the database. When I tried to use RPC calls as an "anonymous" user I got a session error. After looking it up, I found that this is due to not being logged in. I obviously need to be able to display this custom product page to users that are not logged into my website.
All I need is the initial information dump of all the product values in an array or object, then I can use JavaScript to filter the information as needed.
Things I've tried:
I've tried using Python inside QWeb to retrieve the values as follows:
<t t-set="products" t-value="request.env['product.template'].search([('is_published', '=', true)])"/>
which gives me the values I need, but I'm not sure how (if it's even possible) to pass the "products" variable to my JavaScript module so I can use it.
I've also tried using RPC as follows:
var domain = [];
var fields = ['name', 'website_description'];
var products = this._rpc({
model: 'product.template',
method: 'search_read',
args: [domain,fields]
}).then(function (res) {
console.log(res);
})
which will work if the user is logged in, but gives me a session error when the page is accessed by a user that is not logged in.
Is there any way to access the product information I need (name, price, description, etc.) without using RPC, OR get the values using RPC as an "anonymous" user without having to log in? Like, can I create a single RPC call as a designated user from inside my JavaScript module to get the database values and avoid getting a session error, then pass that array/object to a JavaScript function that can be used by an "anonymous" user?