Hi, I am trying (in Odoo 10), if product quantity on hand is zero than show "Out of Stock" on Website. Following code is working fine when I am logged in as Admin, but in case of normal website visitor it gives, "500: Internal Server Error" Any solution Please? Screenshot
Asked
Active
Viewed 401 times
-1
-
**DO NOT post images of code, data, error messages, etc.** - copy or type the text into the question. [ask] – Rob Apr 06 '21 at 01:18
1 Answers
0
This happens because qty_available
is a function field that calls the _compute_quantities
method. This method accesses to different models, so when entering with no user or with one without the necessary permissions odoo raises AccessError
.
To fix this problem, let's access the field through sudo()
<t t-if="product.sudo().qty_available <= 0">
<div class="ribbon-wrapper out-of-stock" style="display: inherit !important;">
<div class="ribbon btn btn-danger">Out of Stock</div>
</div>
</t>

Tiki
- 760
- 1
- 8
- 16