From a753efb0bf5ea5bcd542870f786fdf0187b17c78 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Tue, 9 Mar 2010 14:24:06 +0530 Subject: [PATCH] [IMP] mrp: Converted 'Compute Schedulers' wizard into osv_memory wizard. bzr revid: uco@tinyerp.co.in-20100309085406-cd2vk9u95n5h3v5n --- addons/mrp/__terp__.py | 1 + addons/mrp/mrp_wizard.xml | 6 +- addons/mrp/wizard/__init__.py | 2 +- addons/mrp/wizard/schedulers_all.py | 54 ++++++++++++++++++ addons/mrp/wizard/schedulers_all_view.xml | 49 +++++++++++++++++ addons/mrp/wizard/wizard_schedulers_all.py | 64 ---------------------- 6 files changed, 108 insertions(+), 68 deletions(-) create mode 100644 addons/mrp/wizard/schedulers_all.py create mode 100644 addons/mrp/wizard/schedulers_all_view.xml delete mode 100644 addons/mrp/wizard/wizard_schedulers_all.py diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py index b8ca73b1d51..d898380822d 100644 --- a/addons/mrp/__terp__.py +++ b/addons/mrp/__terp__.py @@ -64,6 +64,7 @@ 'wizard/make_procurement_view.xml', 'wizard/change_production_qty_view.xml', 'wizard/orderpoint_procurement_view.xml', + 'wizard/schedulers_all_view.xml', 'mrp_view.xml', 'mrp_wizard.xml', 'mrp_report.xml', diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml index 41d945f61a1..35b33186986 100644 --- a/addons/mrp/mrp_wizard.xml +++ b/addons/mrp/mrp_wizard.xml @@ -1,9 +1,9 @@ - - - + + + diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 7affcdb9dc1..41709aa42a6 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -21,7 +21,7 @@ import orderpoint_procurement import wizard_procurement -import wizard_schedulers_all +import schedulers_all import wizard_price import wizard_workcenter_load import wizard_track_prod diff --git a/addons/mrp/wizard/schedulers_all.py b/addons/mrp/wizard/schedulers_all.py new file mode 100644 index 00000000000..f1ef2501add --- /dev/null +++ b/addons/mrp/wizard/schedulers_all.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import threading + +from osv import osv, fields + +class procurement_compute(osv.osv_memory): + _name = 'mrp.procurement.compute.all' + _description = 'Compute all schedulers' + + _columns = { + 'automatic': fields.boolean('Automatic orderpoint',help='Triggers an automatic procurement for all products that have a virtual stock under 0. You should probably not use this option, we suggest using a MTO configuration on products.'), + } + + _defaults ={ + 'automatic': lambda *a: False, + } + + def _procure_calculation_all(self, cr, uid, ids, context): + proc_obj = self.pool.get('mrp.procurement') + for proc in self.browse(cr, uid, ids): + proc_obj.run_scheduler(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname,\ + context=context) + return {} + + def procure_calculation(self, cr, uid, ids, context): + threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context)) + threaded_calculation.start() + return {} + +procurement_compute() + + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: + diff --git a/addons/mrp/wizard/schedulers_all_view.xml b/addons/mrp/wizard/schedulers_all_view.xml new file mode 100644 index 00000000000..4574a965fbc --- /dev/null +++ b/addons/mrp/wizard/schedulers_all_view.xml @@ -0,0 +1,49 @@ + + + + + + + + Compute Schedulers + mrp.procurement.compute.all + form + +
+ + + +