Odoo Help


How to modify hr.wkf.expenses workflow to add new state?

Mariusz Mizgier
on 11/25/13, 8:54 AM 2,757 views

I've made files such as hr_expense_board_confirmation.py:

class hr_expense_expense(osv.osv):

_inherit = ['hr.expense.expense']
_columns = {
    'state': fields.selection([
        ('draft', 'New'),
        ('cancelled', 'Refused'),
        ('confirm', 'Waiting Approval'),
        ('waiting', 'Waiting for Chairman Approval')
        ('accepted', 'Approved'),
        ('done', 'Waiting Payment'),
        ('paid', 'Paid'),
        'Status', readonly=True, track_visibility='onchange',
        help='When the expense request is created the status is \'Draft\'.\n It is confirmed by the user and request is sent to admin, the status is \'Waiting Confirmation\'.\
        \nIf the admin accepts it, the status is \'Accepted\'.\n If the accounting entries are made for the expense request, the status is \'Waiting Payment\'.'),


def expense_waiting(self, cr, uid, ids, context=None):
    return self.write(cr, uid, ids, {'state': 'waiting'}, context=context)


Then hr_expense_board_workflow.xml

    <record id="act_waiting" model="workflow.activity">
        <field name="wkf_id" ref="hr_expense.wkf_expenses"/>
        <field name="name">waiting</field>
        <field name="kind">function</field>
        <field name="action">expense_waiting()</field>

    <record id="t3" model="workflow.transition">
        <field name="act_from" ref="hr_expense.act_accepted"/>
        <field name="act_to" ref="act_waiting"/>
        <field name="signal">waiting</field>
        <field name="group_id" ref="base.group_hr_user"/>

    <record id="t5" model="workflow.transition">
        <field name="act_from" ref="act_waiting"/>
        <field name="act_to" ref="hr_expense.act_refused"/>
        <field name="signal">refuse</field>
        <field name="group_id" ref="base.group_hr_user"/>

    <record id="t11" model="workflow.transition">
        <field name="act_from" ref="act_waiting"/>
        <field name="act_to" ref="hr_expense.act_done"/>
        <field name="signal">done</field>
        <field name="group_id" ref="base.group_hr_user"/>

And finally hr_expense_board_view.xml

        <record model="ir.ui.view" id="hr_board_view">
        <field name="name">hr.expense.expense1</field>
        <field name="model">hr.expense.expense</field>
        <field name="inherit_id" ref="hr_expense.view_expenses_form"/>
        <field name="arch" type="xml">
                <xpath expr="/form/header/button[@name='confirm']" position="replace">
                    <button name="confirm" states="draft" string="Submit to Manager" type="workflow" class="oe_highlight"/>
                <xpath expr="/form/header/button[@name='validate']" position="replace">
                    <button name="validate" states="confirm" string="Approve" type="workflow" groups="base.group_hr_user" class="oe_highlight"/>
                <xpath expr="/form/header/button[@name='refuse']" position="replace">
                    <button name="refuse" states="confirm,accepted, waiting" string="Refuse" type="workflow" groups="base.group_hr_user" />
                <xpath expr="/form/header/button[@name='draft']" position="replace">
                    <button name="draft" states="confirm,cancelled" string="Set to Draft" type="workflow" groups="base.group_hr_user" />
                <xpath expr="/form/header/button[@name='done]" position="replace">
                    <button name="done" states="accepted" string="Generate Accounting Entries" type="workflow" groups="account.group_account_invoice" class="oe_highlight"/>
                <button name="waiting" states="accepted" string="Confirmed by Chairman" type="workflow" groups="base.group_hr_user" class="oe_highlight" />
                <xpath expr="/form/header/field[@name='state']" position="replace">
                    <field name="state" widget="statusbar" statusbar_visible="draft,confirm,waiting,accepted,done,paid,cancelled" statusbar_colors='{"invoice_except":"red","waiting_date":"blue"}'/>   

After trying to push button 'Confirmed by Chairman', I get an error like this:

 File "", line 1, in <module>
 NameError: name 'expense_waiting' is not defined

What is the case? expense_waiting has been defined correctly, I believe. I know that status bar will be shown two times (that is a case I will follow after this bug can be eliminated). Any ideas would be very appreciated.

jon chow
On 8/25/17, 2:45 AM

This app is good job for workflow   https://www.odoo.com/apps/modules/10.0/wkf_powerful/


Mariusz Mizgier

--Mariusz Mizgier--
| 4 1 7
SOPOT, Poland
--Mariusz Mizgier--

OpenERP developer

Mariusz Mizgier
On 11/25/13, 3:14 PM

Seems like _columns is not passed to hr.expense.expense - any idea why is that happening? If _columns are not passed, neither will expense_waiting will, but I have no clue, what is wrong here.

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 11/25/13, 8:54 AM
Seen: 2757 times
Last updated: 8/25/17, 2:45 AM