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

Is there a way to define a specific field as readonly on products and customers? I.e. a payment method is created for a customer and only those with access to change this field should be able to change the field. All other fields on the customer like address are writable by regular users.

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

Hi Sean Samborski,

You can write the fields as below:

'approved': fields.boolean('Approved', write=['base.group_sale_manager']),

And in xml as normal fields without any readonly or groups.

<field name="approved"/>

This won't be readonly field. But it is writable only to the users having sale manager access rights.

If you don't want to show this field to the users having no access rights, better write as normal fields and assign groups in xml file.

อวตาร
ละทิ้ง
ผู้เขียน

+1 this sounds really great. Where would I put the first snippet you added?

Inherit the model product and customer, add the above field in py file.

คำตอบที่ดีที่สุด

You Can Specify Group in xml for that particular field.

<field name="date"  readonly="1" groups="base.group_user"/>

where group_user is the name of the group and base is the module in which group is defined. Then

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
2
มี.ค. 15
5715
0
ม.ค. 23
1327
How to create a read only user / group แก้ไขแล้ว
3
มี.ค. 22
17495
1
มี.ค. 15
6241
4
มิ.ย. 24
3111