Se rendre au contenu
Menu
Cette question a été signalée
1 Répondre
1262 Vues

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
Ignorer
Meilleure réponse

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
Ignorer
Auteur

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

Auteur

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

Publications associées Réponses Vues Activité
3
mai 25
1594
1
avr. 25
1209
3
sept. 24
14051
1
mai 24
1646
2
févr. 24
2389