Odoo中文社区可以通过以下两个域名访问:shine-it.net , odoo.net.cn

由于系统升迁的原因,本论坛部分较早期的内容存在格式和链接损坏失效的问题,并非本论坛系统本身的缺陷,望谅解

本社区没有维护任何QQ群讨论组,任何与本社区同名的QQ群讨论组的言论与本社区无关!

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

修改sale.order.basic的workflow后,approve可以,但refuse无效,不知道为什么



  • 重新设置了workflow sale.order.basic,draft->customer confrim -> assign -> bm approve -> gm approve 流程正常。可是在BM refuse与GM refuse的时候workflow就无效了,不能refuse。哪位有时间帮忙看下,问题出在哪边?

    sale_workflow.xml文件内容如下
    <?xml version="1.0" encoding="utf-8"?>
    <openerp>
    <data>
    <record id="wkf_sale" model="workflow">
    <field name="name">sale.order.basic</field>
    <field name="osv">sale.order</field>
    <field name="on_create">True</field>
    </record>

        &lt;!-- Activity --&gt;
        &lt;record id="act_draft" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="flow_start"&gt;True&lt;/field&gt;
            &lt;field name="name"&gt;draft&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_router" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;router&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'cus_confirmed'})&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_assign" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;assigned&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'assigned'})&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_bmapprove" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;bm_approve&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'bm_approved'})&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_bmrefuse" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="name"&gt;bm_refuse&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'bm_refused'})&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_gmapprove" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;gm_approve&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'gm_approved'})&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_gmrefuse" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="name"&gt;gm_refuse&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'gm_refused'})&lt;/field&gt;
        &lt;/record&gt;
        
        &lt;record id="act_done" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;done&lt;/field&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="kind"&gt;function&lt;/field&gt;
            &lt;field name="action"&gt;write({'state':'done'})&lt;/field&gt;
            &lt;field name="join_mode"&gt;AND&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_cancel" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;cancel&lt;/field&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="kind"&gt;stopall&lt;/field&gt;
            &lt;field name="action"&gt;action_cancel()&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_cancel2" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;cancel2&lt;/field&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="kind"&gt;stopall&lt;/field&gt;
            &lt;field name="action"&gt;action_cancel()&lt;/field&gt;
        &lt;/record&gt;
        &lt;record id="act_cancel3" model="workflow.activity"&gt;
            &lt;field name="wkf_id" ref="wkf_sale"/&gt;
            &lt;field name="name"&gt;cancel3&lt;/field&gt;
            &lt;field name="flow_stop"&gt;True&lt;/field&gt;
            &lt;field name="kind"&gt;stopall&lt;/field&gt;
            &lt;field name="action"&gt;action_cancel()&lt;/field&gt;
        &lt;/record&gt;
        
        &lt;!-- Transistion --&gt;
        
        &lt;record id="trans_draft_router" model="workflow.transition"&gt;
            &lt;field name="act_from" ref="act_draft"/&gt;
            &lt;field name="act_to" ref="act_router"/&gt;
            &lt;field name="signal"&gt;order_confirm&lt;/field&gt;
        &lt;/record&gt;
        
        &lt;record id="trans_draft_cancel" model="workflow.transition"&gt;
            &lt;field name="act_from" ref="act_draft"/&gt;
            &lt;field name="act_to" ref="act_cancel"/&gt;
            &lt;field name="signal"&gt;cancel&lt;/field&gt;
        &lt;/record&gt;
        
        &lt;record id="trans_rounter_assgin" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_router"/>
    <field name="act_to" ref="act_assign"/>
    <field name="signal">assign</field>
    </record>

        &lt;record id="trans_assign_bmapprove" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_assign"/>
    <field name="act_to" ref="act_bmapprove"/>
    <field name="signal">bm_approve</field>
    </record>

        &lt;record id="trans_bmapprove_gmapprove" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_bmapprove"/>
    <field name="act_to" ref="act_gmapprove"/>
    <field name="signal">gm_approve</field>
    </record>

        &lt;record id="trans_bmapprove_bmrefuse" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_bmapprove"/>
    <field name="act_to" ref="act_bmrefuse"/>
    <field name="signal">bm_refuse</field>
    </record>

        &lt;record id="trans_gmapprove_router" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_gmapprove"/>
    <field name="act_to" ref="act_router"/>
    <field name="signal">gm_refuse</field>
    </record>

        &lt;record id="trans_gmapprove_gmrefuse" model="workflow.transition"&gt;
    

    <field name="act_from" ref="act_gmapprove"/>
    <field name="act_to" ref="act_gmrefuse"/>
    <field name="signal">gm_refuse</field>
    </record>

    &lt;/data&gt;
    

    </openerp>

    sale.py 文件中state字段的field selection如下:
    'state': fields.selection([
    ('draft', 'Quotation'),

            ('cus_confirmed','Customer Confirmed'),
            ('assigned','Assigned'),
            ('bm_approved','BM Approved'),
            ('gm_refused','GM Refused'),
            ('gm_approved','GM Approved'),
            ('done', 'Done'),
            ('cancel', 'Cancelled')
            ], 'Order State', readonly=True, help="Gives the state of the quotation or sale order. The exception state is automatically set when a cancel operation occurs in the invoice validation (Invoice Exception) or in the packing list process (Shipping Exception). The 'Waiting Schedule' state is set when the invoice is confirmed but waiting for the scheduler to run on the date 'Date Ordered'.", select=True),
        'date_order': fields.date('Date Ordered', required=True, readonly=True, states={'draft': [('readonly', False)]}),
    

    sale_view.xml 中button设置为:
    <group col="13" colspan="4">
    <field name="state" select="2"/>
    <button name="order_confirm" states="draft" string="Customer Confirm" icon="gtk-execute"/>
    <button name="cancel" states="draft" string="Cancel Order" icon="gtk-cancel"/>

                                &lt;button name="assign" states="cus_confirmed" string="Assign"/&gt;
                                &lt;button name="bm_approve" states="assigned" string="BM Approve"/&gt;
                                &lt;button name="bm_refuse" states="assigned" string="BM Refuse"/&gt;
                                &lt;button name="gm_approve" states="bm_approved" string="GM Approve"/&gt;
                                &lt;button name="gm_refuse" states="bm_approved" string="GM Refuse"/&gt;
    

    </group>

    详细文件

    [attach]460[/attach]



  • 找到原因了
    <record id="trans_bmapprove_bmrefuse" model="workflow.transition">
    <field name="act_from" ref="act_bmapprove"/>
    <field name="act_to" ref="act_bmrefuse"/>
    <field name="signal">bm_refuse</field>
    </record>
    其中的act_from 应该是assign

    GM refuse也是这个原因


Log in to reply