Use Workflow for Stock Move

review600002
This commit is contained in:
Cédric Krier committed 2012-12-27 21:53:33 +01:00
1 parent 7a3fbb4529
commit e62cf5db4f
2 files changed
+8 -14

No files matched your search

+6 -12
View File
@@ -2,7 +2,7 @@
#this repository contains the full copyright notices and license terms.
from decimal import Decimal
from trytond.model import fields
from trytond.model import Workflow, ModelView, fields
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
@@ -168,15 +168,9 @@ class Move:
return super(Move, cls).copy(moves, default=default)
@classmethod
def create(cls, vals):
move = super(Move, cls).create(vals)
if vals.get('state') == 'done':
@ModelView.button
@Workflow.transition('done')
def do(cls, moves):
super(Move, cls).do(moves)
for move in moves:
move._create_account_stock_move()
return move
@classmethod
def write(cls, moves, vals):
super(Move, cls).write(moves, vals)
if vals.get('state') == 'done':
for move in moves:
move._create_account_stock_move()
+2 -2
View File
@@ -345,8 +345,8 @@ Create Move from Supplier to Customer::
>>> move.unit_price = Decimal(6)
>>> move.cost_price = move.unit_price
>>> move.currency = currency
>>> move.state = 'done'
>>> move.save()
>>> Move.do([move.id], config.context)
>>> stock_supplier.reload()
>>> (stock_supplier.debit, stock_supplier.credit) == \
... (Decimal(0), Decimal(68))
@@ -363,8 +363,8 @@ Create Move from Supplier to Customer::
>>> move.unit_price = Decimal(5)
>>> move.cost_price = move.unit_price
>>> move.currency = currency
>>> move.state = 'done'
>>> move.save()
>>> Move.do([move.id], config.context)
>>> stock_supplier.reload()
>>> (stock_supplier.debit, stock_supplier.credit) == \
... (Decimal(0), Decimal(88))