[FIX] purchase: workflow of PO wasn't correctly updated
bzr revid: qdp-launchpad@openerp.com-20130904150137-og2bu4ineae2o2ax
This commit is contained in:
parent
cd64a655d7
commit
7fe0d4f840
|
@ -745,30 +745,26 @@ class purchase_order(osv.osv):
|
|||
return [picking_id]
|
||||
|
||||
def test_moves_done(self, cr, uid, ids, context=None):
|
||||
done = True
|
||||
'''PO is done at the delivery side if all the incoming shipments are done'''
|
||||
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
|
||||
|
||||
for picking in purchase.picking_ids:
|
||||
if picking.state != 'done':
|
||||
return False
|
||||
return True
|
||||
|
||||
def test_moves_except(self, cr, uid, ids, context=None):
|
||||
''' PO is in exception at the delivery side if one of the picking is canceled
|
||||
and the other pickings are completed (done or canceled)
|
||||
'''
|
||||
If one of the pickings is cancel and the other pickings are done: except
|
||||
'''
|
||||
cancel = False
|
||||
at_least_one_canceled = 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
|
||||
|
||||
for picking in purchase.picking_ids:
|
||||
if picking.state == 'cancel':
|
||||
at_least_one_canceled = True
|
||||
if picking.state not in ['done', 'cancel']:
|
||||
alldoneorcancel = False
|
||||
return at_least_one_canceled and alldoneorcancel
|
||||
|
||||
def move_lines_get(self, cr, uid, ids, *args):
|
||||
res = []
|
||||
|
@ -777,7 +773,6 @@ class purchase_order(osv.osv):
|
|||
res += [x.id for x in line.move_ids]
|
||||
return res
|
||||
|
||||
|
||||
def action_picking_create(self, cr, uid, ids, context=None):
|
||||
picking_ids = []
|
||||
for order in self.browse(cr, uid, ids):
|
||||
|
|
|
@ -186,13 +186,13 @@
|
|||
<field name="act_to" ref="act_cancel"/>
|
||||
<field name="signal">purchase_cancel</field>
|
||||
</record>
|
||||
<!--<record id="trans_picking_except_picking" model="workflow.transition">
|
||||
<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="trigger_model">stock.move</field>
|
||||
<field name="trigger_expr_id">move_lines_get()</field>
|
||||
<field name="condition">test_moves_except()</field>
|
||||
</record>-->
|
||||
</record>
|
||||
<record id="trans_invoice_except_invoice" model="workflow.transition">
|
||||
<field name="act_from" ref="act_invoice"/>
|
||||
<field name="act_to" ref="act_except_invoice"/>
|
||||
|
|
|
@ -29,8 +29,10 @@ class stock_move(osv.osv):
|
|||
readonly=True),
|
||||
}
|
||||
|
||||
def action_done(self, cr ,uid, ids, context=None):
|
||||
res = super(stock_move, self).action_done(cr, uid, ids, context)
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
res = super(stock_move, self).write(cr, uid, ids, vals, context=context)
|
||||
wf_service = netsvc.LocalService('workflow')
|
||||
for id in ids:
|
||||
wf_service.trg_trigger(uid, 'stock.move', id, cr)
|
||||
|
|
|
@ -2397,11 +2397,10 @@ class stock_picking_type(osv.osv):
|
|||
res = []
|
||||
if not ids:
|
||||
return res
|
||||
reads = self.browse(cr, uid, ids, context=context)
|
||||
for record in reads:
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
name = record.name
|
||||
if record.warehouse_id:
|
||||
name = record.warehouse_id.name+': '+name
|
||||
name = record.warehouse_id.name + ': ' +name
|
||||
res.append((record.id, name))
|
||||
return res
|
||||
|
||||
|
|
Loading…
Reference in New Issue