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

Hello!

Im in the need to block the button of creation in the view of quantity on hand for all the users except one custom group that i have created named " *Mod Quants ", so the users of inventory cant create records of quants.

I try to eliminate the permission of "quant" from the group, but doing this, they cant access to the products...

This is in ODOO.SH - ODOO15


Thanks for the help :)

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
class StockQuant(models.Model):
    _inherit = 'stock.quant'

    @api.model
    def create(self, vals):
        # Check if the current user belongs to 'Mod Quants'
        user = self.env.user
        groupA = self.env.ref('your_module_name.group_name')  # Replace with the actual group reference
        if user and groupA and groupA in user.groups_id:
            return super(StockQuant, self).create(vals)
        else:
            # Raise an exception or handle the restriction as needed
            raise AccessError("You don't have permission to create stock.quant records.")


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 2 22
3454
0
thg 8 17
4555
2
thg 12 24
8045
0
thg 4 19
5659
1
thg 6 25
1872