Add some test tools to ease scenario writing
review11331002
This commit is contained in:
@@ -2,16 +2,14 @@
|
||||
Stock Lot Shipment Out Scenario
|
||||
===============================
|
||||
|
||||
=============
|
||||
General Setup
|
||||
=============
|
||||
|
||||
Imports::
|
||||
|
||||
>>> import datetime
|
||||
>>> from dateutil.relativedelta import relativedelta
|
||||
>>> from decimal import Decimal
|
||||
>>> from proteus import config, Model, Wizard
|
||||
>>> from trytond.modules.company.tests.tools import create_company, \
|
||||
... get_company
|
||||
>>> today = datetime.date.today()
|
||||
|
||||
Create database::
|
||||
@@ -22,35 +20,14 @@ Create database::
|
||||
Install stock_lot Module::
|
||||
|
||||
>>> Module = Model.get('ir.module.module')
|
||||
>>> modules = Module.find([('name', '=', 'stock_lot')])
|
||||
>>> Module.install([x.id for x in modules], config.context)
|
||||
>>> module, = Module.find([('name', '=', 'stock_lot')])
|
||||
>>> module.click('install')
|
||||
>>> Wizard('ir.module.module.install_upgrade').execute('upgrade')
|
||||
|
||||
Create company::
|
||||
|
||||
>>> Currency = Model.get('currency.currency')
|
||||
>>> CurrencyRate = Model.get('currency.currency.rate')
|
||||
>>> Company = Model.get('company.company')
|
||||
>>> Party = Model.get('party.party')
|
||||
>>> company_config = Wizard('company.company.config')
|
||||
>>> company_config.execute('company')
|
||||
>>> company = company_config.form
|
||||
>>> party = Party(name='Dunder Mifflin')
|
||||
>>> party.save()
|
||||
>>> company.party = party
|
||||
>>> currencies = Currency.find([('code', '=', 'USD')])
|
||||
>>> if not currencies:
|
||||
... currency = Currency(name='U.S. Dollar', symbol='$', code='USD',
|
||||
... rounding=Decimal('0.01'), mon_grouping='[3, 3, 0]',
|
||||
... mon_decimal_point='.', mon_thousands_sep=',')
|
||||
... currency.save()
|
||||
... CurrencyRate(date=today + relativedelta(month=1, day=1),
|
||||
... rate=Decimal('1.0'), currency=currency).save()
|
||||
... else:
|
||||
... currency, = currencies
|
||||
>>> company.currency = currency
|
||||
>>> company_config.execute('add')
|
||||
>>> company, = Company.find()
|
||||
>>> _ = create_company()
|
||||
>>> company = get_company()
|
||||
|
||||
Reload the context::
|
||||
|
||||
@@ -110,7 +87,7 @@ Add two shipment lines of same product::
|
||||
>>> move.to_location = customer_loc
|
||||
>>> move.company = company
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> move.currency = company.currency
|
||||
>>> move = StockMove()
|
||||
>>> shipment_out.outgoing_moves.append(move)
|
||||
>>> move.product = product
|
||||
@@ -120,13 +97,12 @@ Add two shipment lines of same product::
|
||||
>>> move.to_location = customer_loc
|
||||
>>> move.company = company
|
||||
>>> move.unit_price = Decimal('1')
|
||||
>>> move.currency = currency
|
||||
>>> move.currency = company.currency
|
||||
>>> shipment_out.save()
|
||||
|
||||
Set the shipment state to waiting::
|
||||
|
||||
>>> ShipmentOut.wait([shipment_out.id], config.context)
|
||||
>>> shipment_out.reload()
|
||||
>>> shipment_out.click('wait')
|
||||
>>> len(shipment_out.outgoing_moves)
|
||||
2
|
||||
>>> len(shipment_out.inventory_moves)
|
||||
@@ -136,11 +112,9 @@ Assign the shipment with 2 lines of 7 products::
|
||||
|
||||
>>> for move in shipment_out.inventory_moves:
|
||||
... move.quantity = 7
|
||||
>>> shipment_out.save()
|
||||
>>> ShipmentOut.assign_force([shipment_out.id], config.context)
|
||||
>>> shipment_out.reload()
|
||||
>>> shipment_out.state == 'assigned'
|
||||
True
|
||||
>>> shipment_out.click('assign_force')
|
||||
>>> shipment_out.state
|
||||
u'assigned'
|
||||
|
||||
Set 2 lots::
|
||||
|
||||
@@ -153,10 +127,9 @@ Set 2 lots::
|
||||
|
||||
Pack the shipment::
|
||||
|
||||
>>> ShipmentOut.pack([shipment_out.id], config.context)
|
||||
>>> shipment_out.reload()
|
||||
>>> shipment_out.state == 'packed'
|
||||
True
|
||||
>>> shipment_out.click('pack')
|
||||
>>> shipment_out.state
|
||||
u'packed'
|
||||
>>> len(shipment_out.outgoing_moves)
|
||||
3
|
||||
>>> sorted([m.quantity for m in shipment_out.outgoing_moves])
|
||||
|
||||
Reference in New Issue
Block a user