Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
997 Widoki

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.

Awatar
Odrzuć
Najlepsza odpowiedź

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"
Awatar
Odrzuć
Autor

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

Autor

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

Powiązane posty Odpowiedzi Widoki Czynność
3
maj 25
993
1
kwi 25
853
3
wrz 24
13184
1
maj 24
1391
2
lut 24
1968