diff options
| author | uco (OpenERP) <uco@tinyerp.co.in> | 2010-03-09 14:11:59 +0530 |
|---|---|---|
| committer | uco (OpenERP) <uco@tinyerp.co.in> | 2010-03-09 14:11:59 +0530 |
| commit | 31826907284b72d83cac2b15e91450c1fbbe358a (patch) | |
| tree | 99fd0523c4244abfd8299af10228d71bcb7e3ab3 | |
| parent | 9fd8b8ad5a477a1a3b2eba88267d2dad48e64741 (diff) | |
[IMP] mrp: Converted 'Compute Stock Minimum Rules Only' wizard into osv_memory wizard.
bzr revid: uco@tinyerp.co.in-20100309084159-knxmex7nv6ezi4r2
| -rw-r--r-- | addons/mrp/__terp__.py | 1 | ||||
| -rw-r--r-- | addons/mrp/mrp_wizard.xml | 2 | ||||
| -rw-r--r-- | addons/mrp/wizard/__init__.py | 2 | ||||
| -rw-r--r-- | addons/mrp/wizard/orderpoint_procurement.py | 58 | ||||
| -rw-r--r-- | addons/mrp/wizard/orderpoint_procurement_view.xml | 46 | ||||
| -rw-r--r-- | addons/mrp/wizard/wizard_orderpoint_procurement.py | 73 |
6 files changed, 107 insertions, 75 deletions
diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py index ff51c74a41a..b8ca73b1d51 100644 --- a/addons/mrp/__terp__.py +++ b/addons/mrp/__terp__.py @@ -63,6 +63,7 @@ 'mrp_wizard_view.xml', 'wizard/make_procurement_view.xml', 'wizard/change_production_qty_view.xml', + 'wizard/orderpoint_procurement_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 e1823092989..41d945f61a1 100644 --- a/addons/mrp/mrp_wizard.xml +++ b/addons/mrp/mrp_wizard.xml @@ -8,7 +8,7 @@ <menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/> --> - <wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/> +<!-- <wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>--> <!-- <menuitem action="wiz_mrp_proc2" id="menu_wiz_mrp_proc2" parent="mrp.mrp_Sched_all" type="wizard"/> --> diff --git a/addons/mrp/wizard/__init__.py b/addons/mrp/wizard/__init__.py index 462ec509e09..7affcdb9dc1 100644 --- a/addons/mrp/wizard/__init__.py +++ b/addons/mrp/wizard/__init__.py @@ -19,7 +19,7 @@ # ############################################################################## -import wizard_orderpoint_procurement +import orderpoint_procurement import wizard_procurement import wizard_schedulers_all import wizard_price diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py new file mode 100644 index 00000000000..623e8080e9c --- /dev/null +++ b/addons/mrp/wizard/orderpoint_procurement.py @@ -0,0 +1,58 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +# +# Order Point Method: +# - Order if the virtual stock of today is bellow the min of the defined order point +# + +import threading +from osv import fields,osv + +class procurement_compute(osv.osv_memory): + _name = 'mrp.procurement.orderpoint.compute' + _description = 'Automatic Order Point' + + _columns = { + 'automatic': fields.boolean('Automatic Orderpoint', help='If the stock of a product is under 0, it will act like an orderpoint'), + } + + _defaults = { + 'automatic' : lambda *a: False, + } + + def _procure_calculation_orderpoint(self, cr, uid, ids, context): + try: + proc_obj = self.pool.get('mrp.procurement') + for proc in self.browse(cr, uid, ids): + proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context) + finally: + cr.close() + return {} + + def procure_calculation(self, cr, uid, ids, context): + threaded_calculation = threading.Thread(target=self._procure_calculation_orderpoint, 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/orderpoint_procurement_view.xml b/addons/mrp/wizard/orderpoint_procurement_view.xml new file mode 100644 index 00000000000..65acca77d0d --- /dev/null +++ b/addons/mrp/wizard/orderpoint_procurement_view.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data> + + <!-- Compute Stock Minimum Rules Only --> + + <record id="view_procurement_compute_wizard" model="ir.ui.view"> + <field name="name">Compute Stock Minimum Rules Only</field> + <field name="model">mrp.procurement.orderpoint.compute</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Parameters"> + <field name="automatic"/> + <separator colspan="4"/> + <group col="2" colspan="4"> + <button icon='gtk-cancel' special="cancel" + string="Cancel" /> + <button name="procure_calculation" string="Compute Stock" + colspan="1" type="object" icon="gtk-ok" /> + </group> + </form> + </field> + </record> + + <record id="action_procurement_compute" model="ir.actions.act_window"> + <field name="name">Compute Stock Minimum Rules Only</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">mrp.procurement.orderpoint.compute</field> + <field name="view_type">form</field> + <field name="view_mode">form</field> + <field name="target">new</field> + <field name="context">{'record_id' : active_id}</field> + </record> + + <record model="ir.values" id="procurement_compute_order_point"> + <field name="model_id" ref="mrp.model_mrp_procurement" /> + <field name="object" eval="1" /> + <field name="name">Compute Stock Minimum Rules Only</field> + <field name="key2">client_action_multi</field> + <field name="value" eval="'ir.actions.act_window,' + str(ref('action_procurement_compute'))" /> + <field name="key">action</field> + <field name="model">mrp.procurement</field> + </record> + + </data> +</openerp> diff --git a/addons/mrp/wizard/wizard_orderpoint_procurement.py b/addons/mrp/wizard/wizard_orderpoint_procurement.py deleted file mode 100644 index a4fa57bb9a8..00000000000 --- a/addons/mrp/wizard/wizard_orderpoint_procurement.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). -# -# 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 <http://www.gnu.org/licenses/>. -# -############################################################################## - -# -# Order Point Method: -# - Order if the virtual stock of today is bellow the min of the defined order point -# - -import wizard -import threading -import pooler - -parameter_form = '''<?xml version="1.0"?> -<form string="Parameters" colspan="4"> - <field name="automatic" /> -</form>''' - -parameter_fields = { - 'automatic': {'string': 'Automatic orderpoint', 'type': 'boolean', 'help': 'If the stock of a product is under 0, it will act like an orderpoint', 'default': lambda *a: False}, -} - -def _procure_calculation_orderpoint(self, db_name, uid, data, context): - db, pool = pooler.get_db_and_pool(db_name) - cr = db.cursor() - try: - proc_obj = pool.get('mrp.procurement') - automatic = data['form']['automatic'] - proc_obj._procure_orderpoint_confirm(cr, uid, automatic=automatic,\ - use_new_cursor=cr.dbname, context=context) - finally: - cr.close() - return {} - -def _procure_calculation(self, cr, uid, data, context): - threaded_calculation = threading.Thread(target=_procure_calculation_orderpoint, args=(self, cr.dbname, uid, data, context)) - threaded_calculation.start() - return {} - -class procurement_compute(wizard.interface): - states = { - 'init': { - 'actions': [], - 'result': {'type': 'form', 'arch':parameter_form, 'fields': parameter_fields, 'state':[('end','Cancel'),('compute','Compute Stock')]} - }, - 'compute': { - 'actions': [_procure_calculation], - 'result': {'type': 'state', 'state':'end'} - }, - } -procurement_compute('mrp.procurement.orderpoint.compute') - - - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - |
