Odoo Help

Welcome!

This community 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.

1

Odoo 8 acess rights

By
Denys
on 1/1/15, 7:26 PM 697 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

--Akhil P Sivan--
3423
| 5 3 6
Kochi, India
--Akhil P Sivan--

Interested in exploring Odoo both technically & functionality wise.

email-id : akhilpsivan01@gmail.com

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"

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 1/1/15, 7:26 PM
Seen: 697 times
Last updated: 3/16/15, 8:10 AM