工作流状态栏不显示颜色和状态

时间:2014-05-19 10:55:20

标签: python-2.7 openerp

我正在研究OpenERP工作流程。所有流程都正常工作,除了状态栏小部件不显示状态并且不反映我在视图中写入的颜色。有人可以帮帮我吗?

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>

example_view.xml

<?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>

问候 阿里汗

1 个答案:

答案 0 :(得分:4)

当您使用OpenERP 7(现在是Odoo)时,webclient中没有可自定义的状态栏颜色(活动状态始终为蓝色)。另外,您已在表单视图中两次定义字段“status”,这意味着实际值将位于第二个字段中,并且第一个定义的字段将为空。除了视图中的嵌入视图外,不要在表单视图中定义两次字段。