Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
8611 Widoki

I am using v12 Odoo Online and I am trying to show my on hand quantity to the product pages online.

The first line of code I added to the product page was:

<h4 class="text-success">Quantity Available: <span t-field="product.qty_available"/>.</h4>

After adding this code, when I refreshed the Product page on the front end of the website, I got the error page "403: Forbidden  The page you were looking for could not be authorized." 

Is there something that prevents the "product.qty_available" field from being displayed on the product page? I have added other field to the page such as "product.uom_id" and some studio fields, without issue.

Awatar
Odrzuć
Najlepsza odpowiedź

'qty_available' is a computed field (in real time). Its calculations requires a user to be at least an employee. This is why public / portal users can't observe such a page.

You may show quantity under sudo():

<span t-field="product.sudo().qty_available"/>

In such a way the figure would be calculated as you are under Odoo SuperUser. Take into account that this approach might have drawbacks:

  1. It is not totally safe, altough there is no much space to retrieve extra information here

  2. In case you have some restrictions by locations, they would not be applied: a user would see ALL stocks.

As alternative you can develop an own method to calculate available quantities. In that method you can also apply sudo(), but it is possible to do that more carefully in the method.



Awatar
Odrzuć

Nice!! I had to do the same with:
`<t t-foreach="product.sudo().product_variant_ids" t-as="variant_id">`

Powiązane posty Odpowiedzi Widoki Czynność
1
lut 25
1129
1
sty 24
2093
1
cze 23
3079
2
lut 21
10411
0
gru 16
5896