Files
tryton/modules/stock/tests/scenario_stock_move_in_future.rst
T
Cédric Krier 4683fde7ac Make scenario independent of the current day
The fiscal years are created centered on the passed date such that if the
current day change during the execution, the fiscal year is still usable.
Also fiscal year can be created for a range of dates such that it is guarantee
that the dates are in the fiscal year.
And finally remove datetime and dateutil import when they are not used.

Closes #9977
2023-01-01 10:36:03 +01:00

72 lines
1.9 KiB
ReStructuredText

=============================
Stock Move In Future Scenario
=============================
Imports::
>>> import datetime as dt
>>> from decimal import Decimal
>>> from proteus import Model
>>> from trytond.tests.tools import activate_modules
>>> from trytond.modules.company.tests.tools import (
... create_company, get_company)
>>> today = dt.date.today()
>>> tomorrow = today + dt.timedelta(days=1)
Activate modules::
>>> config = activate_modules('stock')
Create company::
>>> _ = create_company()
>>> company = get_company()
Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('20')
>>> template.save()
>>> product, = template.products
>>> product.cost_price = Decimal('1')
>>> product.save()
Get stock locations::
>>> Location = Model.get('stock.location')
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
>>> storage_loc, = Location.find([('code', '=', 'STO')])
A warning is raised when doing a move in the future::
>>> Move = Model.get('stock.move')
>>> move = Move()
>>> move.product = product
>>> move.quantity = 1
>>> move.from_location = supplier_loc
>>> move.to_location = storage_loc
>>> move.currency = company.currency
>>> move.effective_date = tomorrow
>>> move.quantity = 2
>>> move.unit_price = Decimal('1')
>>> move.save()
>>> move.click('do') # doctest: +IGNORE_EXCEPTION_DETAIL
Traceback (most recent call last):
...
MoveFutureWarning: ...
But it can be done for today::
>>> move.effective_date = today
>>> move.click('do')
>>> move.state
'done'