修改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><!-- Activity --> <record id="act_draft" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_start">True</field> <field name="name">draft</field> </record> <record id="act_router" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">router</field> <field name="kind">function</field> <field name="action">write({'state':'cus_confirmed'})</field> </record> <record id="act_assign" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">assigned</field> <field name="kind">function</field> <field name="action">write({'state':'assigned'})</field> </record> <record id="act_bmapprove" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">bm_approve</field> <field name="kind">function</field> <field name="action">write({'state':'bm_approved'})</field> </record> <record id="act_bmrefuse" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_stop">True</field> <field name="name">bm_refuse</field> <field name="kind">function</field> <field name="action">write({'state':'bm_refused'})</field> </record> <record id="act_gmapprove" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">gm_approve</field> <field name="kind">function</field> <field name="action">write({'state':'gm_approved'})</field> </record> <record id="act_gmrefuse" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="flow_stop">True</field> <field name="name">gm_refuse</field> <field name="kind">function</field> <field name="action">write({'state':'gm_refused'})</field> </record> <record id="act_done" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">done</field> <field name="flow_stop">True</field> <field name="kind">function</field> <field name="action">write({'state':'done'})</field> <field name="join_mode">AND</field> </record> <record id="act_cancel" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <record id="act_cancel2" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel2</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <record id="act_cancel3" model="workflow.activity"> <field name="wkf_id" ref="wkf_sale"/> <field name="name">cancel3</field> <field name="flow_stop">True</field> <field name="kind">stopall</field> <field name="action">action_cancel()</field> </record> <!-- Transistion --> <record id="trans_draft_router" model="workflow.transition"> <field name="act_from" ref="act_draft"/> <field name="act_to" ref="act_router"/> <field name="signal">order_confirm</field> </record> <record id="trans_draft_cancel" model="workflow.transition"> <field name="act_from" ref="act_draft"/> <field name="act_to" ref="act_cancel"/> <field name="signal">cancel</field> </record> <record id="trans_rounter_assgin" model="workflow.transition">
<field name="act_from" ref="act_router"/>
<field name="act_to" ref="act_assign"/>
<field name="signal">assign</field>
</record><record id="trans_assign_bmapprove" model="workflow.transition">
<field name="act_from" ref="act_assign"/>
<field name="act_to" ref="act_bmapprove"/>
<field name="signal">bm_approve</field>
</record><record id="trans_bmapprove_gmapprove" model="workflow.transition">
<field name="act_from" ref="act_bmapprove"/>
<field name="act_to" ref="act_gmapprove"/>
<field name="signal">gm_approve</field>
</record><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><record id="trans_gmapprove_router" model="workflow.transition">
<field name="act_from" ref="act_gmapprove"/>
<field name="act_to" ref="act_router"/>
<field name="signal">gm_refuse</field>
</record><record id="trans_gmapprove_gmrefuse" model="workflow.transition">
<field name="act_from" ref="act_gmapprove"/>
<field name="act_to" ref="act_gmrefuse"/>
<field name="signal">gm_refuse</field>
</record></data>
</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"/><button name="assign" states="cus_confirmed" string="Assign"/> <button name="bm_approve" states="assigned" string="BM Approve"/> <button name="bm_refuse" states="assigned" string="BM Refuse"/> <button name="gm_approve" states="bm_approved" string="GM Approve"/> <button name="gm_refuse" states="bm_approved" string="GM Refuse"/>
</group>
详细文件
[attach]460[/attach]