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

I noticed that it is used in `hr.employee.public`:

```

image_128 = fields.Image("Image 128", compute='_compute_image', compute_sudo=True)


def _compute_image(self):

    for employee in self:

    employee_id = self.sudo().env['hr.employee'].browse(employee.id)

    ...

```
in the compute method sudo() is used anyways, which implies that compute_sudo doesn't change the self in the compute method to be equivalent to self.sudo();


Then what is the point in adding `compute_sudo`?

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Compute sudo is described in the docs as  "whether the field should be recomputed as superuser to bypass access rights (by default True for stored fields, False for non stored fields)"

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

but what does it mean? the user in the method is not the superuser unless sudo() is explicitly used.

As sudo bypasses access rights ,in compute_sudo compute field while computing itself again it will not look for the users access rights and compute it as its for superuser.

Bài viết liên quan Trả lời Lượt xem Hoạt động
compute issue Đã xử lý
1
thg 5 21
3755
2
thg 5 25
879
2
thg 8 22
5287
2
thg 7 22
7046
1
thg 12 20
37815