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

Workflows status bar doesn't show colors and states

By
Shabeeh Kazmi
on 5/16/14, 11:08 AM 1,710 views

Hi folks

i'm working on OpenERP workflows. All flows are working fine except status bar widget doesnt show states and doesnt reflect colors that i have writen in view. Can anyone help me out please?

<!---- My class-->

class workflow_example2(osv.osv):
    def mymod_new(self, cr, uid, ids):
        self.write(cr, uid, ids, { 'state' : 'new' })
        return True

    def mymod_assigned(self, cr, uid, ids):
        self.write(cr, uid, ids, { 'state' : 'assigned' })
        return True
    
    def mymod_negotiation(self, cr, uid, ids):
        self.write(cr, uid, ids, { 'state' : 'negotiation' })
        return True
    
    def mymod_won(self, cr, uid, ids):
        self.write(cr, uid, ids, { 'state' : 'won' })
        return True
    
    def mymod_lost(self, cr, uid, ids):
        self.write(cr, uid, ids, { 'state' : 'lost' })
        return True

    _name = 'workflow.example2'
    _columns = {
        'abc':fields.char('abc', size=20),
       'state': fields.selection([
        ('new','New'),
        ('assigned','Assigned'),
        ('negotiation','Negotiation'),
        ('won','Won'),
        ('lost','Lost')], 'Stage', readonly=True, track_visibility='onchange'),
        'field_1': fields.char('Field_1', size=20),
        'field_2': fields.char('Field_2', size=16),        
    }
   
workflow_example2()


<!Workflow xlm>

<?xml version="1.0" encoding="utf-8"?>
<openerp>
    <data>
        <record model="workflow" id="wkf_mymod2">
            <field name="name">workflow.wkf</field>
            <field name="osv">workflow.example2</field>
            <field name="on_create">True</field>
        </record>
        
        <record model="workflow.activity" id="act_new">
            <field name="wkf_id" ref="wkf_mymod2" />
            <field name="flow_start">True</field>
            <field name="name">new</field>
            <field name="kind">function</field>
            <field name="action">mymod_new()</field>
        </record>

        <record model="workflow.activity" id="act_assigned">
            <field name="wkf_id" ref="wkf_mymod2" />
            <field name="name">assigned</field>
            <field name="kind">function</field>
            <field name="action">mymod_assigned()</field>
        </record>

        <record model="workflow.activity" id="act_negotiation">
            <field name="wkf_id" ref="wkf_mymod2" />
            <field name="name">negotiation</field>
            <field name="kind">function</field>
            <field name="action">mymod_negotiation()</field>
        </record>

        <record model="workflow.activity" id="act_won">
            <field name="wkf_id" ref="wkf_mymod2" />
            <field name="name">won</field>
            <field name="kind">function</field>
            <field name="action">mymod_won()</field>    
            <field name="flow_stop">True</field>            
        </record>

        <record model="workflow.activity" id="act_lost">
            <field name="wkf_id" ref="wkf_mymod2" />
            <field name="name">lost</field>
            <field name="kind">function</field>
            <field name="action">mymod_lost()</field>
            <field name="flow_stop">True</field>
        </record>
                
        <record model="workflow.transition" id="t1">
            <field name="act_from" ref="act_new" />
            <field name="act_to" ref="act_assigned" />
            <field name="signal">mymod_assigned</field>
        </record>

        <record model="workflow.transition" id="t2">
            <field name="act_from" ref="act_assigned" />
            <field name="act_to" ref="act_negotiation" />
            <field name="signal">mymod_negotiation</field>
        </record>

        <record model="workflow.transition" id="t3">
            <field name="act_from" ref="act_negotiation" />
            <field name="act_to" ref="act_won" />
            <field name="signal">mymod_won</field>
        </record>

        <record model="workflow.transition" id="t4">
            <field name="act_from" ref="act_negotiation" />
            <field name="act_to" ref="act_lost" />
            <field name="signal">mymod_lost</field>
        </record>
        
    </data>
</openerp>

 

<!View>
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
    <data>
        <record id="view_wf_example_form2" model="ir.ui.view">
            <field name="name">workflow.example.form</field>
            <field name="model">workflow.example2</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
                <form string="Workflow Example" version="7.0">
                <header>
                        <button name="mymod_assigned" string="New" class="oe_highlight oe_view_mode_only"  states="new" />
                        <button name="mymod_negotiation" string="In negotiation" class="oe_highlight oe_view_mode_only"  states="assigned" />
                        <button name="mymod_won" string="won" states="negotiation" class="oe_highlight oe_view_mode_only"  />
                        <button name="mymod_lost" string="lost" states="negotiation" class="oe_highlight oe_view_mode_only"  />
                        <label string="Draft Invoice" attrs="{'invisible': ['|',('status','&lt;&gt;','new')]}"/>                        
                        <field name="status" widget="statusbar" statusbar_visible="new,assigned,negotiation" statusbar_colors='{"new":"blue","assigned":"blue"}'/>
                        <field name="status" invisible="1"/>                        
                </header>
                <sheet string ="Workflow">
                    <group col="2" colspan="0">    
                        <field name="field_1"/>
                        <field name="field_2"/>                        
                    </group>                   
                </sheet>
                <div class="oe_chatter">
                    <div>
                        <H2>
                        <label string="History and Comments"/>                
                        </H2>
                    </div>
                </div>
                </form>
            </field>
        </record>
        
        <record id="view_wf_example_tree" model="ir.ui.view">
            <field name="name">workflow.example.tree</field>
            <field name="model">workflow.example2</field>
            <field name="type">tree</field>
            <field name="arch" type="xml">
                <tree string="Workflow Example">
                        <field name="field_1"/>
                </tree>
            </field>
        </record>
        
        <!-- ACTIONS -->
        <record id="act_wf_form" model="ir.actions.act_window">
            <field name="name">Form workflow</field>
            <field name="type">ir.actions.act_window</field>
            <field name="res_model">workflow.example2</field>
            <field name="view_type">form</field>
            <field name="view_mode">form,tree</field>
            <field name="view_id" ref="view_wf_example_form2"/>
        </record>
        <!--  MENUITEM -->
        <menuitem name="workflow" action="act_wf_form" id="menu_wf_form" sequence="1" />
        
    </data>
</openerp>

 

regards
polaris.

 

1
dirk
On 7/9/14, 7:00 AM

Your field name must be state and not status in:

<field name="status" widget="statusbar" statusbar_visible="new,assigned,negotiation" statusbar_colors='{"new":"blue","assigned":"blue"}'/>
                        <field name="status" invisible="1"/>   

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/16/14, 11:08 AM
Seen: 1710 times
Last updated: 3/16/15, 8:10 AM