[WIP] Change purchase workflow not to use picking subworkflow
bzr revid: jco@openerp.com-20130718085756-bk3g3fdzgm2bce9p
This commit is contained in:
parent
2ee6217474
commit
bb6b684688
|
@ -692,9 +692,33 @@ class purchase_order(osv.osv):
|
|||
todo_moves.append(move)
|
||||
stock_move.action_confirm(cr, uid, todo_moves)
|
||||
stock_move.force_assign(cr, uid, todo_moves)
|
||||
stock_picking.signal_button_confirm(cr, uid, [picking_id])
|
||||
return [picking_id]
|
||||
|
||||
def test_moves_done(self, cr, uid, ids, context=None):
|
||||
done = True
|
||||
for purchase in self.browse(cr, uid, ids, context=context):
|
||||
for line in purchase.order_line:
|
||||
for move in line.move_ids:
|
||||
if move.state != 'done':
|
||||
done = False
|
||||
return done
|
||||
|
||||
|
||||
def test_moves_except(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
If one of the pickings is cancel and the other pickings are done: except
|
||||
'''
|
||||
cancel = False
|
||||
alldoneorcancel = True
|
||||
for purchase in self.browse(cr, uid, ids, context=context):
|
||||
for line in purchase.order_line:
|
||||
for move in line.move_ids:
|
||||
if move.state == 'cancel':
|
||||
cancel = True
|
||||
if move.state not in ['done', 'cancel']:
|
||||
alldoneorcancel = False
|
||||
return cancel and alldoneorcancel
|
||||
|
||||
def action_picking_create(self, cr, uid, ids, context=None):
|
||||
picking_ids = []
|
||||
for order in self.browse(cr, uid, ids):
|
||||
|
|
|
@ -73,8 +73,7 @@
|
|||
<record id="act_picking" model="workflow.activity">
|
||||
<field name="wkf_id" ref="purchase_order"/>
|
||||
<field name="name">picking</field>
|
||||
<field name="kind">subflow</field>
|
||||
<field name="subflow_id" search="[('osv','=','stock.picking')]"/>
|
||||
<field name="kind">function</field>
|
||||
<field name="action">action_picking_create()</field>
|
||||
</record>
|
||||
<record id="act_picking_done" model="workflow.activity">
|
||||
|
@ -172,7 +171,7 @@
|
|||
<record id="trans_picking_except_picking" model="workflow.transition">
|
||||
<field name="act_from" ref="act_picking"/>
|
||||
<field name="act_to" ref="act_except_picking"/>
|
||||
<field name="signal">subflow.cancel</field>
|
||||
<field name="condition">test_moves_except()</field>
|
||||
</record>
|
||||
<record id="trans_invoice_except_invoice" model="workflow.transition">
|
||||
<field name="act_from" ref="act_invoice"/>
|
||||
|
@ -182,7 +181,7 @@
|
|||
<record id="trans_picking_picking_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_picking"/>
|
||||
<field name="act_to" ref="act_picking_done"/>
|
||||
<field name="signal">subflow.done</field>
|
||||
<field name="condition">test_moves_done()</field>
|
||||
</record>
|
||||
<record id="trans_invoice_invoice_done" model="workflow.transition">
|
||||
<field name="act_from" ref="act_invoice"/>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.osv import fields, osv
|
||||
|
||||
from openerp import netsvc
|
||||
class stock_move(osv.osv):
|
||||
_inherit = 'stock.move'
|
||||
_columns = {
|
||||
|
@ -30,6 +30,21 @@ class stock_move(osv.osv):
|
|||
}
|
||||
|
||||
|
||||
|
||||
def action_done(self, cr, uid, ids, context=None):
|
||||
'''
|
||||
THIS SHOULD BE REPLACED BY SOMETHING THAT WILL TRIGGER AUTOMATICALLY
|
||||
DOES NOT WORK ANYWAYS
|
||||
'''
|
||||
res = super(stock_move, self).action_done(cr, uid, ids, context=context)
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
for move in self.browse(cr, uid, ids, context=context):
|
||||
if move.purchase_line_id:
|
||||
wf_service.trg_trigger(uid, 'purchase.order', move.purchase_line_id.order_id.id, cr)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Inherit of picking to add the link to the PO
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue