Odoo Help


How to get stock displayed to public on the ecommerce product page ?

Alain Vanzella
on 10/28/14, 5:43 AM 1,214 views

I'm tying to get the product available quantity displayed on the on the ecommerce product page.

Adding  <p t-field="product.qty_available"></p> in the the website_sale.product template does the job but information appears just when logged as a company user. Public visitors don't see it.

Is it possible to get this field visible to public visitors?

product.qty_available is a calculated field and the public user don't have access to stock_workshop and stock_location. Create other field qty_pubic_available and read qty_available using SUPERUSER_ID. Example for test if product is or not in stock. class product_template(orm.Model): _inherit = 'product.template' def _is_qty_available(self, cr, uid, ids, name, args, context=None): res = {} for product in self.browse(cr, SUPERUSER_ID, ids, context=context): if product.qty_available > 0: res[product.id] = True else: res[product.id] = False return res _columns = { 'is_qty_available': fields.function(_is_qty_available, type='boolean'), 'product_brand_id': fields.many2one('product.brand', 'Brand', help='Select a brand for this product.', ondelete='restrict'), }

Dorin Hongu
on 10/28/14, 10:26 AM

Thanks for you response. Nice to hear there is a solution. In which model do I have to create the new field? Could you give some advise on where to put the code you suggested and also why you are refering to product brand?

Alain Vanzella
on 10/28/14, 12:14 PM

swapnil wagh

--swapnil wagh--
| 6 5 8
Pune, India
--swapnil wagh--

My name is Swapnil A. Wagh. I studied Master Of computer Science and work as a Software Engineer. I’m a technology enthusiast and always eager to learn new and exciting technologies. I’m constantly looking for innovative solutions to age-old problems that push the limits of what we conceive to be possible.

swapnil wagh
On 10/28/14, 10:06 AM

Did you publish the product on website, in product form-> edit tab there is a button publish to publish the product on website. Hope it will help you

Yes for sure, products are published on the website but stock info (using

) is not visible from public users.
Alain Vanzella
on 10/28/14, 10:13 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)


Asked: 10/28/14, 5:43 AM
Seen: 1214 times
Last updated: 3/16/15, 8:10 AM