Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

how to refer to actual user in a transition condition

By
CyberCIA
on 5/12/13, 11:24 PM 902 views

how to refer to actual user in a transition condition.

For example:

In the flow hr.wkf.holidays we have a transition from the confirm state to the first_validate where the condition is double_validation and the required group is HHRR/Director, which is fine.

But we need to state that the approver should actually be the director of the requesting employee and not a general director.

So we wanted to change the condition this way: double validation and (employee_id.parent_id.user_id == user.id) i.e. that the one who will liberate is the director of the requesting employee, but I got the error that the "user" object is not known.

So the question is how to refer to the actual user in a condition?

0

Marc Cassuto

--Marc Cassuto--
815
| 4 4 8
Montreal, Canada
--Marc Cassuto--


Marc Cassuto
On 8/7/13, 2:51 PM

Hello,

the only way to do it is to add a function to validate your transition in the workflow.

In your case, the function should be something like :

def is_officer_director(self, cr, uid, ids, *args):
        for leave in self.browse(cr, uid, ids):
            if uid==leave.employee_id.parent_id.user_id.id:
                return True
            else:
                return False

You can find a step-by-step procedure in the question #27239 "Prevent HR Managers from approving their own leave requests".

Marc.

PS: please vote if you find it helpful.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 5/12/13, 11:24 PM
Seen: 902 times
Last updated: 3/16/15, 8:10 AM