コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
896 ビュー

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

関連投稿 返信 ビュー 活動
3
5月 25
833
1
4月 25
719
3
9月 24
12851
1
5月 24
1289
2
2月 24
1828