Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
2 ตอบกลับ
4965 มุมมอง

One way to limit users from accessing cost prices is to simply hide the fields by limiting visibility to specific groups. But this does not take away the possibility to export the field from a list view. How do we still allow the user to export the other fields from the view without the restricted field?

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi  Toon van der Ploeg ,

Try,

@api.model
def fields_get(self, fields=None):
fields_to_hide = ['field1','field2'] //Fields to Hide
res = super(ClassName, self).fields_get()
for field in fields_to_hide:
if self.env.user.has_group('group_which_the_field_to_be_hide'): 
res[field]['exportable'] = False
return res

Hope It Helps,
Kiran K

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

In .py file you can add the groups to a specific field so that it will not be visible while exporting also.

                                                    groups="base.group_no_one"

Adding this will make the field accessible only to "base.group_no_one" group users.

อวตาร
ละทิ้ง

Hi K Ch Kumar Jagabattula, thanks for your suggestion. Do you mean updating the 'odoo/addons/product/models/product.py' file or is there are more appropriate way to inherit it and update the groups?

Hi Anthony Nelson, Updating the default modules is not a good practice. Inherit the model in a custom addon and add groups for the field.

Something like this should work.

class ProductTemplate(models.Model):
_inherit = "product.template"
field_name = fields.Float(default_content, groups="base.group_user)

default_content - entire code in field definition of default addon.

Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ธ.ค. 22
6421
Export data depends on Group users แก้ไขแล้ว
1
ต.ค. 22
2673
1
พ.ค. 22
2985
1
ก.พ. 22
3202
Export/Import product images แก้ไขแล้ว
2
ก.พ. 25
11126