Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
4 Odpowiedzi
16325 Widoki

I want to disable the Delete option in the 'action drop down' menu to prevent users from deleting a contact.

Iam working with Odoo 11.0.

I would appreciate any suggestions.

Thanks in advance!

Awatar
Odrzuć
Najlepsza odpowiedź

Hello

there are many way to achieve this.

1. into the tree/form view of the contact add the delete attribute. 

    like <tree delete="0"> . for the form <form delete="0">

2. remove the users access rights of users for the delete the contact from menu "Access Rights"

3. override fields_view_get, you can also remove the option for the "delete" from "Action Drop Down"

4. override the unlink. using this you have option "delete" in "Action" dropdown. but using override unlink method  you can raise error, so user cannot delete contact.

I hope this answer will helps you.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Dear Mitul and Samo, first of all, thanks for your help. Here's my problem:

Initially I tried to solve the problem by removing (in Ajustments \ Database Structure \ Models \ res.partner) the permission to delete in the res.partner model, but it did not allow users to delete the contacts created in the "Contacts and addresses" form the Contacts form, which should be allowed. That's why I had to give them back access to delete contacts.

The problem arises when it is detected that a group of contracts had the partner_id field in blank, which is an error because the Contracts module has this field as mandatory.

So to verify this inconsistency, I tried to eliminate a client with a Contract in the Contacts module and the Odoo allowed it, leaving the partner_id field in blank in their respective contract.

For this reason I want to limit the possibility that a normal user can eliminate contacts.

On the other hand my programming knowledge in Odoo is very limited, I have been learning Odoo for only 3 months, so I ask you to give me examples of a piece of code to understand, for example, where I should put:

  like <tree delete = "0">. for the form <form delete = "0">

or

how "i can override fields_view_get, you can also remove the option for the "delete" from "Action Drop Down""

or 

how Samo "overriding the unlink method for the res_partner. I added an if that checks if the user has group for root the it allows to delete the record, else it raises a validation error"

Thanks you very much in advance!

Iam working with Odoo 11.0


Awatar
Odrzuć

while you create the tree view or form view you have to pass the attribute delete

like <tree delete="0"> and <form delete="0">

Najlepsza odpowiedź

I did it with overriding the unlink method for the res_partner. I added an if that checks if the user has group for root the it allows to delete the record, else it raises a validation error.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
1
maj 25
708
1
mar 25
917
MERGING CONTACTS Rozwiązane
1
lut 25
1249
2
lut 25
1464
2
lut 25
1545