Help on definig Group Rules

Hey guys, i hope everything is all right with you.

I am struggling to define a group rule for the commission module. I’m probably missing something, so any help is much appreciated.

So I am trying to define a trivial group rule where each logged company employee user can only see his/her invoice commissions. I have read about this on other topics in here, but nothing worked so far. The list of commissions is always empty. I’m defining the rule in the group rule tab with the following PYSON statement:
[['party', '=', Get(Eval('user', {}), 'employee', None)]], referring to the Commission Agent model.

With this I thought that Tryton ERP would only list commission records in which the party agent is equal to the logged in company employee user.

Any thoughts?

Thank you for all your help

There’s an example in purchase_requisition:

https://hg.tryton.org/modules/purchase_requisition/file/default/purchase.xml#l288

Maybe you should try this:

[['party', 'in', Get(Eval('user', {}), 'employees', None)]]

hey @maxx, thanks for your suggestion.

However, it did not work. It still listing no records. Is there any difference between defining the group rule by xml files or with the group rule tab?

You are comparing Party records with Employee records which are not the same.
Also the Commission model has no party field, only an agent.

Yeah, because I want Tryton to list the commission records according to the commission agent, identified by a party, whenever the commission agent is equal to the company employee user currently logged in.

Yeah, but the definition is made on the Commission Agent model, not in the Commission model. It seems more reasonable for me to define the restriction on the commission agent model, because the user can check for the commissions from the commission agent model with the relate window.

But it can not and will never work to compare ids of different models.
You must compare ids of the same models.

So it will filter only the commission agent. The rule applies only on what it is defined.

You must define access right on all the models on which you want them to be applied.

Can you elaborate on this?

Yeah I can understand what you mean. What I am struggling with is on how should I filter only the commissions related to the logged in company user?

Rules apply only directly to the Model for which they are written.

I think you can not write such rule out-of-the-box. You need to have an agent or a list of agents defined on the user. So you can write rules like: [('agent', '=', Eval('user', {}).get('agent'))]

Hummm ok. I got it. I’ll try it out

Thank you so much for your help :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.