Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
2 Răspunsuri
12487 Vizualizări

Hello Everyone,


We were looking into the ability to restrict a user so that they may create a person (contact) within a company contact record but not create an entire new company. So far all we can find  is the ability to restrict a user from creating a contact in general.

Is this possible? If so, how would we be able to accomplish this?

Thank you for any help.

Imagine profil
Abandonează
Cel mai bun răspuns

You can't use Access Rules / Security Groups as both an Individual and a Company are stored in the same model.


This example tests to see if the user is a member of the Sales Manager group, and if not, restricts saving if the record is not an individual:



 

Create an AUTOMATED action for the res.partner model that is triggered on CREATE of res.partner:





The Server Action would be defined something like this:


if not env.user.has_group('base.group_sale_manager') and record.company_type != 'person':
    raise Warning("You can't do that")

Imagine profil
Abandonează
Cel mai bun răspuns

While it's entirely possible to implement it as Ray Carnes has done (As a bonus it even gives you the ability to raise a custom warning, rather than the generic permission denied message, which is why I prefer his method), I just wanted to show that a rule like this can easily be implemented through the access rules.


While individuals and companies are the same model, you can restrict CRUD permissions on a model by domain filtering. Therefore we can give Create/Delete permission to a group only when the is_company field is false.


(Using v11, though similar for v9/10)


In Settings -> Users & Companies (Users in v9-10) -> Groups -> Extra Rights /  Contact Creation -> Rules -> Edit -> Add an Item -> Create

From here you can create a rule. 

Object: res.partner

Access Rights: Create (And possibly delete, depends on your needs)

Rule definition: [('is_company', '=', False)]

Groups: Extra Rights / Contact Creation


Note: if another rule exists regarding res.model models, things get a little trickier. Read the "Interaction between rules" section on the creation menu for more information.

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
iul. 18
1638
2
aug. 22
3551
1
aug. 22
2677
1
mai 25
1439
2
mar. 25
5882