diff --git a/addons/mrp/__init__.py b/addons/mrp/__init__.py
index 3283ec11b99..4c69a136661 100644
--- a/addons/mrp/__init__.py
+++ b/addons/mrp/__init__.py
@@ -28,5 +28,6 @@ import company
import schedulers
import make_procurement
+import orderpoint_procurement
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp/__terp__.py b/addons/mrp/__terp__.py
index 6497dc3933a..72b09d3a77a 100644
--- a/addons/mrp/__terp__.py
+++ b/addons/mrp/__terp__.py
@@ -70,6 +70,7 @@
'process/procurement_process.xml',
'mrp_installer.xml',
'make_procurement.xml',
+ 'orderpoint_procurement.xml',
],
'demo_xml': ['mrp_demo.xml', 'mrp_order_point.xml'],
'installable': True,
diff --git a/addons/mrp/mrp_wizard.xml b/addons/mrp/mrp_wizard.xml
index 852bc57bac9..fe13df46387 100644
--- a/addons/mrp/mrp_wizard.xml
+++ b/addons/mrp/mrp_wizard.xml
@@ -8,7 +8,7 @@
-->
-
+
diff --git a/addons/mrp/orderpoint_procurement.xml b/addons/mrp/orderpoint_procurement.xml
new file mode 100644
index 00000000000..3a2ac2bb638
--- /dev/null
+++ b/addons/mrp/orderpoint_procurement.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+ Compute Stock Minimum Rules Only
+ mrp.procurement.orderpoint.compute
+ form
+
+
+
+
+
+
+ Compute Stock Minimum Rules Only
+ ir.actions.act_window
+ mrp.procurement.orderpoint.compute
+ form
+ form
+ new
+ {'record_id' : active_id}
+
+
+
+
+
+ Compute Stock Minimum Rules Only
+ client_action_multi
+
+ action
+ mrp.procurement
+
+
+
+
\ No newline at end of file
diff --git a/addons/mrp/wizard/make_procurement.py b/addons/mrp/wizard/make_procurement.py
new file mode 100644
index 00000000000..0cf12107181
--- /dev/null
+++ b/addons/mrp/wizard/make_procurement.py
@@ -0,0 +1,102 @@
+# -*- 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 wizard
+import pooler
+import netsvc
+
+import time
+
+def _get_default(obj, cr, uid, data, context=None):
+ pool = pooler.get_pool(cr.dbname)
+ product = pool.get('product.product').browse(cr, uid, data['id'], context)
+ return {'product_id': product.id, 'uom_id':product.uom_id.id, 'qty':1.0}
+
+def make_procurement(obj, cr, uid, data, context=None):
+ '''Create procurement'''
+ pool = pooler.get_pool(cr.dbname)
+ wh = pool.get('stock.warehouse').browse(cr, uid, data['form']['warehouse_id'], context)
+ user = pool.get('res.users').browse(cr, uid, uid, context)
+ procure_id = pool.get('mrp.procurement').create(cr, uid, {
+ 'name':'INT:'+str(user.login),
+ 'date_planned':data['form']['date_planned'],
+ 'product_id':data['form']['product_id'],
+ 'product_qty':data['form']['qty'],
+ 'product_uom':data['form']['uom_id'],
+ 'location_id':wh.lot_stock_id.id,
+ 'procure_method':'make_to_order',
+ }, context=context)
+ wf_service = netsvc.LocalService("workflow")
+ wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
+ return {}
+
+
+class MakeProcurement(wizard.interface):
+ '''Wizard that create a procurement from a product form'''
+
+ done_form = """
+"""
+ procurement_form = """
+"""
+ procurement_fields = {
+ 'qty': {'string': 'Quantity', 'type': 'float', 'digits':(16,2), 'required': True},
+ 'product_id': {'string': 'product', 'type': 'many2one', 'relation': 'product.product', 'required': True, 'readonly':1},
+ 'uom_id': {'string': 'Unit of Measure', 'type': 'many2one', 'relation': 'product.uom', 'required':True},
+ 'warehouse_id': {'string': 'Warehouse', 'type': 'many2one', 'relation':'stock.warehouse', 'required':True},
+ 'date_planned': {'string': 'Planned Date', 'type': 'date', 'required':True, 'default': lambda *args: time.strftime('%Y-%m-%d')}
+ }
+
+ states = {
+ 'init': {
+ 'actions': [_get_default],
+ 'result': {'type': 'form', 'arch': procurement_form, 'fields': procurement_fields,
+ 'state': [
+ ('end', 'Cancel'),
+ ('create', 'Ask New Products')
+ ]
+ }
+ },
+ 'done': {
+ 'actions': [],
+ 'result': {'type': 'form', 'arch': done_form, 'fields': {},
+ 'state': [
+ ('end', 'Close'),
+ ]
+ }
+ },
+ 'create': {
+ 'actions': [],
+ 'result': {'type': 'action', 'action': make_procurement, 'state': 'done'}
+ }
+ }
+
+MakeProcurement('product.product.procurement')
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/mrp/wizard/orderpoint_procurement.py b/addons/mrp/wizard/orderpoint_procurement.py
new file mode 100644
index 00000000000..e9bf9377d11
--- /dev/null
+++ b/addons/mrp/wizard/orderpoint_procurement.py
@@ -0,0 +1,61 @@
+# -*- 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 .
+#
+##############################################################################
+
+#
+# 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):
+ _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/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 ().
-#
-# 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 .
-#
-##############################################################################
-
-#
-# 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 = '''
-'''
-
-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:
-