<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record id="act_debit_denied" model="workflow.activity">
            <field name="wkf_id" ref="account.wkf"/>
            <field name="name">debit_denied</field>
            <field name="action">action_debit_denied()</field>
            <field name="kind">function</field>
        </record>
       <record id="paid_to_debit_denied" model="workflow.transition">
            <!-- 
                 Set an invoice to state debit denied, either manually
                 or by confirming a bank statement line that constitutes
                 a fatal storno
            -->
            <field name="act_from" ref="account.act_paid"/>
            <field name="act_to" ref="act_debit_denied"/>
            <field name="signal">invoice_debit_denied</field>
        </record>
       <record id="open_test_to_debit_denied" model="workflow.transition">
            <!-- 
                 A storno leads to unreconciling the move line, which
                 reopens the invoice. We need to allow a transition from
                 this state to the debit denied state if the storno is fatal.
            -->
            <field name="act_from" ref="account.act_open_test"/>
            <field name="act_to" ref="act_debit_denied"/>
            <field name="signal">invoice_debit_denied</field>
        </record>
       <record id="debit_denied_to_paid" model="workflow.transition">
            <!-- 
                 Cancel a bank statement line that constitutes a fatal
                 storno
            -->
            <field name="act_from" ref="act_debit_denied"/>
            <field name="act_to" ref="account.act_paid"/>
            <field name="condition">test_undo_debit_denied()</field>
            <field name="signal">undo_debit_denied</field>
        </record>
        <record id="debit_denied_to_open" model="workflow.transition">
            <!-- 
                 Allow the user to manually reset a debit denied status
                 on a paid invoice (but only after manually unreconciling
                 the invoice)
            -->
            <field name="act_from" ref="act_debit_denied"/>
            <field name="act_to" ref="account.act_open_test"/>
            <field name="signal">open_test</field>
        </record>
    </data>
</openerp>
