Skip to Content
Menu
This question has been flagged
1 Reply
854 Views

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.

Avatar
Discard
Best Answer

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"
Avatar
Discard
Author

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).

Author

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 Replies Views Activity
3
May 25
789
1
Apr 25
670
3
Sep 24
12721
1
May 24
1247
2
Feb 24
1782