Odoo Help

1

Odoo 8 acess rights

By
Denys
on 1/1/15, 7:26 PM 923 views

Hello, evrybody!

I changed class product_template to show available products quantity to costumers.
Changes:
new function
    def _product_template_quant(self, cr, uid, ids, name, arg, context=None):
        res = {}
        for product in self.browse(cr, uid, ids):
            if product.qty_available == 0.0:
                res[product.id] = str('Not available')
            else:
                res[product.id] = 'Available: ' + str(int(product.qty_available))
        return res
Add this function to model:
_columns={
.....
'quant': fields.function(_product_template_quant, type='char', string='Available products'),
.....}

After that i changed template
to show t-field="product.quant"

When I logged in odoo like administrator evrything go fine: i can see product quantity.
But when i`m public user (not logged on at all) i  can`t see anything.

If i change function _product_template_quant to it return constant:
    def _product_template_quant(self, cr, uid, ids, name, arg, context=None):
        res = {}
        for product in self.browse(cr, uid, ids):
            res[product.id] = 'My test const '
        return res
evrything go fine and i see 'My test const' as public user.

So, i think the problem is acess rights for field product.qty_available for public user.
I find table ir_model_access, but i can`t understand  how to give acess to product.qty_available to public user.

Can somebody give me an example how to do that?

UPDATE: here is the warning from log.
WARNING mechanic openerp.addons.base.ir.ir_model: Access Denied by ACLs for operation: read, uid: 3, model: stock.warehouse

uid:3 it is public user.
 

2
Akhil P Sivan
On 1/11/15, 8:22 AM

Denys, you can add field access control, by including a "groups" attribute in the field definition.

For eg: in the field definition of 'quant', after string='Available products', add groups="base.group_user"

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: 1/1/15, 7:26 PM
Seen: 923 times
Last updated: 3/16/15, 8:10 AM