From d92bb37534385a49b3a11d9763924cc5145c3a52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 27 Dec 2012 21:54:21 +0100 Subject: [PATCH] Use Workflow for Stock Move review600002 --- production.py | 38 +++++++++----------------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/production.py b/production.py index fa1e3a9fc4..1f56673f9e 100644 --- a/production.py +++ b/production.py @@ -490,11 +490,8 @@ class Production(Workflow, ModelSQL, ModelView): def cancel(cls, productions): pool = Pool() Move = pool.get('stock.move') - Move.write([m for p in productions - for m in p.inputs + p.outputs - if m.state != 'cancel'], { - 'state': 'cancel', - }) + Move.cancel([m for p in productions + for m in p.inputs + p.outputs]) @classmethod @ModelView.button @@ -502,11 +499,8 @@ class Production(Workflow, ModelSQL, ModelView): def draft(cls, productions): pool = Pool() Move = pool.get('stock.move') - Move.write([m for p in productions - for m in p.inputs + p.outputs - if m.state != 'draft'], { - 'state': 'draft', - }) + Move.draft([m for p in productions + for m in p.inputs + p.outputs]) @classmethod @ModelView.button @@ -514,11 +508,8 @@ class Production(Workflow, ModelSQL, ModelView): def wait(cls, productions): pool = Pool() Move = pool.get('stock.move') - Move.write([m for p in productions - for m in p.inputs + p.outputs - if m.state not in ('draft', 'done')], { - 'state': 'draft', - }) + Move.draft([m for p in productions + for m in p.inputs + p.outputs]) @classmethod @Workflow.transition('assigned') @@ -531,11 +522,7 @@ class Production(Workflow, ModelSQL, ModelView): def run(cls, productions): pool = Pool() Move = pool.get('stock.move') - Move.write([m for p in productions - for m in p.inputs - if m.state not in ('done', 'cancel')], { - 'state': 'done', - }) + Move.do([m for p in productions for m in p.inputs]) @classmethod @ModelView.button @@ -544,11 +531,7 @@ class Production(Workflow, ModelSQL, ModelView): pool = Pool() Move = pool.get('stock.move') Date = pool.get('ir.date') - Move.write([m for p in productions - for m in p.outputs - if m.state not in ('done', 'cancel')], { - 'state': 'done', - }) + Move.do([m for p in productions for m in p.outputs]) cls.write(productions, { 'effective_date': Date.today(), }) @@ -575,10 +558,7 @@ class Production(Workflow, ModelSQL, ModelView): def assign_force(cls, productions): pool = Pool() Move = pool.get('stock.move') - Move.write([m for p in productions for m in p.inputs - if m.state != 'done'], { - 'state': 'assigned', - }) + Move.assign([m for p in productions for m in p.inputs]) cls.assign(productions)