You are on page 1of 2

How to add approval workflow for openerp 7

Here shows my model class which i need to add approval work flow.

class bpl_work_update(osv.osv):
_name = ""
_description = "BPL Work Update"
_columns = {
'bpl_company_id':fields.many2one('', 'Company',
'ref_no': fields.char('Reference No', size=10,),
'offered_date':'Offered Date'),
# below lines are related to work update approve Workflow (i refer
hr.holidays model for )
'state': fields.selection([('draft', 'To Submit'), ('cancel',
'Cancelled'), ('confirm', 'To Approve'), ('refuse', 'Refused'),
('validate1', 'Second Approval'), ('validate', 'Approved')],
'Status', readonly=True, track_visibility='onchange'),
'user_id': fields.many2one('hr.employee', 'Add records',
invisible=False, readonly=True),
'manager_id': fields.many2one('hr.employee', 'First Approval',
invisible=False, readonly=True),

_defaults = {
'state': 'draft',
'user_id': lambda obj, cr, uid, context: uid,

Here shows my view.xml file (i got only lines here which are related to work flow handling )

<button string="Approve" name="validate" states="confirm"
type="workflow" groups="group_checkroll_user" class="oe_highlight"
<button string="Validate" name="second_validate" states="validate1"
type="workflow" groups="group_checkroll_manager"
class="oe_highlight" />
<button string="Refuse" name="refuse"
type="workflow" groups="group_checkroll_manager" />
<button string="Reset to New" name="set_to_draft"
type="object" groups="group_checkroll_manager" />
<field name="state" widget="statusbar"
statusbar_colors='{"confirm":"blue","validate1":"blue","refuse":"red"}' />
i have no idea for how to implement this approval type work flow. i refer hr.holidays model class
but unable to got clear idea about it. please help me to add level to approve my work order
request. & please give me a link to refer regarding this type of work flow creating..

now that workflow buttons added to form and shows correctly.but how to handle those.? here is

1 Answer
You can refer this link :
You need to create a new workflow.xml file where you need to define first Workflow for which object you are
creating, Different Activities that you want to show in that workflow and Different Transitions between
Activities. First you refer above link, understand it and after go for developing it.

You did right thing by assigning type="workflow" in button. Here, name of button is working as a signal in
transition. It means that If your flow will get the signal, It will go for checking it in transition and from
transition, it will trigger the function of that activity for which, transition is created.