changeset d6cedb836371 in modules/stock_forecast:default
details:
https://hg.tryton.org/modules/stock_forecast?cmd=changeset;node=d6cedb836371
description:
Add model, record and records attribute on Wizard
issue9421
review309861012
diffstat:
forecast.py | 19 +++++++------------
tests/test_stock_forecast.py | 3 ++-
2 files changed, 9 insertions(+), 13 deletions(-)
diffs (61 lines):
diff -r 10fb40f2cbd6 -r d6cedb836371 forecast.py
--- a/forecast.py Sat Jun 06 10:30:12 2020 +0100
+++ b/forecast.py Tue Jul 07 23:56:10 2020 +0200
@@ -563,25 +563,21 @@
"""
Forecast dates shifted by one year.
"""
- Forecast = Pool().get('stock.forecast')
- forecast = Forecast(Transaction().context['active_id'])
-
- res = {}
+ default = {}
for field in ("to_date", "from_date"):
- res[field] = getattr(forecast, field) - relativedelta(years=1)
- return res
+ default[field] = (
+ getattr(self.record, field) - relativedelta(years=1))
+ return default
def _get_product_quantity(self):
pool = Pool()
- Forecast = pool.get('stock.forecast')
Product = pool.get('product.product')
- forecast = Forecast(Transaction().context['active_id'])
with Transaction().set_context(
- stock_destinations=[forecast.destination.id],
+ stock_destinations=[self.record.destination.id],
stock_date_start=self.ask.from_date,
stock_date_end=self.ask.to_date):
- return Product.products_by_location([forecast.warehouse.id],
+ return Product.products_by_location([self.record.warehouse.id],
with_childs=True)
def default_choose(self, fields):
@@ -600,11 +596,10 @@
def transition_complete(self):
pool = Pool()
- Forecast = pool.get('stock.forecast')
ForecastLine = pool.get('stock.forecast.line')
Product = pool.get('product.product')
- forecast = Forecast(Transaction().context['active_id'])
+ forecast = self.record
prod2line = {}
forecast_lines = ForecastLine.search([
('forecast', '=', forecast.id),
diff -r 10fb40f2cbd6 -r d6cedb836371 tests/test_stock_forecast.py
--- a/tests/test_stock_forecast.py Sat Jun 06 10:30:12 2020 +0100
+++ b/tests/test_stock_forecast.py Tue Jul 07 23:56:10 2020 +0200
@@ -303,7 +303,8 @@
'company': company.id,
}])
- with Transaction().set_context(active_id=forecast.id):
+ with Transaction().set_context(
+ active_model=Forecast.__name__, active_id=forecast.id):
session_id, _, _ = ForecastComplete.create()
forecast_complete = ForecastComplete(session_id)
forecast_complete.ask.from_date = (