diff --git a/__init__.py b/__init__.py index 2b370ceceb..f7b292bc36 100644 --- a/__init__.py +++ b/__init__.py @@ -1,4 +1,11 @@ #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 from .purchase_request import * + + +def register(): + Pool.register( + PurchaseRequest, + module='stock_supply_forecast', type_='model') diff --git a/purchase_request.py b/purchase_request.py index 209a25c110..05966f63d2 100644 --- a/purchase_request.py +++ b/purchase_request.py @@ -1,24 +1,26 @@ #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.model import Model -from trytond.pool import Pool +from trytond.pool import Pool, PoolMeta + +__all__ = ['PurchaseRequest'] +__metaclass__ = PoolMeta -class PurchaseRequest(Model): - _name = 'purchase.request' +class PurchaseRequest: + __name__ = 'purchase.request' - def generate_requests(self): - forecast_obj = Pool().get('stock.forecast') - date_obj = Pool().get('ir.date') + @classmethod + def generate_requests(cls): + pool = Pool() + Forecast = pool.get('stock.forecast') + Date = pool.get('ir.date') - today = date_obj.today() + today = Date.today() - forecast_ids = forecast_obj.search([ + forecasts = Forecast.search([ ('to_date', '>=', today), ('state', '=', 'done'), ]) - forecast_obj.create_moves(forecast_ids) - super(PurchaseRequest, self).generate_requests() - forecast_obj.delete_moves(forecast_ids) - -PurchaseRequest() + Forecast.create_moves(forecasts) + super(PurchaseRequest, cls).generate_requests() + Forecast.delete_moves(forecasts)