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

For example. 

The amount in expense cannot be edited by internal.user.group if the status is in approved. But can still be edited by manager.group even it is in approved status.


What's happening in odoo right now is, if i tick the read-only and set a condition, "is in approved", even the administrators is affected.

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

You can achieve it by making add 2 view field with different condition and group

  1. the first view field is for the group non administrator and editable when the state is not approved
  2. the second view field is for the group administrator and always editable

here the example

field name="total_amount_currency" widget="monetary" readonly="state in ['approved', 'done']" groups="!base.group_erp_manager"

field name="total_amount_currency" widget="monetary" groups="base.group_erp_manager"
อวตาร
ละทิ้ง
ผู้เขียน

I tried to follow your suggestion.

What i did:
I created 2 views and inherited the hr.expense.view.form.

I inserted this code in non-admin group
<data>
<xpath expr="//field[@name='total_amount_currency']" position="attributes">
<attribute name="groups">!base.group_erp_manager</attribute>
<attribute name="readonly">state in ["approved", "done", "submitted"]</attribute>
</xpath>
</data>

and this for admin group,

<data>
<xpath expr="//field[@name='total_amount_currency']" position="attributes">
<attribute name="groups">base.group_erp_manager</attribute>
</xpath>
</data>

Just like what you said. But, what only happens. The total_amount_currency field became invisible to admin group. But it really read-only in non-admin group.

hmm, i mean you can adding 2 field, not replacing the attribute. if you do replace the attribute, it will only exist 1 fields (thats not what i expected).

ผู้เขียน

Oh. You really literally mean 2 fields. Well that's not what i actually want..

i think we got miscom,
i mean 1 field from model, but you defined it into 2 field view in xml

Related Posts ตอบกลับ มุมมอง กิจกรรม
3
พ.ค. 25
1589
1
เม.ย. 25
1195
one2one relational field แก้ไขแล้ว
3
ก.ย. 24
14041
1
พ.ค. 24
1637
2
ก.พ. 24
2387