i have created a new group which is personal to restrict some users to create new product. So i have developed a custom module to do my needs. After installing the module and adding the user to the group i connect with this user to verify if he is able to add a new product or not , and i found he can. Could any body help me please to verify if my code is right or not because i'm not sure if it is the right way to create a new group and add user to it
https://ibb.co/9cgssBt
security.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model="res.groups" id="your_group">
<field name="name">Group of users who cannot create new products</field>
</record>
</data>
product.py
# -*- coding: utf-8 -*-
from openerp import fields,models,api
from openerp import tools
import openerp.addons.decimal_precision as dp
from openerp.tools.translate import _
class product_product(models.Model):
_inherit = "product.product"
@api.model
def create(self, vals):
if self.env.user.has_group('yor_module.your_group'):
raise Warning(
_('Sorry, you are not allowed to create new products.'),
)
else:
return super(product_product, self).create(vals)
Odoo Tips: https://plus.google.com/collection/MrdEWE