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

I'm trying to port form odoo 13 to 16. I have two fields: A, B

In my form view, A has attribute: "attrs ({'readonly': [('report_done', '=', True)]})"

And B is restricted to groups="account.group_account_manager"


When I install the module, it keeps saying this:

Error while validating view near: 

Field 'B' used in attrs ({'readonly': [('B', '=', True)]}) is restricted to the group(s) account.group_account_manager.



Is there something wrong in Odoo16?

Or am I missing something else?  

อวตาร
ละทิ้ง

Don't have enough karma to upvote the answer. The solution in my case was to add the field set as invisible (it already was on the form but was only accesible to the specific user group). 

คำตอบที่ดีที่สุด
def _compute_my_field_readonly(self):
return not (
self.user.has_group("my_module.group_1")
or self.user.has_group("my_module.group_2")
)

my_field = fields.Float(
readonly=_compute_my_field_readonly,
)
อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi @dimitry

Hope you are doing well.

Here in odoo 16 what happens is that in the field 'B' you have given the group and when you are trying to use this field in another field as an attribute "Field 'B' used in attrs ({'readonly': [('B', '=', True)]})" it is getting restricted due to the applied group. 

Hence you can either move the group from the field or add the same field where its is being used as attribute as invisible.


I hope it will help you.

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari

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

Hi,

Create a group and add the attribute to the field that you want to make as read only as below.

<field name="example_field" attrs="{'readonly': [('groups', 'in', [example_group])]}"/>


Regards

อวตาร
ละทิ้ง

I tried this solution but it gave me this error:
Field 'groups' used in attrs ({'readonly': [('groups', 'in', [example_group])]}) must be present in view but is missing.

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ก.ย. 15
4298
1
เม.ย. 23
227
1
พ.ค. 23
4024
readonly option in fields? แก้ไขแล้ว
3
ธ.ค. 23
91071
3
ก.ย. 21
5143