Active Record

This commit is contained in:
Cédric Krier
2012-09-24 22:18:26 +02:00
parent 831dc76c00
commit 12c522409a
2 changed files with 23 additions and 14 deletions
+7
View File
@@ -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')
+16 -14
View File
@@ -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)