How to restrict users from creating companies? I want them to have permissions to create individuals only.
Both individuals and and companies come under Partner.
(Odoo 18 community edition)
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How to restrict users from creating companies? I want them to have permissions to create individuals only.
Both individuals and and companies come under Partner.
(Odoo 18 community edition)
Use this to restrict users from creating contacts:
from odoo import models, api, _
from odoo.exceptions import ValidationError
class ResPartner(models.Model):
_inherit = 'res.partner'
@api.model
def create(self, vals):
if vals.get('is_company') and not self.env.user.has_group('base.group_system'):
raise ValidationError(_("You are not allowed to create companies. Please create individuals only."))
return super(ResPartner, self).create(vals)
def write(self, vals):
if vals.get('is_company') and not self.env.user.has_group('base.group_system'):
raise ValidationError(_("You are not allowed to convert a contact into a company."))
return super(ResPartner, self).write(vals)
Optional: Hide or Disable the “Is a Company” Checkbox in the Form
Stwórz konto dzisiaj, aby cieszyć się ekskluzywnymi funkcjami i wchodzić w interakcje z naszą wspaniałą społecznością!
Zarejestruj sięPowiązane posty | Odpowiedzi | Widoki | Czynność | |
---|---|---|---|---|
|
3
lip 25
|
635 | ||
|
1
cze 25
|
1120 | ||
|
1
maj 25
|
1404 | ||
|
3
mar 25
|
2050 | ||
|
1
mar 25
|
1546 |