trytond-patches/issue8702.diff

82 lines
2.8 KiB
Diff

diff -r 168b01453902 __init__.py
--- a/trytond/trytond/modules/stock_supply_forecast/__init__.py Mon May 06 15:17:58 2019 +0200
+++ b/trytond/trytond/modules/stock_supply_forecast/__init__.py Fri Oct 04 10:04:50 2019 +0000
@@ -2,10 +2,10 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
-from .purchase_request import *
+from . import stock
def register():
Pool.register(
- PurchaseRequest,
- module='stock_supply_forecast', type_='model')
+ stock.StockSupply,
+ module='stock_supply_forecast', type_='wizard')
diff -r 168b01453902 purchase_request.py
--- a/trytond/trytond/modules/stock_supply_forecast/purchase_request.py Mon May 06 15:17:58 2019 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-# This file is part of Tryton. The COPYRIGHT file at the top level of
-# this repository contains the full copyright notices and license terms.
-from trytond.pool import Pool, PoolMeta
-
-__all__ = ['PurchaseRequest']
-
-
-class PurchaseRequest(metaclass=PoolMeta):
- __name__ = 'purchase.request'
-
- @classmethod
- def generate_requests(cls, *args, **kwargs):
- pool = Pool()
- Forecast = pool.get('stock.forecast')
- Date = pool.get('ir.date')
-
- today = Date.today()
-
- forecasts = Forecast.search([
- ('to_date', '>=', today),
- ('state', '=', 'done'),
- ])
- Forecast.create_moves(forecasts)
- super(PurchaseRequest, cls).generate_requests(*args, **kwargs)
- Forecast.delete_moves(forecasts)
diff -r 168b01453902 stock.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/trytond/trytond/modules/stock_supply_forecast/stock.py Fri Oct 04 10:04:50 2019 +0000
@@ -0,0 +1,22 @@
+# This file is part of Tryton. The COPYRIGHT file at the top level of
+# this repository contains the full copyright notices and license terms.
+from trytond.pool import Pool, PoolMeta
+
+class StockSupply(metaclass=PoolMeta):
+ __name__ = 'stock.supply'
+
+ def transition_create_(self):
+ pool = Pool()
+ Forecast = pool.get('stock.forecast')
+ Date = pool.get('ir.date')
+
+ today = Date.today()
+
+ forecasts = Forecast.search([
+ ('to_date', '>=', today),
+ ('state', '=', 'done'),
+ ])
+ Forecast.create_moves(forecasts)
+ res = super(StockSupply, self).transition_create_()
+ Forecast.delete_moves(forecasts)
+ return res
diff -r 168b01453902 tryton.cfg
--- a/trytond/trytond/modules/stock_supply_forecast/tryton.cfg Mon May 06 15:17:58 2019 +0200
+++ b/trytond/trytond/modules/stock_supply_forecast/tryton.cfg Fri Oct 04 10:04:50 2019 +0000
@@ -4,3 +4,5 @@
ir
stock_supply
stock_forecast
+extras_depend:
+ stock_supply_production