Active Record
This commit is contained in:
@@ -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
@@ -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