Odoo Help

0

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

By
Alain Vanzella
on 10/28/14, 5:43 AM 1,361 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
0
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

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.

Register

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)

Stats

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