Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
8 Trả lời
4867 Lượt xem

I created an automated action as such:

Name: Prevent duplicate vendor based on name

Model: Contact 
Trigger: On Creation & Update
Trigger Fields: Before Update

Domain: Match all records

Apply on: Match all records

Action To Do: Execute Python Code

Code:

exists = env['res.partner'].search([('name','=',record.name),('id','!=',record.id)])

if exists:

  raise UserError('Vendor "' + record.name + '" is already in Odoo!')



When I try to create a new PO as an admin, it works. However, when I try this as a user (user permission on purchase module), it provides me with the following error:

Access Error:
You are not allowed to access 'Automated Action' (base.automation) records. This operation is allowed for the following groups: - Administration/Settings Contact your administrator to request access if necessary.

What can I do? I need the automated action and also I need my regular user to be able to create a PO.

Thanks.
Ảnh đại diện
Huỷ bỏ

Which version of Odoo?

Tác giả

@Chris, v14

OK, it's a bug in Odoo 14 - I added an answer.

Câu trả lời hay nhất

Hello Tushar
You can use python constrains to not allow anyone to create duplicate vendor
You can use following code to add constrains in res.partner object.

@api.constrains('name')
    def check_name(self):
        partners_name = self.search([]).mapped("name")
        check_name = list(filter(lambda all_partner:all_partner.lower() == self.name.lower(),partners_name))
        if len(check_name) > 1:
            raise UserError("You Can not create vendor with same name")

Ảnh đại diện
Huỷ bỏ
Tác giả

Husain, thanks you. I still wonder if there is a way to do it without changing or extending the source code.

Hello Tushar

If you don't wants to change your existing code then follow below steps.

Go to setting ---> Groups --> purchase/ user groups and give access rights to user for automates action.

Go to access right tab and add new access right for purchase user group select model automated action and given read,write,update and delete permission.

Then user will not get error while creating PO

Thanks

Tác giả

Hi Husain, thank you very much, this worked!

Câu trả lời hay nhất

Seems that this is a bug in Odoo 14 and there's a fix.  



Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 10 21
2344
0
thg 4 24
1420
1
thg 2 22
2964
1
thg 5 21
3390
1
thg 7 25
1942