Active Record
This commit is contained in:
1 parent
831dc76c00
commit
12c522409a
2 files changed
+23
-14
No files matched your search
+16
-14
@@ -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)
|
||||
Reference in new issue
Block a user