I am using Odoo 9 and I want to deny the creation of products for some users, for example, for the persons who do sales, I want them to only have access to products which are already created. They must not have the right to create new products. How can I do it? Any idea for this, please?
product.py
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)
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>