[IMP] procurment: Task ID-819: mrp_procurement should be renamed in procurement ...
authoruco (OpenERP) <uco@tinyerp.com>
Thu, 27 May 2010 05:45:42 +0000 (11:15 +0530)
committeruco (OpenERP) <uco@tinyerp.com>
Thu, 27 May 2010 05:45:42 +0000 (11:15 +0530)
bzr revid: uco@tinyerp.com-20100527054542-0jq7fam3f6ga071f

66 files changed:
addons/board_manufacturing/board_manufacturing_view.xml
addons/board_warehouse/board_warehouse_view.xml
addons/mrp/__init__.py
addons/mrp/__openerp__.py
addons/mrp/mrp_procurement.py [deleted file]
addons/mrp/mrp_view.xml
addons/mrp/mrp_workflow.xml
addons/mrp/process/procurement_process.xml
addons/mrp/procurement.py [new file with mode: 0644]
addons/mrp_jit/__openerp__.py
addons/mrp_jit/mrp_jit.xml
addons/mrp_procurement/__init__.py [deleted file]
addons/mrp_procurement/__openerp__.py [deleted file]
addons/mrp_procurement/company.py [deleted file]
addons/mrp_procurement/company_view.xml [deleted file]
addons/mrp_procurement/mrp_procurement.py [deleted file]
addons/mrp_procurement/mrp_procurement_data.xml [deleted file]
addons/mrp_procurement/mrp_procurement_view.xml [deleted file]
addons/mrp_procurement/mrp_procurement_workflow.xml [deleted file]
addons/mrp_procurement/process/procurement_process.xml [deleted file]
addons/mrp_procurement/schedulers.py [deleted file]
addons/mrp_procurement/scripts/scheduler.py [deleted file]
addons/mrp_procurement/security/ir.model.access.csv [deleted file]
addons/mrp_procurement/security/mrp_procurement_security.xml [deleted file]
addons/mrp_procurement/wizard/__init__.py [deleted file]
addons/mrp_procurement/wizard/make_procurement_product.py [deleted file]
addons/mrp_procurement/wizard/make_procurement_view.xml [deleted file]
addons/mrp_procurement/wizard/mrp_procurement.py [deleted file]
addons/mrp_procurement/wizard/mrp_procurement_view.xml [deleted file]
addons/mrp_procurement/wizard/orderpoint_procurement.py [deleted file]
addons/mrp_procurement/wizard/orderpoint_procurement_view.xml [deleted file]
addons/mrp_procurement/wizard/schedulers_all.py [deleted file]
addons/mrp_procurement/wizard/schedulers_all_view.xml [deleted file]
addons/point_of_sale/posrule_data.xml
addons/point_of_sale/posrule_data2.xml
addons/point_of_sale/statement_data.xml
addons/procurement/__init__.py [new file with mode: 0644]
addons/procurement/__openerp__.py [new file with mode: 0644]
addons/procurement/company.py [new file with mode: 0644]
addons/procurement/company_view.xml [new file with mode: 0644]
addons/procurement/process/procurement_process.xml [new file with mode: 0644]
addons/procurement/procurement.py [new file with mode: 0644]
addons/procurement/procurement_data.xml [new file with mode: 0644]
addons/procurement/procurement_view.xml [new file with mode: 0644]
addons/procurement/procurement_workflow.xml [new file with mode: 0644]
addons/procurement/schedulers.py [new file with mode: 0644]
addons/procurement/scripts/scheduler.py [new file with mode: 0644]
addons/procurement/security/ir.model.access.csv [new file with mode: 0644]
addons/procurement/security/procurement_security.xml [new file with mode: 0644]
addons/procurement/wizard/__init__.py [new file with mode: 0644]
addons/procurement/wizard/make_procurement_product.py [new file with mode: 0644]
addons/procurement/wizard/make_procurement_view.xml [new file with mode: 0644]
addons/procurement/wizard/mrp_procurement.py [new file with mode: 0644]
addons/procurement/wizard/mrp_procurement_view.xml [new file with mode: 0644]
addons/procurement/wizard/orderpoint_procurement.py [new file with mode: 0644]
addons/procurement/wizard/orderpoint_procurement_view.xml [new file with mode: 0644]
addons/procurement/wizard/schedulers_all.py [new file with mode: 0644]
addons/procurement/wizard/schedulers_all_view.xml [new file with mode: 0644]
addons/project_mrp/__openerp__.py
addons/project_mrp/project_mrp_workflow.xml
addons/purchase/__openerp__.py
addons/purchase/purchase_view.xml
addons/purchase/purchase_workflow.xml
addons/sale/__openerp__.py
addons/sale/process/sale_process.xml
addons/sale/security/ir.model.access.csv

index 191f181..b223f12 100644 (file)
@@ -14,8 +14,8 @@
                     <hpaned position="100">
                         <child1>
                             <action colspan="4" height="200" name="%(mrp.mrp_production_action2)d" string="Next production orders" width="510"/>
-                            <action colspan="4" name="%(stock.action_picking_all)d" string="Deliveries (Out picking)" domain="[('state','=','assigned'),('type','=','out')]"/>
-                            <action colspan="4" name="%(mrp_procurement.mrp_procurement_action4)d" string="Procurements in Exception"/>
+                            <action colspan="4" name="%(stock.action_picking_tree)d" string="Deliveries (Out picking)" domain="[('state','=','assigned'),('type','=','out')]"/>
+                            <action colspan="4" name="%(procurement.mrp_procurement_action4)d" string="Procurements in Exception"/>
                         </child1>
 
 
index af79740..4ce02a7 100644 (file)
@@ -23,7 +23,7 @@
                 <form string="Warehouse board">
                     <hpaned position="100">
                         <child1>
-                                               <action colspan="4" name="%(mrp_procurement.mrp_procurement_action5)d" string="Procurement Exceptions" width="510" />
+                                               <action colspan="4" name="%(procurement.mrp_procurement_action5)d" string="Procurement Exceptions" width="510" />
                                                <action colspan="4" name="%(action_reception_picking_move_board)d" string="Products To Receive" />
                         </child1>
 
index d23cee8..30367ec 100644 (file)
@@ -26,6 +26,6 @@ import installer
 import wizard
 import report
 import company
-import mrp_procurement
+import procurement
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 97e23f3..45b35d5 100644 (file)
@@ -26,7 +26,7 @@
     "author" : "Tiny",
     "website" : "http://www.openerp.com",
     "category" : "Generic Modules/Production",
-    "depends" : ["mrp_procurement", "stock", "resource", "purchase", "product","process"],
+    "depends" : ["procurement", "stock", "resource", "purchase", "product","process"],
     "description": """
     This is the base module to manage the manufacturing process in Open ERP.
 
diff --git a/addons/mrp/mrp_procurement.py b/addons/mrp/mrp_procurement.py
deleted file mode 100644 (file)
index 4ebd11f..0000000
+++ /dev/null
@@ -1,96 +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/>.
-#
-##############################################################################
-
-from mx import DateTime
-from osv import fields
-from osv import osv
-from tools.translate import _
-import ir
-import netsvc
-import time
-
-class mrp_procurement(osv.osv):
-    _inherit = 'mrp.procurement'
-    _columns = {
-        'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True),
-    }
-    
-    def check_produce_product(self, cr, uid, procurement, context=[]):
-        """ Finds the bill of material for the product from procurement order.
-        @return: True or False
-        """
-        properties = [x.id for x in procurement.property_ids]
-        bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties)
-        if not bom_id:
-            cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
-            return False
-        return True
-    
-    def action_produce_assign_product(self, cr, uid, ids, context={}):
-        """ This is action which call from workflow to assign production order to procurements
-        @return: True
-        """
-        procurement_obj = self.pool.get('mrp.procurement')
-        res = procurement_obj.make_mo(cr, uid, ids, context=context)
-        res = res.values()
-        return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
-    
-    def make_mo(self, cr, uid, ids, context={}):
-        """ Make Manufacturing(production) order from procurement
-        @return: New created Production Orders procurement wise 
-        """
-        res = {}
-        company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
-        production_obj = self.pool.get('mrp.production')
-        move_obj = self.pool.get('stock.move')
-        wf_service = netsvc.LocalService("workflow")
-        procurement_obj = self.pool.get('mrp.procurement')
-        for procurement in procurement_obj.browse(cr, uid, ids):
-            res_id = procurement.move_id.id
-            loc_id = procurement.location_id.id
-            newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
-            newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead)
-            produce_id = production_obj.create(cr, uid, {
-                'origin': procurement.origin,
-                'product_id': procurement.product_id.id,
-                'product_qty': procurement.product_qty,
-                'product_uom': procurement.product_uom.id,
-                'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False,
-                'product_uos': procurement.product_uos and procurement.product_uos.id or False,
-                'location_src_id': procurement.location_id.id,
-                'location_dest_id': procurement.location_id.id,
-                'bom_id': procurement.bom_id and procurement.bom_id.id or False,
-                'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
-                'move_prod_id': res_id,
-                'company_id': procurement.company_id.id,
-            })
-            res[procurement.id] = produce_id
-            self.write(cr, uid, [procurement.id], {'state': 'running'})
-            bom_result = production_obj.action_compute(cr, uid,
-                    [produce_id], properties=[x.id for x in procurement.property_ids])
-            wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
-            move_obj.write(cr, uid, [res_id],
-                    {'location_id': procurement.location_id.id})
-        return res
-    
-mrp_procurement()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 80587c6..6ee6342 100644 (file)
         Procurement
         -->
 
-               <menuitem action="mrp_procurement.mrp_procurement_action" id="menu_mrp_procurement_action"
+               <menuitem action="procurement.mrp_procurement_action" id="menu_mrp_procurement_action"
                          parent="mrp.menu_mrp_manufacturing" sequence="2" />
-<!--        <menuitem action="mrp_procurement.mrp_procurement_action5" id="menu_mrp_procurement_exception_action"-->
+<!--        <menuitem action="procurement.mrp_procurement_action5" id="menu_mrp_procurement_exception_action"-->
 <!--                     parent="mrp.menu_mrp_control" sequence="1" />-->
 
        <menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
-        <menuitem action="mrp_procurement.action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
+        <menuitem action="procurement.action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
 
                <!--
                Order Point
                -->
-               <menuitem action="mrp_procurement.action_orderpoint_form" id="menu_action_orderpoint_form" parent="mrp.menu_mrp_reordering"/>
+               <menuitem action="procurement.action_orderpoint_form" id="menu_action_orderpoint_form" parent="mrp.menu_mrp_reordering"/>
 
         <!--
            Production Management
         <record id="view_procurement_form_inherit" model="ir.ui.view">
                <field name="name">mrp.procurement.form.inherit</field>
                <field name="model">mrp.procurement</field>
-               <field name="inherit_id" ref="mrp_procurement.mrp_procurement_form_view"/>
+               <field name="inherit_id" ref="procurement.mrp_procurement_form_view"/>
                <field name="type">form</field>
                <field name="arch" type="xml">
                        <xpath expr="/form/notebook/page/field[@name='move_id']" position="before">
index a9c83b2..0a55ccd 100644 (file)
         <!-- Procurement -->
 
         <record id="act_produce" model="workflow.activity">
-            <field name="wkf_id" ref="mrp_procurement.wkf_procurement"/>
+            <field name="wkf_id" ref="procurement.wkf_procurement"/>
             <field name="name">produce</field>
             <field name="kind">subflow</field>
             <field name="subflow_id" search="[('osv','=','mrp.production')]"/>
         </record>
         
         <record id="trans_product_check_produce" model="workflow.transition">
-            <field name="act_from" ref="mrp_procurement.act_produce_check"/>
+            <field name="act_from" ref="procurement.act_produce_check"/>
             <field name="act_to" ref="act_produce"/>
             <field name="condition">check_product()</field>
         </record>
         
         <record id="trans_produce_cancel" model="workflow.transition">
             <field name="act_from" ref="act_produce"/>
-            <field name="act_to" ref="mrp_procurement.act_cancel"/>
+            <field name="act_to" ref="procurement.act_cancel"/>
             <field name="signal">subflow.cancel</field>
         </record>
         
         <record id="trans_produce_make_done" model="workflow.transition">
             <field name="act_from" ref="act_produce"/>
-            <field name="act_to" ref="mrp_procurement.act_make_done"/>
+            <field name="act_to" ref="procurement.act_make_done"/>
             <field name="signal">subflow.done</field>
         </record>
         
index 08d6657..25c204a 100644 (file)
@@ -4,11 +4,11 @@
     
        <record id="process_node_procureproducts0" model="process.node">
             <field name="menu_id" ref="mrp.menu_mrp_procurement_action"/>
-            <field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
+            <field name="model_id" ref="procurement.model_mrp_procurement"/>
             <field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;The way to procurement depends on the product type.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Procure Products&quot;&quot;&quot;" name="name"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="0" name="flow_start"/>
         </record>
@@ -19,7 +19,7 @@
             <field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;Drives the procurement orders for raw material.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Production Order&quot;&quot;&quot;" name="name"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'picking_except', 'confirmed', 'ready', 'in_production', 'cancel', 'done')&quot;&quot;&quot;" name="model_states"/>
             <field eval="1" name="flow_start"/>
         </record>
             <field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;The way to procurement depends on the product type.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Procure Products&quot;&quot;&quot;" name="name"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="0" name="flow_start"/>
         </record>
         
         <record id="process_node_minimumstockrule0" model="process.node">
             <field name="menu_id" ref="mrp.menu_action_orderpoint_form"/>
-            <field name="model_id" ref="mrp_procurement.model_stock_warehouse_orderpoint"/>
+            <field name="model_id" ref="procurement.model_stock_warehouse_orderpoint"/>
             <field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;Linked to the 'Minimum stock rule' supplying method.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Minimum Stock&quot;&quot;&quot;" name="name"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="1" name="flow_start"/>
         </record>
 
@@ -52,7 +52,7 @@
             <field eval="&quot;&quot;&quot;Product type is Stockable or Consumable.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Stockable Product&quot;&quot;&quot;" name="name"/>
             <field name="subflow_id" ref="process_process_stockableproductprocess0"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="0" name="flow_start"/>
         </record>
@@ -64,7 +64,7 @@
             <field eval="&quot;&quot;&quot;For stockable products and consumables&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Stockable Product&quot;&quot;&quot;" name="name"/>
             <field name="process_id" ref="mrp.process_process_stockableproductprocess0"/>
-            <field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="subflow_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="1" name="flow_start"/>
         </record>
@@ -76,7 +76,7 @@
             <field eval="&quot;&quot;&quot;Product type is service&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Service&quot;&quot;&quot;" name="name"/>
             <field name="subflow_id" ref="process_process_serviceproductprocess0"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="0" name="flow_start"/>
         </record>
@@ -88,7 +88,7 @@
             <field eval="&quot;&quot;&quot;For Services.&quot;&quot;&quot;" name="note"/>
             <field eval="&quot;&quot;&quot;Service&quot;&quot;&quot;" name="name"/>
             <field name="process_id" ref="mrp.process_process_serviceproductprocess0"/>
-            <field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="subflow_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'confirmed', 'cancel', 'exception', 'running', 'done', 'waiting')&quot;&quot;&quot;" name="model_states"/>
             <field eval="1" name="flow_start"/>
         </record>
             <field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;Procurement Orders&quot;&quot;&quot;" name="name"/>
             <field eval="&quot;&quot;&quot;For purchased material&quot;&quot;&quot;" name="note"/>
-            <field name="subflow_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="subflow_id" ref="procurement.process_process_procurementprocess0"/>
             <field name="process_id" ref="purchase.process_process_purchaseprocess0"/>
             <field eval="1" name="flow_start"/>
         </record>
 
         <record id="process_node_productminimumstockrule0" model="process.node">
             <field name="menu_id" ref="mrp.menu_action_orderpoint_form"/>
-            <field name="model_id" ref="mrp_procurement.model_stock_warehouse_orderpoint"/>
+            <field name="model_id" ref="procurement.model_stock_warehouse_orderpoint"/>
             <field eval="&quot;&quot;&quot;state&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;Minimum Stock&quot;&quot;&quot;" name="name"/>
             <field eval="&quot;&quot;&quot;Automatic procurement rule&quot;&quot;&quot;" name="note"/>
diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py
new file mode 100644 (file)
index 0000000..4ebd11f
--- /dev/null
@@ -0,0 +1,96 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from mx import DateTime
+from osv import fields
+from osv import osv
+from tools.translate import _
+import ir
+import netsvc
+import time
+
+class mrp_procurement(osv.osv):
+    _inherit = 'mrp.procurement'
+    _columns = {
+        'bom_id': fields.many2one('mrp.bom', 'BoM', ondelete='cascade', select=True),
+    }
+    
+    def check_produce_product(self, cr, uid, procurement, context=[]):
+        """ Finds the bill of material for the product from procurement order.
+        @return: True or False
+        """
+        properties = [x.id for x in procurement.property_ids]
+        bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, procurement.product_id.id, procurement.product_uom.id, properties)
+        if not bom_id:
+            cr.execute('update mrp_procurement set message=%s where id=%s', (_('No BoM defined for this product !'), procurement.id))
+            return False
+        return True
+    
+    def action_produce_assign_product(self, cr, uid, ids, context={}):
+        """ This is action which call from workflow to assign production order to procurements
+        @return: True
+        """
+        procurement_obj = self.pool.get('mrp.procurement')
+        res = procurement_obj.make_mo(cr, uid, ids, context=context)
+        res = res.values()
+        return len(res) and res[0] or 0 #TO CHECK: why workflow is generated error if return not integer value
+    
+    def make_mo(self, cr, uid, ids, context={}):
+        """ Make Manufacturing(production) order from procurement
+        @return: New created Production Orders procurement wise 
+        """
+        res = {}
+        company = self.pool.get('res.users').browse(cr, uid, uid, context).company_id
+        production_obj = self.pool.get('mrp.production')
+        move_obj = self.pool.get('stock.move')
+        wf_service = netsvc.LocalService("workflow")
+        procurement_obj = self.pool.get('mrp.procurement')
+        for procurement in procurement_obj.browse(cr, uid, ids):
+            res_id = procurement.move_id.id
+            loc_id = procurement.location_id.id
+            newdate = DateTime.strptime(procurement.date_planned, '%Y-%m-%d %H:%M:%S') - DateTime.RelativeDateTime(days=procurement.product_id.product_tmpl_id.produce_delay or 0.0)
+            newdate = newdate - DateTime.RelativeDateTime(days=company.manufacturing_lead)
+            produce_id = production_obj.create(cr, uid, {
+                'origin': procurement.origin,
+                'product_id': procurement.product_id.id,
+                'product_qty': procurement.product_qty,
+                'product_uom': procurement.product_uom.id,
+                'product_uos_qty': procurement.product_uos and procurement.product_uos_qty or False,
+                'product_uos': procurement.product_uos and procurement.product_uos.id or False,
+                'location_src_id': procurement.location_id.id,
+                'location_dest_id': procurement.location_id.id,
+                'bom_id': procurement.bom_id and procurement.bom_id.id or False,
+                'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
+                'move_prod_id': res_id,
+                'company_id': procurement.company_id.id,
+            })
+            res[procurement.id] = produce_id
+            self.write(cr, uid, [procurement.id], {'state': 'running'})
+            bom_result = production_obj.action_compute(cr, uid,
+                    [produce_id], properties=[x.id for x in procurement.property_ids])
+            wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)
+            move_obj.write(cr, uid, [res_id],
+                    {'location_id': procurement.location_id.id})
+        return res
+    
+mrp_procurement()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index d9a862f..497a813 100644 (file)
@@ -40,7 +40,7 @@
     
     """,
     'author': 'Tiny',
-    'depends': ['mrp_procurement'],
+    'depends': ['procurement'],
     'update_xml': ['mrp_jit.xml'],
     'demo_xml': [],
     'installable': True,
index bab0d62..99f74a1 100644 (file)
@@ -2,7 +2,7 @@
 <openerp>
 <data>
 
-    <record model="workflow.transition" id="mrp_procurement.trans_confirm_confirm_wait">
+    <record model="workflow.transition" id="procurement.trans_confirm_confirm_wait">
         <field name="signal" eval="False"/>
     </record>
 
diff --git a/addons/mrp_procurement/__init__.py b/addons/mrp_procurement/__init__.py
deleted file mode 100644 (file)
index 6cb8ad4..0000000
+++ /dev/null
@@ -1,25 +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/>.
-#
-##############################################################################
-
-import mrp_procurement
-import wizard
-import schedulers
-import company
\ No newline at end of file
diff --git a/addons/mrp_procurement/__openerp__.py b/addons/mrp_procurement/__openerp__.py
deleted file mode 100644 (file)
index 82c611c..0000000
+++ /dev/null
@@ -1,52 +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/>.
-#
-##############################################################################
-
-
-{
-    "name" : "Procurements",
-    "version" : "1.0",
-    "author" : "Tiny",
-    "website" : "http://www.openerp.com",
-    "category" : "Generic Modules/Production",
-    "depends" : ["base","process", "product", "stock"],
-    "description": """
-    This is the module for computing Procurements.
-    """,
-    'init_xml': [],
-    'update_xml': [
-        'security/ir.model.access.csv',
-        'security/mrp_procurement_security.xml',
-        'mrp_procurement_data.xml',
-        'wizard/make_procurement_view.xml',
-        'wizard/mrp_procurement_view.xml',
-        'wizard/orderpoint_procurement_view.xml',
-        'mrp_procurement_view.xml',
-        'wizard/schedulers_all_view.xml',
-        'mrp_procurement_workflow.xml',
-        'process/procurement_process.xml',
-        "company_view.xml",
-    ],
-#    'demo_xml': [],
-    'installable': True,
-    'active': False,
-    'certificate': '',
-}
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_procurement/company.py b/addons/mrp_procurement/company.py
deleted file mode 100644 (file)
index ce39ca9..0000000
+++ /dev/null
@@ -1,38 +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/>.
-#
-##############################################################################
-
-from osv import osv,fields
-
-class company(osv.osv):
-    _inherit = 'res.company'
-    _columns = {
-        'schedule_range': fields.float('Scheduler Range', required=True,
-            help="This is the time frame analysed by the scheduler when "\
-            "computing procurements. All procurements that are not between "\
-            "today and today+range are skipped for futur computation."),
-    }
-    _defaults = {
-        'schedule_range': lambda *a: 80.0,
-    }
-company()
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_procurement/company_view.xml b/addons/mrp_procurement/company_view.xml
deleted file mode 100644 (file)
index 543e36f..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" ?>
-<openerp>
-    <data>
-
-        <record id="mrp_company" model="ir.ui.view">
-            <field name="name">res.company.mrp.config</field>
-            <field name="model">res.company</field>
-            <field name="type">form</field>
-            <field name="inherit_id" ref="base.view_company_form"/>
-            <field name="arch" type="xml">
-                <page string="Configuration" position="inside">
-                    <separator string="MRP &amp; Logistic Scheduler" colspan="4"/>
-                    <field name="schedule_range"/>
-                </page>
-            </field>
-       </record>
-    
-    </data>
-</openerp>
\ No newline at end of file
diff --git a/addons/mrp_procurement/mrp_procurement.py b/addons/mrp_procurement/mrp_procurement.py
deleted file mode 100644 (file)
index ceaefb4..0000000
+++ /dev/null
@@ -1,524 +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/>.
-#
-##############################################################################
-
-from mx import DateTime
-from osv import osv, fields
-from tools.translate import _
-import netsvc
-import time
-
-
-class mrp_property_group(osv.osv):
-    """
-    Group of mrp properties.
-    """
-    _name = 'mrp.property.group'
-    _description = 'Property Group'
-    _columns = {
-        'name': fields.char('Property Group', size=64, required=True),
-        'description': fields.text('Description'),
-    }
-mrp_property_group()
-
-class mrp_property(osv.osv):
-    """
-    Properties of mrp.
-    """
-    _name = 'mrp.property'
-    _description = 'Property'
-    _columns = {
-        'name': fields.char('Name', size=64, required=True),
-        'composition': fields.selection([('min','min'),('max','max'),('plus','plus')], 'Properties composition', required=True, help="Not used in computations, for information purpose only."),
-        'group_id': fields.many2one('mrp.property.group', 'Property Group', required=True),
-        'description': fields.text('Description'),
-    }
-    _defaults = {
-        'composition': lambda *a: 'min',
-    }
-mrp_property()
-
-# ------------------------------------------------------------------
-# Procurement
-# ------------------------------------------------------------------
-#
-# Produce, Buy or Find products and place a move
-#     then wizard for picking lists & move
-#
-class mrp_procurement(osv.osv):
-    """
-    Procurement Orders
-    """
-    _name = "mrp.procurement"
-    _description = "Procurement"
-    _order = 'priority,date_planned desc'
-    _log_create = False
-    _columns = {
-        'name': fields.char('Reason', size=64, required=True, help='Procurement name.'),
-        'origin': fields.char('Source Document', size=64,
-            help="Reference of the document that created this Procurement.\n"
-            "This is automatically completed by Open ERP."),
-        'priority': fields.selection([('0','Not urgent'),('1','Normal'),('2','Urgent'),('3','Very Urgent')], 'Priority', required=True),
-        'date_planned': fields.datetime('Scheduled date', required=True),
-        'date_close': fields.datetime('Date Closed'),
-        'product_id': fields.many2one('product.product', 'Product', required=True, states={'draft':[('readonly',False)]}, readonly=True),
-        'product_qty': fields.float('Quantity', required=True, states={'draft':[('readonly',False)]}, readonly=True),
-        'product_uom': fields.many2one('product.uom', 'Product UoM', required=True, states={'draft':[('readonly',False)]}, readonly=True),
-        'product_uos_qty': fields.float('UoS Quantity', states={'draft':[('readonly',False)]}, readonly=True),
-        'product_uos': fields.many2one('product.uom', 'Product UoS', states={'draft':[('readonly',False)]}, readonly=True),
-        'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'),
-        'close_move': fields.boolean('Close Move at end', required=True),
-        'location_id': fields.many2one('stock.location', 'Location', required=True, states={'draft':[('readonly',False)]}, readonly=True),
-        'procure_method': fields.selection([('make_to_stock','from stock'),('make_to_order','on order')], 'Procurement Method', states={'draft':[('readonly',False)], 'confirmed':[('readonly',False)]},
-            readonly=True, required=True, help="If you encode manually a Procurement, you probably want to use" \
-            " a make to order method."),
-
-        'note': fields.text('Note'),
-
-        'property_ids': fields.many2many('mrp.property', 'mrp_procurement_property_rel', 'procurement_id','property_id', 'Properties'),
-
-        'message': fields.char('Latest error', size=64, help="Exception occurred while computing procurement orders."),
-        'state': fields.selection([
-            ('draft','Draft'),
-            ('confirmed','Confirmed'),
-            ('exception','Exception'),
-            ('running','Running'),
-            ('cancel','Cancel'),
-            ('ready','Ready'),
-            ('done','Done'),
-            ('waiting','Waiting')], 'State', required=True,
-            help='When a procurement is created the state is set to \'Draft\'.\n If the procurement is confirmed, the state is set to \'Confirmed\'.\
-            \nAfter confirming the state is set to \'Running\'.\n If any exception arises in the order then the state is set to \'Exception\'.\n Once the exception is removed the state becomes \'Ready\'.\n It is in \'Waiting\'. state when the procurement is waiting for another one to finish.'),
-        'note': fields.text('Note'),
-        'company_id': fields.many2one('res.company','Company',required=True),
-    }
-    _defaults = {
-        'state': lambda *a: 'draft',
-        'priority': lambda *a: '1',
-        'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
-        'close_move': lambda *a: 0,
-        'procure_method': lambda *a: 'make_to_order',
-        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.procurement', context=c)
-    }
-
-    def unlink(self, cr, uid, ids, context=None):
-        procurements = self.read(cr, uid, ids, ['state'])
-        unlink_ids = []
-        for s in procurements:
-            if s['state'] in ['draft','cancel']:
-                unlink_ids.append(s['id'])
-            else:
-                raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
-        return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
-
-    def onchange_product_id(self, cr, uid, ids, product_id, context={}):
-        """ Finds UoM and UoS of changed product.
-        @param product_id: Changed id of product.
-        @return: Dictionary of values.
-        """
-        if product_id:
-            w = self.pool.get('product.product').browse(cr, uid, product_id, context)
-            v = {
-                'product_uom': w.uom_id.id,
-                'product_uos': w.uos_id and w.uos_id.id or w.uom_id.id
-            }
-            return {'value': v}
-        return {}
-
-    def check_product(self, cr, uid, ids):
-        """ Checks product type.
-        @return: True or False
-        """
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.product_id.type in ('product', 'consu'):
-                return True
-        return False
-
-    def check_move_cancel(self, cr, uid, ids, context={}):
-        """ Checks if move is cancelled or not.
-        @return: True or False.
-        """
-        res = True
-        ok = False
-        for procurement in self.browse(cr, uid, ids, context):
-            if procurement.move_id:
-                ok = True
-                if not procurement.move_id.state == 'cancel':
-                    res = False
-        return res and ok
-
-    def check_move_done(self, cr, uid, ids, context={}):
-        """ Checks if move is done or not.
-        @return: True or False.
-        """
-        res = True
-        for proc in self.browse(cr, uid, ids, context):
-            if proc.move_id:
-                if not proc.move_id.state == 'done':
-                    res = False
-        return res
-
-    #
-    # This method may be overrided by objects that override mrp.procurment
-    # for computing their own purpose
-    #
-    def _quantity_compute_get(self, cr, uid, proc, context={}):
-        """ Finds sold quantity of product.
-        @param proc: Current procurement.
-        @return: Quantity or False.
-        """
-        if proc.product_id.type == 'product':
-            if proc.move_id.product_uos:
-                return proc.move_id.product_uos_qty
-        return False
-
-    def _uom_compute_get(self, cr, uid, proc, context={}):
-        """ Finds UoS if product is Stockable Product.
-        @param proc: Current procurement.
-        @return: UoS or False.
-        """
-        if proc.product_id.type == 'product':
-            if proc.move_id.product_uos:
-                return proc.move_id.product_uos.id
-        return False
-
-    #
-    # Return the quantity of product shipped/produced/served, wich may be
-    # different from the planned quantity
-    #
-    def quantity_get(self, cr, uid, id, context={}):
-        """ Finds quantity of product used in procurement.
-        @return: Quantity of product.
-        """
-        proc = self.browse(cr, uid, id, context)
-        result = self._quantity_compute_get(cr, uid, proc, context)
-        if not result:
-            result = proc.product_qty
-        return result
-
-    def uom_get(self, cr, uid, id, context=None):
-        """ Finds UoM of product used in procurement.
-        @return: UoM of product.
-        """
-        proc = self.browse(cr, uid, id, context)
-        result = self._uom_compute_get(cr, uid, proc, context)
-        if not result:
-            result = proc.product_uom.id
-        return result
-
-    def check_waiting(self, cr, uid, ids, context=[]):
-        """ Checks state of move.
-        @return: True or False
-        """
-        for procurement in self.browse(cr, uid, ids, context=context):
-            if procurement.move_id and procurement.move_id.state == 'auto':
-                return True
-        return False
-
-    def check_produce_service(self, cr, uid, procurement, context=[]):
-        return True
-
-    def check_produce_product(self, cr, uid, procurement, context=[]):
-        """ Finds BoM of a product if not found writes exception message.
-        @param procurement: Current procurement.
-        @return: True or False.
-        """
-        return True
-
-    def check_make_to_stock(self, cr, uid, ids, context={}):
-        """ Checks product type.
-        @return: True or False
-        """
-        ok = True
-        for procurement in self.browse(cr, uid, ids, context=context):
-            if procurement.product_id.type == 'service':
-                ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context)
-            else:
-                ok = ok and self._check_make_to_stock_product(cr, uid, procurement, context)
-        return ok
-
-    def check_produce(self, cr, uid, ids, context={}):
-        """ Checks product type.
-        @return: True or Product Id.
-        """
-        res = True
-        user = self.pool.get('res.users').browse(cr, uid, uid)
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.product_id.product_tmpl_id.supply_method <> 'produce':
-                if procurement.product_id.seller_ids:
-                    partner = procurement.product_id.seller_ids[0].name
-                    if user.company_id and user.company_id.partner_id:
-                        if partner.id == user.company_id.partner_id.id:
-                            return True
-                return False
-            if procurement.product_id.product_tmpl_id.type=='service':
-                res = res and self.check_produce_service(cr, uid, procurement, context)
-            else:
-                res = res and self.check_produce_product(cr, uid, procurement, context)
-            if not res:
-                return False
-        return res
-
-    def check_buy(self, cr, uid, ids):
-        """ Checks product type.
-        @return: True or Product Id.
-        """
-        user = self.pool.get('res.users').browse(cr, uid, uid)
-        partner_obj = self.pool.get('res.partner')
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
-                return False
-            if not procurement.product_id.seller_ids:
-                cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id))
-                return False
-            partner = procurement.product_id.seller_ids[0].name
-            if user.company_id and user.company_id.partner_id:
-                if partner.id == user.company_id.partner_id.id:
-                    return False
-            address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
-            if not address_id:
-                cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id))
-                return False
-        return True
-
-    def test_cancel(self, cr, uid, ids):
-        """ Tests whether state of move is cancelled or not.
-        @return: True or False
-        """
-        for record in self.browse(cr, uid, ids):
-            if record.move_id and record.move_id.state == 'cancel':
-                return True
-        return False
-
-    def action_confirm(self, cr, uid, ids, context={}):
-        """ Confirms procurement and writes exception message if any.
-        @return: True
-        """
-        move_obj = self.pool.get('stock.move')
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.product_qty <= 0.00:
-                raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity of Procurement Order(s), it should not be less than 1!'))
-            if procurement.product_id.type in ('product', 'consu'):
-                if not procurement.move_id:
-                    source = procurement.location_id.id
-                    if procurement.procure_method == 'make_to_order':
-                        source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
-                    id = move_obj.create(cr, uid, {
-                        'name': 'PROC:' + procurement.name,
-                        'location_id': source,
-                        'location_dest_id': procurement.location_id.id,
-                        'product_id': procurement.product_id.id,
-                        'product_qty': procurement.product_qty,
-                        'product_uom': procurement.product_uom.id,
-                        'date_planned': procurement.date_planned,
-                        'state': 'draft',
-                        'company_id': procurement.company_id.id,
-                    })
-                    move_obj.action_confirm(cr, uid, [id], context=context)
-                    self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
-        self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
-        return True
-
-    def action_move_assigned(self, cr, uid, ids, context={}):
-        """ Changes procurement state to Running and writes message.
-        @return: True
-        """
-        self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')})
-        return True
-
-    def _check_make_to_stock_service(self, cr, uid, procurement, context={}):
-        return True
-
-    def _check_make_to_stock_product(self, cr, uid, procurement, context={}):
-        """ Checks procurement move state.
-        @param procurement: Current procurement.
-        @return: True or move id.
-        """
-        ok = True
-        if procurement.move_id:
-            id = procurement.move_id.id
-            if not (procurement.move_id.state in ('done','assigned','cancel')):
-                ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
-                cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
-                if not cr.fetchone()[0]:
-                    cr.execute('update mrp_procurement set message=%s where id=%s', (_('Stock is not enough and No minimum orderpoint rule defined'), procurement.id))
-        return ok
-
-    def action_produce_assign_service(self, cr, uid, ids, context={}):
-        """ Changes procurement state to Running.
-        @return: True
-        """
-        for procurement in self.browse(cr, uid, ids):
-            self.write(cr, uid, [procurement.id], {'state': 'running'})
-        return True
-
-    def action_produce_assign_product(self, cr, uid, ids, context={}):
-        """ This is action which call from workflow to assign production order to procurements
-        @return: True
-        """
-        return 0
-
-
-    def action_po_assign(self, cr, uid, ids, context={}):
-        """ This is action which call from workflow to assign purchase order to procurements
-        @return: True
-        """
-        return 0
-
-    def action_cancel(self, cr, uid, ids):
-        """ Cancels procurement and writes move state to Assigned.
-        @return: True
-        """
-        todo = []
-        todo2 = []
-        move_obj = self.pool.get('stock.move')
-        for proc in self.browse(cr, uid, ids):
-            if proc.close_move:
-                if proc.move_id.state not in ('done', 'cancel'):
-                    todo2.append(proc.move_id.id)
-            else:
-                if proc.move_id and proc.move_id.state == 'waiting':
-                    todo.append(proc.move_id.id)
-        if len(todo2):
-            move_obj.action_cancel(cr, uid, todo2)
-        if len(todo):
-            move_obj.write(cr, uid, todo, {'state': 'assigned'})
-        self.write(cr, uid, ids, {'state': 'cancel'})
-        wf_service = netsvc.LocalService("workflow")
-        for id in ids:
-            wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
-        return True
-
-    def action_check_finnished(self, cr, uid, ids):
-        return self.check_move_done(cr, uid, ids)
-
-    def action_check(self, cr, uid, ids):
-        """ Checks procurement move state whether assigned or done.
-        @return: True
-        """
-        ok = False
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
-                self.action_done(cr, uid, [procurement.id])
-                ok = True
-        return ok
-
-    def action_ready(self, cr, uid, ids):
-        """ Changes procurement state to Ready.
-        @return: True
-        """
-        res = self.write(cr, uid, ids, {'state': 'ready'})
-        return res
-
-    def action_done(self, cr, uid, ids):
-        """ Changes procurement state to Done and writes Closed date.
-        @return: True
-        """
-        move_obj = self.pool.get('stock.move')
-        for procurement in self.browse(cr, uid, ids):
-            if procurement.move_id:
-                if procurement.close_move and (procurement.move_id.state <> 'done'):
-                    move_obj.action_done(cr, uid, [procurement.move_id.id])
-        res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
-        wf_service = netsvc.LocalService("workflow")
-        for id in ids:
-            wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
-        return res
-
-    def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
-        ''' Runs through scheduler.
-        @param use_new_cursor: False or the dbname
-        '''
-        if not context:
-            context={}
-        self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
-        self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
-                use_new_cursor=use_new_cursor, context=context)
-
-mrp_procurement()
-
-
-class stock_warehouse_orderpoint(osv.osv):
-    """
-    Defines Minimum stock rules.
-    """
-    _name = "stock.warehouse.orderpoint"
-    _description = "Orderpoint minimum rule"
-
-    _columns = {
-        'name': fields.char('Name', size=32, required=True),
-        'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
-        'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True),
-        'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
-        'location_id': fields.many2one('stock.location', 'Location', required=True),
-        'product_id': fields.many2one('product.product', 'Product', required=True, ondelete='cascade', domain=[('type','=','product')]),
-        'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ),
-        'product_min_qty': fields.float('Min Quantity', required=True,
-            help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
-            "a procurement to bring the virtual stock to the Max Quantity."),
-        'product_max_qty': fields.float('Max Quantity', required=True,
-            help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
-            "a procurement to bring the virtual stock to the Max Quantity."),
-        'qty_multiple': fields.integer('Qty Multiple', required=True,
-            help="The procurement quantity will by rounded up to this multiple."),
-        'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement'),
-        'company_id': fields.many2one('res.company','Company',required=True),
-    }
-    _defaults = {
-        'active': lambda *a: 1,
-        'logic': lambda *a: 'max',
-        'qty_multiple': lambda *a: 1,
-        'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '',
-        'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
-        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
-    }
-
-    def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
-        """ Finds location id for changed warehouse.
-        @param warehouse_id: Changed id of warehouse.
-        @return: Dictionary of values.
-        """
-        if warehouse_id:
-            w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context)
-            v = {'location_id': w.lot_stock_id.id}
-            return {'value': v}
-        return {}
-
-    def onchange_product_id(self, cr, uid, ids, product_id, context={}):
-        """ Finds UoM for changed product.
-        @param product_id: Changed id of product.
-        @return: Dictionary of values.
-        """
-        if product_id:
-            prod = self.pool.get('product.product').browse(cr,uid,product_id)
-            v = {'product_uom': prod.uom_id.id}
-            return {'value': v}
-        return {}
-
-    def copy(self, cr, uid, id, default=None,context={}):
-        if not default:
-            default = {}
-        default.update({
-            'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '',
-        })
-        return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
-
-stock_warehouse_orderpoint()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_procurement/mrp_procurement_data.xml b/addons/mrp_procurement/mrp_procurement_data.xml
deleted file mode 100644 (file)
index 256472b..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data noupdate="1">
-        
-        <record forcecreate="True" id="ir_cron_scheduler_action" model="ir.cron">
-            <field name="name">Run mrp scheduler</field>
-            <field eval="False" name="active"/>
-            <field name="user_id" ref="base.user_root"/>
-            <field name="interval_number">1</field>
-            <field name="interval_type">days</field>
-            <field name="numbercall">-1</field>
-            <field eval="False" name="doall"/>
-            <field eval="'mrp.procurement'" name="model"/>
-            <field eval="'run_scheduler'" name="function"/>
-            <field eval="'(False,)'" name="args"/>
-        </record>
-        
-    </data>
-</openerp>
\ No newline at end of file
diff --git a/addons/mrp_procurement/mrp_procurement_view.xml b/addons/mrp_procurement/mrp_procurement_view.xml
deleted file mode 100644 (file)
index 1defa21..0000000
+++ /dev/null
@@ -1,271 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-       <data>
-               <!--
-        Procurement
-        -->
-
-        <record id="mrp_procurement_tree_view" model="ir.ui.view">
-            <field name="name">mrp.procurement.tree</field>
-            <field name="model">mrp.procurement</field>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <tree string="Procurement Lines" colors="red:date_planned&lt;current_date and state in ('exception');black:state=='running';green:state=='confirmed';gray:state in ['done','cancel'];blue:state in ('ready')">
-                    <field name="date_planned" widget="date"/>
-                    <field name="origin"/>
-                    <field name="product_id"/>
-                    <field name="product_qty"/>
-                    <field name="product_uom" string="UOM"/>
-                    <field name="procure_method"/>
-                    <field name="state"/>
-                    <field name="message"/>
-                </tree>
-            </field>
-        </record>
-        <record id="mrp_procurement_form_view" model="ir.ui.view">
-            <field name="name">mrp.procurement.form</field>
-            <field name="model">mrp.procurement</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Procurement">
-                    <group col="2" colspan="2">
-                        <separator colspan="2" string="References"/>
-                        <field name="name" string="Procurement Reason"/>
-                        <field name="origin"/>
-                        <field name="company_id" groups="base.group_multi_company" widget="selection"/>
-                    </group>
-                    <group col="2" colspan="2">
-                        <separator colspan="2" string="Planification"/>
-                        <field name="date_planned"/>
-                        <field name="procure_method"/>
-                        <field name="priority" groups="base.group_extended"/>
-                    </group>
-                    <notebook colspan="4">
-                    <page string="Procurement Details">
-                        <separator colspan="4" string="Product &amp; Location"/>
-                        <field name="product_id" on_change="onchange_product_id(product_id)"/>
-                        <field name="location_id" domain="[('usage','=','internal')]"/>
-                        <field name="product_qty"/>
-                        <field name="product_uom" widget="selection"/>
-
-                        <field name="product_uos_qty" groups="product.group_uos,base.group_extended"/>
-                        <field name="product_uos" widget="selection" groups="product.group_uos,base.group_extended"/>
-
-                        <separator colspan="4" string="Status"/>
-                        <field colspan="4" name="message" readonly="1"/>
-                        <field name="state" readonly="1"/>
-                        <group col="7" colspan="2">
-                            <button name="button_confirm" states="draft" string="Confirm" icon="gtk-apply"/>
-                            <button name="button_restart" states="exception" string="Retry" icon="gtk-convert"/>
-                            <button name="button_cancel" states="draft,exception,waiting" string="Cancel" icon="gtk-cancel"/>
-                            <button name="button_check" states="confirmed" string="Run     Procurement" icon="gtk-media-play"/>
-                        </group>
-                    </page>
-                    <page string="Extra Information">
-                        <separator colspan="4" string="Details"/>
-                        <field name="move_id" groups="base.group_extended"/>
-                        <field name="date_close"/>
-                        <field name="close_move" groups="base.group_extended"/>
-                                               <group colspan="4"  groups="base.group_extended">
-                               <separator colspan="4" string="Properties" />
-                               <field colspan="4" name="property_ids" nolabel="1"/>
-                           </group>
-                    </page>
-                    <page string="Notes">
-                        <separator colspan="4" string="Note" />
-                        <field name="note" colspan="4" nolabel="1"/>
-                    </page>
-                    </notebook>
-                </form>
-            </field>
-        </record>
-        <record id="view_mrp_procurement_filter" model="ir.ui.view">
-            <field name="name">mrp.procurement.select</field>
-            <field name="model">mrp.procurement</field>
-            <field name="type">search</field>
-            <field name="arch" type="xml">
-                <search string="Search Procurement">
-                    <group col='10' colspan='4'>
-                       <filter icon="terp-mrp" string="Current" domain="[('state','in',('draft','confirmed'))]" name="current" help="Procurement Orders in draft or open state."/>
-                       <filter icon="terp-mrp" string="Exceptions" domain="[('state','=','exception')]" help="Procurement Orders with exceptions"/>
-                       <filter icon="terp-mrp" string="Late"
-                           domain="['&amp;', ('date_planned::date','&lt;', current_date), ('state', 'in', ('draft', 'confirmed'))]"
-                           help="Procurement started late" />
-                       <filter icon="terp-mrp" string="To Fix" domain="[('state', '=', 'exception'),('message','=','')]" help="Procurement Orders with exceptions and without message"/>
-                       <separator orientation="vertical"/>
-                       <field name="name"/>
-                       <field name="origin"/>
-                       <field name="product_id" />
-                       <field name="date_planned" widget="date"/>
-                       <field name="state" />
-                    </group>
-                    <newline/>
-                    <group expand="1" string="Group By" colspan="4" col="8" groups="base.group_extended">
-                        <filter string="Product" icon="terp-mrp" domain="[]" context="{'group_by':'product_id'}"/>
-                        <filter string="Reason" icon="terp-mrp" domain="[]" context="{'group_by':'name'}"/>
-                        <filter string="Scheduled Date" icon="terp-mrp" domain="[]" context="{'group_by':'date_planned'}"/>
-                       <filter string="State" icon="terp-mrp" domain="[]" context="{'group_by':'state'}"/>
-                    </group>
-                </search>
-            </field>
-        </record>
-        <record id="mrp_procurement_action" model="ir.actions.act_window">
-            <field name="name">Procurement Orders</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">mrp.procurement</field>
-            <field name="view_type">form</field>
-            <field name="view_id" eval="False"/>
-            <field name="context">{'search_default_current':1}</field>
-            <field name="search_view_id" ref="view_mrp_procurement_filter"/>
-            <field name="context">{'search_default_Current':1}</field>
-        </record>
-
-        <record id="mrp_procurement_action3" model="ir.actions.act_window">
-            <field name="name">Procurements</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">mrp.procurement</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-            <field name="search_view_id" ref="view_mrp_procurement_filter"/>
-            <field name="domain">[]</field>
-            <field name="context">{}</field>
-        </record>
-
-        <record id="mrp_procurement_action5" model="ir.actions.act_window">
-            <field name="name">Procurement Exceptions</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">mrp.procurement</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-            <field name="domain">[('state','=','exception')]</field>
-        </record>
-
-        <record id="mrp_procurement_action4" model="ir.actions.act_window">
-            <field name="name">Procurement Exceptions to Fix</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">mrp.procurement</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-            <field name="domain">[('state','=','exception'), ('message', '&lt;&gt;', '')]</field>
-            <field name="filter" eval="True"/>
-        </record>
-
-        <record id="mrp_procurement_action11" model="ir.actions.act_window">
-            <field name="name">Temporary Procurement Exceptions</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="res_model">mrp.procurement</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-            <field name="domain">[('state','=','exception'), ('message', '=', '')]</field>
-        </record>
-
-        <!-- Order Point -->
-        <record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
-            <field name="name">stock.warehouse.orderpoint.tree</field>
-            <field name="model">stock.warehouse.orderpoint</field>
-            <field name="type">tree</field>
-            <field name="arch" type="xml">
-                <tree string="Minimum Stock Rules">
-                    <field name="name"/>
-                    <field name="warehouse_id"/>
-                    <field name="location_id"/>
-                    <field name="product_id"/>
-                    <field name="product_uom"/>
-                    <field name="product_min_qty"/>
-                    <field name="product_max_qty"/>
-                </tree>
-            </field>
-        </record>
-
-        <record model="ir.ui.view" id="warehouse_orderpoint_search">
-            <field name="name">stock.warehouse.orderpoint.search</field>
-            <field name="model">stock.warehouse.orderpoint</field>
-            <field name="type">search</field>
-            <field name="arch" type="xml">
-                <search string="Minimum Stock Rules Search">
-                    <group col="10" colspan="4">
-                        <field name="name"/>
-                        <field name="warehouse_id" widget="selection"/>
-                        <field name="location_id"/>
-                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
-                        <field name="product_id"/>
-                    </group>
-                    <newline/>
-                    <group expand="1" string="Group By..." colspan="4" col="10">
-                        <filter string="Warehouse" icon="terp-stock" domain="[]"  context="{'group_by':'warehouse_id'}"/>
-                        <filter string="Location" icon="terp-stock" domain="[]" context="{'group_by':'location_id'}"/>
-                    </group>
-                </search>
-            </field>
-        </record>
-
-        <record id="view_warehouse_orderpoint_form" model="ir.ui.view">
-            <field name="name">stock.warehouse.orderpoint.form</field>
-            <field name="model">stock.warehouse.orderpoint</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Minimum Stock Rules">
-                    <group col="2" colspan="2">
-                        <separator string="General Information" colspan="2" />
-                        <field name="name" />
-                        <field name="product_id" on_change="onchange_product_id(product_id)"/>
-                        <field name="product_uom"/>
-                    </group>
-                    <group col="2" colspan="2">
-                        <separator string="Locations" colspan="2" />
-                        <field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
-                        <field name="location_id"/>
-                        <field name="company_id" groups="base.group_multi_company" widget="selection"/>
-                    </group>
-                    <group col="2" colspan="2">
-                        <separator string="Quantity Rules" colspan="2" />
-                        <field name="product_min_qty"/>
-                        <field name="product_max_qty"/>
-                        <field name="qty_multiple"/>
-                    </group>
-                    <group col="2" colspan="2" groups="base.group_extended">
-                        <separator string="Misc" colspan="2" />
-                        <field name="procurement_id" readonly="1"/>
-                        <field name="active" />
-                    </group>
-                </form>
-            </field>
-        </record>
-
-        <record id="action_orderpoint_form" model="ir.actions.act_window">
-            <field name="name">Minimum Stock Rules</field>
-            <field name="res_model">stock.warehouse.orderpoint</field>
-            <field name="type">ir.actions.act_window</field>
-            <field name="view_type">form</field>
-            <field name="view_id" ref="view_warehouse_orderpoint_tree"/>
-            <field name="search_view_id" ref="warehouse_orderpoint_search" />
-        </record>
-
-        <act_window domain="[('warehouse_id', '=', active_id)]" id="act_stock_warehouse_2_stock_warehouse_orderpoint" name="Minimum Stock Rules" res_model="stock.warehouse.orderpoint" src_model="stock.warehouse"/>
-
-        <!-- add product_uom to context to be the default value when adding new orderpoints -->
-        <act_window
-            context="{'product_uom': locals().has_key('uom_id') and uom_id}"
-            domain="[('product_id', '=', active_id)]"
-            id="act_product_product_2_stock_warehouse_orderpoint"
-            name="Minimum Stock Rules"
-            res_model="stock.warehouse.orderpoint"
-            src_model="product.product"/>
-
-        <act_window
-            context="{'product_uom': locals().has_key('uom_id') and uom_id}"
-            domain="[('product_id', '=', active_id)]"
-            id="act_mrp_procurement_2_stock_warehouse_orderpoint"
-            name="Minimum Stock Rules"
-            res_model="stock.warehouse.orderpoint"
-            src_model="mrp.procurement"/>
-
-        <act_window
-            domain="[('id', '=', product_id)]"
-            id="act_product_product_2_stock_warehouse_orderpoint"
-            name="Product"
-            res_model="product.product"
-            src_model="mrp.procurement"/>
-
-    </data>
-</openerp>
diff --git a/addons/mrp_procurement/mrp_procurement_workflow.xml b/addons/mrp_procurement/mrp_procurement_workflow.xml
deleted file mode 100644 (file)
index 599d11c..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-
-        <record id="wkf_procurement" model="workflow">
-            <field name="name">mrp.procurement.basic</field>
-            <field name="osv">mrp.procurement</field>
-            <field name="on_create">True</field>
-        </record>
-
-        <record id="act_draft" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="flow_start">True</field>
-            <field name="name">draft</field>
-        </record>
-        <record id="act_cancel" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">cancel</field>
-            <field name="kind">function</field>
-            <field name="action">action_cancel()</field>
-            <field name="flow_stop">True</field>
-        </record>
-        <record id="act_confirm" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">confirm</field>
-            <field name="kind">function</field>
-            <field name="action">action_confirm()</field>
-        </record>
-        <record id="act_confirm_wait" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">confirm_wait</field>
-            <field name="kind">function</field>
-            <field name="action">write({'state':'exception'})</field>
-        </record>
-        <record id="act_confirm_mts" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">confirm_mts</field>
-        </record>
-        <record id="act_confirm_mto" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">confirm_mto</field>
-        </record>
-        <record id="act_make_to_stock" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">make_to_stock</field>
-            <field name="kind">function</field>
-            <field name="action">action_move_assigned()</field>
-        </record>
-        <record id="act_produce_check" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">produce_check</field>
-        </record>
-        <record id="act_produce_service" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">produce_service</field>
-            <field name="kind">function</field>
-            <field name="action">action_produce_assign_service()</field>
-        </record>
-        <record id="act_make_done" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">ready</field>
-            <field name="kind">function</field>
-            <field name="action">action_ready()</field>
-        </record>
-        <record id="act_wait_done" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="name">wait_done</field>
-            <field name="kind">function</field>
-            <field name="action">write({'state':'waiting'})</field>
-        </record>
-
-        <record id="act_done" model="workflow.activity">
-            <field name="wkf_id" ref="wkf_procurement"/>
-            <field name="flow_stop">True</field>
-            <field name="name">done</field>
-            <field name="kind">function</field>
-            <field name="action">action_done()</field>
-        </record>
-
-        <record id="trans_draft_confirm" model="workflow.transition">
-            <field name="act_from" ref="act_draft"/>
-            <field name="act_to" ref="act_confirm"/>
-            <field name="signal">button_confirm</field>
-        </record>
-        <record id="trans_confirm_cancel2" model="workflow.transition">
-            <field name="act_from" ref="act_confirm"/>
-            <field name="act_to" ref="act_wait_done"/>
-            <field name="signal">button_wait_done</field>
-            <field name="condition">True</field>
-        </record>
-        <record id="trans_confirm_wait_done" model="workflow.transition">
-            <field name="act_from" ref="act_wait_done"/>
-            <field name="act_to" ref="act_done"/>
-            <field name="condition">check_move_done()</field>
-            <field name="trigger_model">stock.move</field>
-            <field name="trigger_expr_id">[move_id.id]</field>
-        </record>
-
-        <record id="trans_confirm_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_confirm"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">button_check</field>
-            <field name="condition">test_cancel()</field>
-        </record>
-        <record id="trans_confirm_confirm_wait" model="workflow.transition">
-            <field name="act_from" ref="act_confirm"/>
-            <field name="act_to" ref="act_confirm_wait"/>
-            <field name="signal">button_check</field>
-            <field name="condition">not test_cancel()</field>
-        </record>
-        <record id="trans_confirm_wait_confirm_mto" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_wait"/>
-            <field name="act_to" ref="act_confirm_mto"/>
-            <field name="condition">procure_method=='make_to_order'</field>
-        </record>
-        <record id="trans_confirm_wait_confirm_mts" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_wait"/>
-            <field name="act_to" ref="act_confirm_mts"/>
-            <field name="condition">procure_method=='make_to_stock'</field>
-        </record>
-        <record id="trans_confirm_mts_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mts"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">button_cancel</field>
-        </record>
-        <record id="trans_confirm_waiting_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_wait_done"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">button_cancel</field>
-        </record>
-        <record id="trans_confirm_mts_confirm" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mts"/>
-            <field name="act_to" ref="act_confirm"/>
-            <field name="signal">button_restart</field>
-        </record>
-        <record id="trans_confirm_mto_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mto"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">button_cancel</field>
-        </record>
-        <record id="trans_confirm_mto_confirm" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mto"/>
-            <field name="act_to" ref="act_confirm"/>
-            <field name="signal">button_restart</field>
-        </record>
-        <record id="trans_draft_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_draft"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">button_cancel</field>
-        </record>
-        <record id="trans_confirm_mts_make_to_stock" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mts"/>
-            <field name="act_to" ref="act_make_to_stock"/>
-            <field name="condition">check_make_to_stock()</field>
-        </record>
-        <record id="trans_confirm_mto_produce_check" model="workflow.transition">
-            <field name="act_from" ref="act_confirm_mto"/>
-            <field name="act_to" ref="act_produce_check"/>
-            <field name="condition">check_produce()</field>
-        </record>
-        <record id="trans_product_check_produce_service" model="workflow.transition">
-            <field name="act_from" ref="act_produce_check"/>
-            <field name="act_to" ref="act_produce_service"/>
-            <field name="condition">not check_product()</field>
-        </record>
-        <record id="trans_make_to_stock_make_done" model="workflow.transition">
-            <field name="act_from" ref="act_make_to_stock"/>
-            <field name="act_to" ref="act_make_done"/>
-            <field name="condition">True</field>
-            <field name="trigger_model" eval="False"/>
-            <field name="trigger_expr_id" eval="False"/>
-        </record>
-        <record id="trans_produce_service_cancel" model="workflow.transition">
-            <field name="act_from" ref="act_produce_service"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="signal">subflow.cancel</field>
-        </record>
-        <record id="trans_produce_service_make_done" model="workflow.transition">
-            <field name="act_from" ref="act_produce_service"/>
-            <field name="act_to" ref="act_make_done"/>
-        </record>
-        <record id="trans_make_done_done" model="workflow.transition">
-            <field name="act_from" ref="act_make_done"/>
-            <field name="act_to" ref="act_done"/>
-            <field name="condition">action_check_finnished()</field>
-        </record>
-        <record id="trans_make_done_confirm" model="workflow.transition">
-            <field name="act_from" ref="act_make_done"/>
-            <field name="act_to" ref="act_cancel"/>
-            <field name="condition">check_move_cancel()</field>
-        </record>
-    
-    </data>
-</openerp>
diff --git a/addons/mrp_procurement/process/procurement_process.xml b/addons/mrp_procurement/process/procurement_process.xml
deleted file mode 100644 (file)
index 21f953c..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" ?>
-<openerp>
-    <data>
-
-        <!--
-            Process
-        -->
-
-        <record id="process_process_procurementprocess0" model="process.process">
-            <field eval="&quot;&quot;&quot;Procurement&quot;&quot;&quot;" name="name"/>
-            <field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
-            <field eval="1" name="active"/>
-        </record>
-
-        <!--
-            Process Node
-        -->
-
-        
-    </data>
-</openerp>
diff --git a/addons/mrp_procurement/schedulers.py b/addons/mrp_procurement/schedulers.py
deleted file mode 100644 (file)
index 6ebc0f6..0000000
+++ /dev/null
@@ -1,242 +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/>.
-#
-##############################################################################
-
-from osv import osv
-import netsvc
-import pooler
-from mx import DateTime
-import time
-
-
-class mrp_procurement(osv.osv):
-    _inherit = 'mrp.procurement'
-
-    def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, context=None):
-        '''
-        use_new_cursor: False or the dbname
-        '''
-        if not context:
-            context = {}
-
-        if use_new_cursor:
-            cr = pooler.get_db(use_new_cursor).cursor()
-        wf_service = netsvc.LocalService("workflow")
-
-        procurement_obj = self.pool.get('mrp.procurement')
-        if not ids:
-            ids = procurement_obj.search(cr, uid, [], order="date_planned")
-        for id in ids:
-            wf_service.trg_validate(uid, 'mrp.procurement', id, 'button_restart', cr)
-        if use_new_cursor:
-            cr.commit()
-
-        company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
-        maxdate = DateTime.now() + DateTime.RelativeDateTime(days=company.schedule_range)
-        start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
-        offset = 0
-        report = []
-        report_total = 0
-        report_except = 0
-        report_later = 0
-        while True:
-            cr.execute('select id from mrp_procurement where state=%s and procure_method=%s order by priority,date_planned limit 500 offset %s', ('confirmed', 'make_to_order', offset))
-            ids = map(lambda x: x[0], cr.fetchall())
-            for proc in procurement_obj.browse(cr, uid, ids):
-                if (maxdate.strftime('%Y-%m-%d') >= proc.date_planned):
-                    wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr)
-                else:
-                    offset += 1
-                    report_later += 1
-            for proc in procurement_obj.browse(cr, uid, ids):
-                if proc.state == 'exception':
-                    report.append('PROC %d: on order - %3.2f %-5s - %s' % \
-                            (proc.id, proc.product_qty, proc.product_uom.name,
-                                proc.product_id.name))
-                    report_except += 1
-                report_total += 1
-            if use_new_cursor:
-                cr.commit()
-            if not ids:
-                break
-
-        offset = 0
-        ids = []
-        while True:
-            report_ids = []
-            ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_stock')], offset=offset)
-            for proc in procurement_obj.browse(cr, uid, ids):
-                if ((maxdate).strftime('%Y-%m-%d') >= proc.date_planned) :
-                    wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr)
-                    report_ids.append(proc.id)
-                else:
-                    report_later += 1
-                report_total += 1
-            for proc in procurement_obj.browse(cr, uid, report_ids):
-                if proc.state == 'exception':
-                    report.append('PROC %d: from stock - %3.2f %-5s - %s' % \
-                            (proc.id, proc.product_qty, proc.product_uom.name,
-                                proc.product_id.name,))
-                    report_except += 1
-            if use_new_cursor:
-                cr.commit()
-            offset += len(ids)
-            if not ids: break
-        end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
-        if uid:
-            request = self.pool.get('res.request')
-            summary = '''Here is the procurement scheduling report.
-
-    Computation Started; %s
-    Computation Finished; %s
-
-    Total procurement: %d
-    Exception procurement: %d
-    Not run now procurement: %d
-
-    Exceptions;
-    '''% (start_date, end_date, report_total, report_except, report_later)
-            summary += '\n'.join(report)
-            request.create(cr, uid,
-                {'name': "Procurement calculation report.",
-                    'act_from': uid,
-                    'act_to': uid,
-                    'body': summary,
-                })
-        if use_new_cursor:
-            cr.commit()
-            cr.close()
-        return {}
-
-    def create_automatic_op(self, cr, uid, context=None):
-        if not context:
-            context = {}
-        product_obj = self.pool.get('product.product')
-        proc_obj = self.pool.get('mrp.procurement')
-        warehouse_obj = self.pool.get('stock.warehouse')
-        wf_service = netsvc.LocalService("workflow")
-
-        warehouse_ids = warehouse_obj.search(cr, uid, [], context=context)
-
-        cr.execute('select id from product_product')
-        products_id = [x for x, in cr.fetchall()]
-
-        for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context):
-            context['warehouse'] = warehouse
-            for product in product_obj.browse(cr, uid, products_id, context=context):
-                if product.virtual_available >= 0.0:
-                    continue
-
-                newdate = DateTime.now()
-                if product.supply_method == 'buy':
-                    location_id = warehouse.lot_input_id.id
-                elif product.supply_method == 'produce':
-                    location_id = warehouse.lot_stock_id.id
-                else:
-                    continue
-                proc_id = proc_obj.create(cr, uid, {
-                    'name': 'Automatic OP: %s' % product.name,
-                    'origin': 'SCHEDULER',
-                    'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
-                    'product_id': product.id,
-                    'product_qty': -product.virtual_available,
-                    'product_uom': product.uom_id.id,
-                    'location_id': location_id,
-                    'procure_method': 'make_to_order',
-                    })
-                wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
-                wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_check', cr)
-
-    def _procure_orderpoint_confirm(self, cr, uid, automatic=False,\
-            use_new_cursor=False, context=None, user_id=False):
-        '''
-        use_new_cursor: False or the dbname
-        '''
-        if not context:
-            context = {}
-        if use_new_cursor:
-            cr = pooler.get_db(use_new_cursor).cursor()
-        orderpoint_obj = self.pool.get('stock.warehouse.orderpoint')
-        location_obj = self.pool.get('stock.location')
-        procurement_obj = self.pool.get('mrp.procurement')
-        request_obj = self.pool.get('res.request')
-        wf_service = netsvc.LocalService("workflow")
-        report = []
-        offset = 0
-        ids = [1]
-        if automatic:
-            self.create_automatic_op(cr, uid, context=context)
-        while ids:
-            ids = orderpoint_obj.search(cr, uid, [], offset=offset, limit=100)
-            for op in orderpoint_obj.browse(cr, uid, ids):
-                if op.procurement_id and op.procurement_id.purchase_id and op.procurement_id.purchase_id.state in ('draft', 'confirmed'):
-                    continue
-                prods = location_obj._product_virtual_get(cr, uid,
-                        op.location_id.id, [op.product_id.id],
-                        {'uom': op.product_uom.id})[op.product_id.id]
-                if prods < op.product_min_qty:
-                    qty = max(op.product_min_qty, op.product_max_qty)-prods
-                    reste = qty % op.qty_multiple
-                    if reste > 0:
-                        qty += op.qty_multiple - reste                    
-                    newdate = DateTime.now() + DateTime.RelativeDateTime(
-                            days = int(op.product_id.seller_delay))
-                    if op.product_id.supply_method == 'buy':
-                        location_id = op.warehouse_id.lot_input_id
-                    elif op.product_id.supply_method == 'produce':
-                        location_id = op.warehouse_id.lot_stock_id
-                    else:
-                        continue
-                    if qty <= 0:
-                        continue
-                    if op.product_id.type not in ('consu'):
-                        proc_id = procurement_obj.create(cr, uid, {
-                            'name': 'OP:' + str(op.id),
-                            'date_planned': newdate.strftime('%Y-%m-%d'),
-                            'product_id': op.product_id.id,
-                            'product_qty': qty,
-                            'product_uom': op.product_uom.id,
-                            'location_id': op.warehouse_id.lot_input_id.id,
-                            'procure_method': 'make_to_order',
-                            'origin': op.name
-                        })
-                        wf_service.trg_validate(uid, 'mrp.procurement', proc_id,
-                                'button_confirm', cr)
-                        wf_service.trg_validate(uid, 'mrp.procurement', proc_id,
-                                'button_check', cr)
-                        orderpoint_obj.write(cr, uid, [op.id],
-                                {'procurement_id': proc_id})
-            offset += len(ids)
-            if use_new_cursor:
-                cr.commit()
-        if user_id and report:
-            request_obj.create(cr, uid, {
-                'name': 'Orderpoint report.',
-                'act_from': user_id,
-                'act_to': user_id,
-                'body': '\n'.join(report)
-                })
-        if use_new_cursor:
-            cr.commit()
-            cr.close()
-        return {}
-mrp_procurement()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_procurement/scripts/scheduler.py b/addons/mrp_procurement/scripts/scheduler.py
deleted file mode 100644 (file)
index d95e824..0000000
+++ /dev/null
@@ -1,30 +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/>.     
-#
-##############################################################################
-
-import xmlrpclib
-
-sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/wizard')
-wiz_id = sock.create('trunk', 1, 'admin', 'mrp.procurement.compute.all')
-sock.execute('trunk', 1, 'admin', wiz_id, {'form': {'po_cycle': 1.0, 'po_lead': 1.0, 'user_id': 3, 'schedule_cycle': 1.0, 'picking_lead': 1.0, 'security_lead': 50.0, 'automatic': False}, 'ids': [], 'report_type': 'pdf', 'model': 'ir.ui.menu', 'id': False}, 'compute', {})
-
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp_procurement/security/ir.model.access.csv b/addons/mrp_procurement/security/ir.model.access.csv
deleted file mode 100644 (file)
index ce022a7..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
-"access_mrp_property_group","mrp.property.group","model_mrp_property_group",,1,0,0,0
-"access_mrp_property","mrp.property","model_mrp_property",,1,0,0,0
-"access_mrp_procurement","mrp.procurement","model_mrp_procurement",,1,0,0,0
-"access_stock_warehouse_orderpoint","stock.warehouse.orderpoint","model_stock_warehouse_orderpoint",,1,0,0,0
-"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all",,1,0,0,0
-"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute",,1,0,0,0
-"access_mrp_make_procurement","make.procurement","model_make_procurement",,1,0,0,0
-"access_mrp_make_procurement","mrp.procurement.compute","model_mrp_procurement_compute",,1,0,0,0
diff --git a/addons/mrp_procurement/security/mrp_procurement_security.xml b/addons/mrp_procurement/security/mrp_procurement_security.xml
deleted file mode 100644 (file)
index a0f2ef4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-       <data noupdate="0">
-       
-           <record model="ir.rule" id="mrp_procurement_rule">
-               <field name="name">mrp_procurement multi-company</field>
-               <field name="model_id" search="[('model','=','mrp.procurement')]" model="ir.model"/>
-               <field name="global" eval="True"/>
-               <field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
-           </record>
-       
-           <record model="ir.rule" id="stock_warehouse_orderpoint_rule">
-               <field name="name">stock_warehouse.orderpoint multi-company</field>
-               <field name="model_id" search="[('model','=','stock.warehouse.orderpoint')]" model="ir.model"/>
-               <field name="global" eval="True"/>
-               <field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
-           </record>
-           
-       </data>
-</openerp>
\ No newline at end of file
diff --git a/addons/mrp_procurement/wizard/__init__.py b/addons/mrp_procurement/wizard/__init__.py
deleted file mode 100644 (file)
index ae70ffb..0000000
+++ /dev/null
@@ -1,27 +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/>.     
-#
-##############################################################################
-
-import orderpoint_procurement
-import mrp_procurement
-import schedulers_all
-import make_procurement_product
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/mrp_procurement/wizard/make_procurement_product.py b/addons/mrp_procurement/wizard/make_procurement_product.py
deleted file mode 100644 (file)
index 96f00b8..0000000
+++ /dev/null
@@ -1,122 +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/>.
-#
-##############################################################################
-
-import netsvc
-import time
-
-from osv import fields, osv
-
-class make_procurement(osv.osv_memory):
-    _name = 'make.procurement'
-    _description = 'Make Procurements'
-    
-    def onchange_product_id(self, cr, uid, ids, prod_id):
-        """ On Change of Product ID getting the value of related UoM.
-         @param self: The object pointer.
-         @param cr: A database cursor
-         @param uid: ID of the user currently logged in
-         @param ids: List of IDs selected 
-         @param prod_id: Changed ID of Product 
-         @return: A dictionary which gives the UoM of the changed Product 
-        """
-        product = self.pool.get('product.product').browse(cr, uid, prod_id)
-        return {'value': {'uom_id': product.uom_id.id}}
-    
-    _columns = {
-        'qty': fields.float('Quantity', digits=(16,2), required=True),
-        'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1),
-        'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
-        'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
-        'date_planned': fields.date('Planned Date', required=True),
-    }
-    
-    _defaults = {
-            'date_planned': lambda *args: time.strftime('%Y-%m-%d'),
-            'qty': lambda *args: 1.0,
-    }
-    
-    def make_procurement(self, cr, uid, ids, context=None):
-        """ Creates procurement order for selected product.
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param ids: List of IDs selected 
-        @param context: A standard dictionary 
-        @return: A dictionary which loads Procurement form view. 
-        """
-        user = self.pool.get('res.users').browse(cr, uid, uid, context).login
-        wh_obj = self.pool.get('stock.warehouse')
-        procurement_obj = self.pool.get('mrp.procurement') 
-        wf_service = netsvc.LocalService("workflow")
-        data_obj = self.pool.get('ir.model.data')
-        
-        for proc in self.browse(cr, uid, ids):
-            wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context)
-            procure_id = procurement_obj.create(cr, uid, {
-                'name':'INT: '+str(user),
-                'date_planned': proc.date_planned,
-                'product_id': proc.product_id.id,
-                'product_qty': proc.qty,
-                'product_uom': proc.uom_id.id,
-                'location_id': wh.lot_stock_id.id,
-                'procure_method':'make_to_order',
-            })
-            
-            wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
-        
-        
-        id2 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_tree_view')
-        id3 = data_obj._get_id(cr, uid, 'mrp_procurement', 'mrp_procurement_form_view')
-        
-        if id2:
-            id2 = data_obj.browse(cr, uid, id2, context=context).res_id
-        if id3:
-            id3 = data_obj.browse(cr, uid, id3, context=context).res_id
-        
-        return {
-                'view_type': 'form',
-                'view_mode': 'tree,form',
-                'res_model': 'mrp.procurement',
-                'res_id' : procure_id,
-                'views': [(id3,'form'),(id2,'tree')],
-                'type': 'ir.actions.act_window',
-         }
-    
-    def default_get(self, cr, uid, fields, context=None):
-        """ To get default values for the object.
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param fields: List of fields for which we want default values 
-        @param context: A standard dictionary 
-        @return: A dictionary which of fields with values. 
-        """
-        record_id = context and context.get('active_id', False) or False
-
-        res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
-        product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
-        if 'product_id' in fields:
-            res.update({'product_id':product_id})  
-        return res
-
-make_procurement()
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
-
diff --git a/addons/mrp_procurement/wizard/make_procurement_view.xml b/addons/mrp_procurement/wizard/make_procurement_view.xml
deleted file mode 100644 (file)
index 2e9b44e..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-
-        <!--  Make Procurement -->
-
-        <record id="view_make_procurment_wizard" model="ir.ui.view">
-            <field name="name">Procurement Request</field>
-            <field name="model">make.procurement</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Procurement Request">
-                    <label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." colspan="4"/>
-                    <field name="product_id" on_change="onchange_product_id(product_id)"/>
-                    <field name="qty"/>
-                    <field name="uom_id"/>
-                    <field name="date_planned"/>
-                    <field name="warehouse_id" colspan="4"/>
-                    <newline/>
-                    <separator colspan="4"/>
-                    <group col="2" colspan="4">
-                        <button icon='gtk-cancel' special="cancel"
-                            string="Cancel" />
-                        <button name="make_procurement" string="Ask New Products"
-                            colspan="1" type="object" icon="gtk-ok" />
-                    </group>
-                </form>
-            </field>
-        </record>
-
-        <act_window name="Procurement Request"
-            res_model="make.procurement"
-            src_model="product.product"
-            view_mode="form"
-            target="new"
-            key2="client_action_multi"
-            id="act_make_procurement"
-            groups="base.group_extended"/>
-
-    </data>
-</openerp>
diff --git a/addons/mrp_procurement/wizard/mrp_procurement.py b/addons/mrp_procurement/wizard/mrp_procurement.py
deleted file mode 100644 (file)
index 1c3f3dd..0000000
+++ /dev/null
@@ -1,52 +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/>.
-#
-##############################################################################
-
-import threading
-from osv import osv, fields
-
-class procurement_compute(osv.osv_memory):
-    _name = 'mrp.procurement.compute'
-    _description = 'Compute Procurement'
-    
-    def _procure_calculation_procure(self, cr, uid, ids, context):
-        try:
-            proc_obj = self.pool.get('mrp.procurement')
-            proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context)
-        finally:
-            cr.close()
-        return {}
-    
-    def procure_calculation(self, cr, uid, ids, context):
-        """ 
-         @param self: The object pointer.
-         @param cr: A database cursor
-         @param uid: ID of the user currently logged in
-         @param ids: List of IDs selected 
-         @param context: A standard dictionary 
-        """
-        threaded_calculation = threading.Thread(target=self._procure_calculation_procure, 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_procurement/wizard/mrp_procurement_view.xml b/addons/mrp_procurement/wizard/mrp_procurement_view.xml
deleted file mode 100644 (file)
index 817f701..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-
-        <!--  Compute Procurement -->
-
-        <record id="view_compute_procurment_wizard" model="ir.ui.view">
-            <field name="name">Compute Procurements</field>
-            <field name="model">mrp.procurement.compute</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Parameters">
-                    <label string="This wizard will schedule procurements." colspan="4" align="0.0"/>
-                    <newline/>
-                    <group col="2" colspan="4">
-                        <button icon='gtk-cancel' special="cancel"
-                            string="Cancel" />
-                        <button name="procure_calculation" string="Compute Procurements"
-                            colspan="1" type="object" icon="gtk-ok" />
-                    </group>
-                </form>
-            </field>
-        </record>
-
-<!--        <act_window name="Compute Procurements"            -->
-<!--            res_model="mrp.procurement.compute"-->
-<!--            src_model="mrp.procurement"-->
-<!--            view_mode="form"-->
-<!--            target="new"        -->
-<!--            key2="client_action_multi"    -->
-<!--            id="act_compute_procurement"/>       -->
-        
-    </data>
-</openerp>    
diff --git a/addons/mrp_procurement/wizard/orderpoint_procurement.py b/addons/mrp_procurement/wizard/orderpoint_procurement.py
deleted file mode 100644 (file)
index 5630266..0000000
+++ /dev/null
@@ -1,70 +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 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):
-        """ 
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param ids: List of IDs selected 
-        @param context: A standard dictionary 
-        """        
-        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)
-        
-        return {}
-    
-    def procure_calculation(self, cr, uid, ids, context):
-        """ 
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param ids: List of IDs selected 
-        @param context: A standard dictionary 
-        """
-        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_procurement/wizard/orderpoint_procurement_view.xml b/addons/mrp_procurement/wizard/orderpoint_procurement_view.xml
deleted file mode 100644 (file)
index c17beda..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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>
-
-        <act_window name="Compute Stock Minimum Rules Only"                
-                   res_model="mrp.procurement.orderpoint.compute"
-                   src_model="mrp.procurement"
-                   view_mode="form"
-                   target="new"        
-            key2="client_action_multi"    
-                   id="action_procurement_compute"/>        
-               
-       </data>
-</openerp>     
diff --git a/addons/mrp_procurement/wizard/schedulers_all.py b/addons/mrp_procurement/wizard/schedulers_all.py
deleted file mode 100644 (file)
index ad67b13..0000000
+++ /dev/null
@@ -1,68 +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/>.
-#
-##############################################################################
-
-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):
-        """ 
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param ids: List of IDs selected 
-        @param context: A standard dictionary 
-        """
-        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):
-        """ 
-        @param self: The object pointer.
-        @param cr: A database cursor
-        @param uid: ID of the user currently logged in
-        @param ids: List of IDs selected 
-        @param context: A standard dictionary 
-        """
-        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_procurement/wizard/schedulers_all_view.xml b/addons/mrp_procurement/wizard/schedulers_all_view.xml
deleted file mode 100644 (file)
index 3386128..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-        
-        <!--  Compute Schedulers -->
-        
-               <record id="view_compute_schedulers_wizard" model="ir.ui.view">
-            <field name="name">Compute Schedulers</field>
-            <field name="model">mrp.procurement.compute.all</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Scheduler 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 Schedulers"
-                                       colspan="1" type="object" icon="gtk-ok" />
-                       </group>
-                </form>
-            </field>
-        </record>
-
-         <act_window name="Compute Schedulers"             
-                   res_model="mrp.procurement.compute.all"
-                   src_model="mrp.procurement"
-                   view_mode="form"
-                   target="new"        
-            key2="client_action_multi"    
-                   id="action_compute_schedulers"/>            
-        
-       </data>
-</openerp>     
index 80c0667..4945711 100644 (file)
@@ -95,7 +95,7 @@
       ref('stock.menu_action_picking_tree7'),
                        ref('stock.menu_action_picking_tree8'),
       ref('stock.menu_action_picking_tree9'),
-                       ref('mrp_procurement.menu_mrp_procurement_action3'),
+                       ref('procurement.menu_mrp_procurement_action3'),
                        ref('point_of_sale.menu_point_root')])]" name="menu_access"/>
                        <field eval="[(6,0,[ref('res_users_shopuser0'),ref('res_users_shopuser1')])]" name="users"/>
                                <field eval="[(6,0,[ref('point_of_sale.ir_rule_group_point0'),ref('point_of_sale.ir_rule_group_poslinecompany0'),ref('point_of_sale.ir_rule_group_posreporting0')])]" name="rule_groups"/>
                </record>
 
                <record id="ir_modelsmrp_pdt0" model="ir.model.access">
-                       <field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
+                       <field name="model_id" ref="procurement.model_mrp_procurement"/>
                        <field eval="1" name="perm_read"/>
                        <field eval="&quot;&quot;&quot;MRP - Procurement&quot;&quot;&quot;" name="name"/>
                        <field eval="0" name="perm_unlink"/>
                        <field name="group_id" ref="res_groups_posuser0"/>
                </record>
                <record id="ir_model_access_stockwarehouseorderpoint0" model="ir.model.access">
-                       <field name="model_id" ref="mrp_procurement.model_stock_warehouse_orderpoint"/>
+                       <field name="model_id" ref="procurement.model_stock_warehouse_orderpoint"/>
                        <field eval="1" name="perm_read"/>
                        <field eval="&quot;&quot;&quot;stock.warehouse.orderpoint&quot;&quot;&quot;" name="name"/>
                        <field eval="0" name="perm_unlink"/>
                        <field name="group_id" ref="res_groups_posuser0"/>
                </record>
         <record id="ir_model_access_procurement0" model="ir.model.access">
-            <field name="model_id" ref="mrp_procurement.model_mrp_procurement" />
+            <field name="model_id" ref="procurement.model_mrp_procurement" />
             <field eval="1" name="perm_read" />
             <field eval="1" name="perm_write" />
             <field eval="1" name="perm_create" />
             name="Reporting"
             parent="stock.menu_stock_root" groups="base.group_user"/>
                <menuitem action="stock.action_picking_tree" id="stock.menu_action_picking_tree" parent="stock.menu_stock_warehouse_mgmt" sequence="19" groups="res_groups_posuser0"/>
-<!--        <menuitem id="mrp_procurement.menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4" groups="base.group_user"/>-->
+<!--        <menuitem id="procurement.menu_mrp_reordering" name="Automatic Procurements" parent="stock.menu_stock_root" sequence="4" groups="base.group_user"/>-->
         <menuitem parent="stock.next_id_61" action="stock.action_stock_line_date" id="stock.menu_report_stock_line_date" groups="base.group_user"/>
 
        </data>
index 927584e..da80266 100644 (file)
       ref('stock.menu_action_picking_tree7'),
                        ref('stock.menu_action_picking_tree8'),
       ref('stock.menu_action_picking_tree9'),
-                       ref('mrp_procurement.menu_mrp_procurement_action3'),
+                       ref('procurement.menu_mrp_procurement_action3'),
                        ref('point_of_sale.menu_point_root')])]" name="menu_access"/>
                                <field eval="[(6,0,[ref('point_of_sale.ir_rule_group_point0'),ref('point_of_sale.ir_rule_group_poslinecompany0'),ref('point_of_sale.ir_rule_group_posreporting0')])]" name="rule_groups"/>
                        <field eva="[(6,0,[ref('res_users_shopuser0'),ref('res_users_shopuser1')])]" name="users"/>
                </record>
 
                <record id="ir_modelsmrp_pdt0" model="ir.model.access">
-                       <field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
+                       <field name="model_id" ref="procurement.model_mrp_procurement"/>
                        <field eval="1" name="perm_read"/>
                        <field eval="&quot;&quot;&quot;MRP - Procurement&quot;&quot;&quot;" name="name"/>
                        <field eval="0" name="perm_unlink"/>
index 67c9417..5172e0e 100644 (file)
@@ -33,7 +33,7 @@
                        <field eval="1" name="global"/>
                </record>
                <record id="point_of_sale.res_groups_posuser0" model="res.groups">
-               <field eval="[(6,0,[ref('product.menu_config_product'),ref('product.menu_product_category_action_form'),ref('point_of_sale.menu_point_ofsale'),ref('point_of_sale.menu_point_config'),ref('point_of_sale.menu_statement_tree_all'),ref('stock.menu_stock_root'),ref('stock.menu_action_location_form'),ref('stock.menu_action_location_tree'),ref('stock.menu_picking_waiting'),ref('stock.menu_action_picking_tree3'),ref('stock.menu_action_picking_tree5'),ref('stock.menu_action_picking_form'),ref('stock.menu_action_picking_tree7'),ref('stock.menu_action_picking_tree8'),ref('stock.menu_action_picking_tree9'),ref('mrp_procurement.menu_mrp_procurement_action3'),ref('mrp_procurement.menu_mrp_procurement_new'),ref('mrp.next_id_77'),ref('mrp.menu_report_workcenter_load'),ref('mrp.menu_report_in_out_picking'),ref('base.menu_sales'),ref('sale.menu_action_shop_form'),ref('sale.menu_sale_order'),ref('sale.menu_action_order_tree'),ref('sale.menu_action_order_tree_all'),ref('sale.menu_action_order_tree2'),ref('sale.menu_action_order_tree3'),ref('sale.menu_action_order_tree7'),ref('sale.menu_action_order_tree8'),ref('sale.menu_action_order_line_tree1'),ref('delivery.menu_action_delivery_carrier_form'),ref('delivery.menu_action_delivery_grid_form'),ref('point_of_sale.menu_point_root')])]" name="menu_access"/>
+               <field eval="[(6,0,[ref('product.menu_config_product'),ref('product.menu_product_category_action_form'),ref('point_of_sale.menu_point_ofsale'),ref('point_of_sale.menu_point_config'),ref('point_of_sale.menu_statement_tree_all'),ref('stock.menu_stock_root'),ref('stock.menu_action_location_form'),ref('stock.menu_action_location_tree'),ref('stock.menu_picking_waiting'),ref('stock.menu_action_picking_tree3'),ref('stock.menu_action_picking_tree5'),ref('stock.menu_action_picking_form'),ref('stock.menu_action_picking_tree7'),ref('stock.menu_action_picking_tree8'),ref('stock.menu_action_picking_tree9'),ref('procurement.menu_mrp_procurement_action3'),ref('procurement.menu_mrp_procurement_new'),ref('mrp.next_id_77'),ref('mrp.menu_report_workcenter_load'),ref('mrp.menu_report_in_out_picking'),ref('base.menu_sales'),ref('sale.menu_action_shop_form'),ref('sale.menu_sale_order'),ref('sale.menu_action_order_tree'),ref('sale.menu_action_order_tree_all'),ref('sale.menu_action_order_tree2'),ref('sale.menu_action_order_tree3'),ref('sale.menu_action_order_tree7'),ref('sale.menu_action_order_tree8'),ref('sale.menu_action_order_line_tree1'),ref('delivery.menu_action_delivery_carrier_form'),ref('delivery.menu_action_delivery_grid_form'),ref('point_of_sale.menu_point_root')])]" name="menu_access"/>
                        <field eval="[(6,0,[ref('ir_rule_group_bankstatementcompany0'),ref('ir_rule_group_bankstatementlinecompany0'),ref('point_of_sale.ir_rule_group_point0'),ref('point_of_sale.ir_rule_group_poslinecompany0'),ref('point_of_sale.ir_rule_group_posreporting0')])]" name="rule_groups"/>
                        <field eval="&quot;&quot;&quot;POS_user&quot;&quot;&quot;" name="name"/>
                </record>
diff --git a/addons/procurement/__init__.py b/addons/procurement/__init__.py
new file mode 100644 (file)
index 0000000..3420ef1
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import procurement
+import wizard
+import schedulers
+import company
\ No newline at end of file
diff --git a/addons/procurement/__openerp__.py b/addons/procurement/__openerp__.py
new file mode 100644 (file)
index 0000000..7484735
--- /dev/null
@@ -0,0 +1,52 @@
+# -*- 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/>.
+#
+##############################################################################
+
+
+{
+    "name" : "Procurements",
+    "version" : "1.0",
+    "author" : "Tiny",
+    "website" : "http://www.openerp.com",
+    "category" : "Generic Modules/Production",
+    "depends" : ["base","process", "product", "stock"],
+    "description": """
+    This is the module for computing Procurements.
+    """,
+    'init_xml': [],
+    'update_xml': [
+        'security/ir.model.access.csv',
+        'security/procurement_security.xml',
+        'procurement_data.xml',
+        'wizard/make_procurement_view.xml',
+        'wizard/mrp_procurement_view.xml',
+        'wizard/orderpoint_procurement_view.xml',
+        'procurement_view.xml',
+        'wizard/schedulers_all_view.xml',
+        'procurement_workflow.xml',
+        'process/procurement_process.xml',
+        "company_view.xml",
+    ],
+#    'demo_xml': [],
+    'installable': True,
+    'active': False,
+    'certificate': '',
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/company.py b/addons/procurement/company.py
new file mode 100644 (file)
index 0000000..ce39ca9
--- /dev/null
@@ -0,0 +1,38 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from osv import osv,fields
+
+class company(osv.osv):
+    _inherit = 'res.company'
+    _columns = {
+        'schedule_range': fields.float('Scheduler Range', required=True,
+            help="This is the time frame analysed by the scheduler when "\
+            "computing procurements. All procurements that are not between "\
+            "today and today+range are skipped for futur computation."),
+    }
+    _defaults = {
+        'schedule_range': lambda *a: 80.0,
+    }
+company()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/company_view.xml b/addons/procurement/company_view.xml
new file mode 100644 (file)
index 0000000..543e36f
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+
+        <record id="mrp_company" model="ir.ui.view">
+            <field name="name">res.company.mrp.config</field>
+            <field name="model">res.company</field>
+            <field name="type">form</field>
+            <field name="inherit_id" ref="base.view_company_form"/>
+            <field name="arch" type="xml">
+                <page string="Configuration" position="inside">
+                    <separator string="MRP &amp; Logistic Scheduler" colspan="4"/>
+                    <field name="schedule_range"/>
+                </page>
+            </field>
+       </record>
+    
+    </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/procurement/process/procurement_process.xml b/addons/procurement/process/procurement_process.xml
new file mode 100644 (file)
index 0000000..b537eee
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+
+        <!--
+            Process
+        -->
+
+        <record id="process_process_procurementprocess0" model="process.process">
+            <field eval="&quot;&quot;&quot;Procurement&quot;&quot;&quot;" name="name"/>
+            <field name="model_id" ref="procurement.model_mrp_procurement"/>
+            <field eval="1" name="active"/>
+        </record>
+
+        <!--
+            Process Node
+        -->
+
+        
+    </data>
+</openerp>
diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py
new file mode 100644 (file)
index 0000000..ceaefb4
--- /dev/null
@@ -0,0 +1,524 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from mx import DateTime
+from osv import osv, fields
+from tools.translate import _
+import netsvc
+import time
+
+
+class mrp_property_group(osv.osv):
+    """
+    Group of mrp properties.
+    """
+    _name = 'mrp.property.group'
+    _description = 'Property Group'
+    _columns = {
+        'name': fields.char('Property Group', size=64, required=True),
+        'description': fields.text('Description'),
+    }
+mrp_property_group()
+
+class mrp_property(osv.osv):
+    """
+    Properties of mrp.
+    """
+    _name = 'mrp.property'
+    _description = 'Property'
+    _columns = {
+        'name': fields.char('Name', size=64, required=True),
+        'composition': fields.selection([('min','min'),('max','max'),('plus','plus')], 'Properties composition', required=True, help="Not used in computations, for information purpose only."),
+        'group_id': fields.many2one('mrp.property.group', 'Property Group', required=True),
+        'description': fields.text('Description'),
+    }
+    _defaults = {
+        'composition': lambda *a: 'min',
+    }
+mrp_property()
+
+# ------------------------------------------------------------------
+# Procurement
+# ------------------------------------------------------------------
+#
+# Produce, Buy or Find products and place a move
+#     then wizard for picking lists & move
+#
+class mrp_procurement(osv.osv):
+    """
+    Procurement Orders
+    """
+    _name = "mrp.procurement"
+    _description = "Procurement"
+    _order = 'priority,date_planned desc'
+    _log_create = False
+    _columns = {
+        'name': fields.char('Reason', size=64, required=True, help='Procurement name.'),
+        'origin': fields.char('Source Document', size=64,
+            help="Reference of the document that created this Procurement.\n"
+            "This is automatically completed by Open ERP."),
+        'priority': fields.selection([('0','Not urgent'),('1','Normal'),('2','Urgent'),('3','Very Urgent')], 'Priority', required=True),
+        'date_planned': fields.datetime('Scheduled date', required=True),
+        'date_close': fields.datetime('Date Closed'),
+        'product_id': fields.many2one('product.product', 'Product', required=True, states={'draft':[('readonly',False)]}, readonly=True),
+        'product_qty': fields.float('Quantity', required=True, states={'draft':[('readonly',False)]}, readonly=True),
+        'product_uom': fields.many2one('product.uom', 'Product UoM', required=True, states={'draft':[('readonly',False)]}, readonly=True),
+        'product_uos_qty': fields.float('UoS Quantity', states={'draft':[('readonly',False)]}, readonly=True),
+        'product_uos': fields.many2one('product.uom', 'Product UoS', states={'draft':[('readonly',False)]}, readonly=True),
+        'move_id': fields.many2one('stock.move', 'Reservation', ondelete='set null'),
+        'close_move': fields.boolean('Close Move at end', required=True),
+        'location_id': fields.many2one('stock.location', 'Location', required=True, states={'draft':[('readonly',False)]}, readonly=True),
+        'procure_method': fields.selection([('make_to_stock','from stock'),('make_to_order','on order')], 'Procurement Method', states={'draft':[('readonly',False)], 'confirmed':[('readonly',False)]},
+            readonly=True, required=True, help="If you encode manually a Procurement, you probably want to use" \
+            " a make to order method."),
+
+        'note': fields.text('Note'),
+
+        'property_ids': fields.many2many('mrp.property', 'mrp_procurement_property_rel', 'procurement_id','property_id', 'Properties'),
+
+        'message': fields.char('Latest error', size=64, help="Exception occurred while computing procurement orders."),
+        'state': fields.selection([
+            ('draft','Draft'),
+            ('confirmed','Confirmed'),
+            ('exception','Exception'),
+            ('running','Running'),
+            ('cancel','Cancel'),
+            ('ready','Ready'),
+            ('done','Done'),
+            ('waiting','Waiting')], 'State', required=True,
+            help='When a procurement is created the state is set to \'Draft\'.\n If the procurement is confirmed, the state is set to \'Confirmed\'.\
+            \nAfter confirming the state is set to \'Running\'.\n If any exception arises in the order then the state is set to \'Exception\'.\n Once the exception is removed the state becomes \'Ready\'.\n It is in \'Waiting\'. state when the procurement is waiting for another one to finish.'),
+        'note': fields.text('Note'),
+        'company_id': fields.many2one('res.company','Company',required=True),
+    }
+    _defaults = {
+        'state': lambda *a: 'draft',
+        'priority': lambda *a: '1',
+        'date_planned': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
+        'close_move': lambda *a: 0,
+        'procure_method': lambda *a: 'make_to_order',
+        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.procurement', context=c)
+    }
+
+    def unlink(self, cr, uid, ids, context=None):
+        procurements = self.read(cr, uid, ids, ['state'])
+        unlink_ids = []
+        for s in procurements:
+            if s['state'] in ['draft','cancel']:
+                unlink_ids.append(s['id'])
+            else:
+                raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!' % s['state']))
+        return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
+
+    def onchange_product_id(self, cr, uid, ids, product_id, context={}):
+        """ Finds UoM and UoS of changed product.
+        @param product_id: Changed id of product.
+        @return: Dictionary of values.
+        """
+        if product_id:
+            w = self.pool.get('product.product').browse(cr, uid, product_id, context)
+            v = {
+                'product_uom': w.uom_id.id,
+                'product_uos': w.uos_id and w.uos_id.id or w.uom_id.id
+            }
+            return {'value': v}
+        return {}
+
+    def check_product(self, cr, uid, ids):
+        """ Checks product type.
+        @return: True or False
+        """
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.product_id.type in ('product', 'consu'):
+                return True
+        return False
+
+    def check_move_cancel(self, cr, uid, ids, context={}):
+        """ Checks if move is cancelled or not.
+        @return: True or False.
+        """
+        res = True
+        ok = False
+        for procurement in self.browse(cr, uid, ids, context):
+            if procurement.move_id:
+                ok = True
+                if not procurement.move_id.state == 'cancel':
+                    res = False
+        return res and ok
+
+    def check_move_done(self, cr, uid, ids, context={}):
+        """ Checks if move is done or not.
+        @return: True or False.
+        """
+        res = True
+        for proc in self.browse(cr, uid, ids, context):
+            if proc.move_id:
+                if not proc.move_id.state == 'done':
+                    res = False
+        return res
+
+    #
+    # This method may be overrided by objects that override mrp.procurment
+    # for computing their own purpose
+    #
+    def _quantity_compute_get(self, cr, uid, proc, context={}):
+        """ Finds sold quantity of product.
+        @param proc: Current procurement.
+        @return: Quantity or False.
+        """
+        if proc.product_id.type == 'product':
+            if proc.move_id.product_uos:
+                return proc.move_id.product_uos_qty
+        return False
+
+    def _uom_compute_get(self, cr, uid, proc, context={}):
+        """ Finds UoS if product is Stockable Product.
+        @param proc: Current procurement.
+        @return: UoS or False.
+        """
+        if proc.product_id.type == 'product':
+            if proc.move_id.product_uos:
+                return proc.move_id.product_uos.id
+        return False
+
+    #
+    # Return the quantity of product shipped/produced/served, wich may be
+    # different from the planned quantity
+    #
+    def quantity_get(self, cr, uid, id, context={}):
+        """ Finds quantity of product used in procurement.
+        @return: Quantity of product.
+        """
+        proc = self.browse(cr, uid, id, context)
+        result = self._quantity_compute_get(cr, uid, proc, context)
+        if not result:
+            result = proc.product_qty
+        return result
+
+    def uom_get(self, cr, uid, id, context=None):
+        """ Finds UoM of product used in procurement.
+        @return: UoM of product.
+        """
+        proc = self.browse(cr, uid, id, context)
+        result = self._uom_compute_get(cr, uid, proc, context)
+        if not result:
+            result = proc.product_uom.id
+        return result
+
+    def check_waiting(self, cr, uid, ids, context=[]):
+        """ Checks state of move.
+        @return: True or False
+        """
+        for procurement in self.browse(cr, uid, ids, context=context):
+            if procurement.move_id and procurement.move_id.state == 'auto':
+                return True
+        return False
+
+    def check_produce_service(self, cr, uid, procurement, context=[]):
+        return True
+
+    def check_produce_product(self, cr, uid, procurement, context=[]):
+        """ Finds BoM of a product if not found writes exception message.
+        @param procurement: Current procurement.
+        @return: True or False.
+        """
+        return True
+
+    def check_make_to_stock(self, cr, uid, ids, context={}):
+        """ Checks product type.
+        @return: True or False
+        """
+        ok = True
+        for procurement in self.browse(cr, uid, ids, context=context):
+            if procurement.product_id.type == 'service':
+                ok = ok and self._check_make_to_stock_service(cr, uid, procurement, context)
+            else:
+                ok = ok and self._check_make_to_stock_product(cr, uid, procurement, context)
+        return ok
+
+    def check_produce(self, cr, uid, ids, context={}):
+        """ Checks product type.
+        @return: True or Product Id.
+        """
+        res = True
+        user = self.pool.get('res.users').browse(cr, uid, uid)
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.product_id.product_tmpl_id.supply_method <> 'produce':
+                if procurement.product_id.seller_ids:
+                    partner = procurement.product_id.seller_ids[0].name
+                    if user.company_id and user.company_id.partner_id:
+                        if partner.id == user.company_id.partner_id.id:
+                            return True
+                return False
+            if procurement.product_id.product_tmpl_id.type=='service':
+                res = res and self.check_produce_service(cr, uid, procurement, context)
+            else:
+                res = res and self.check_produce_product(cr, uid, procurement, context)
+            if not res:
+                return False
+        return res
+
+    def check_buy(self, cr, uid, ids):
+        """ Checks product type.
+        @return: True or Product Id.
+        """
+        user = self.pool.get('res.users').browse(cr, uid, uid)
+        partner_obj = self.pool.get('res.partner')
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.product_id.product_tmpl_id.supply_method <> 'buy':
+                return False
+            if not procurement.product_id.seller_ids:
+                cr.execute('update mrp_procurement set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id))
+                return False
+            partner = procurement.product_id.seller_ids[0].name
+            if user.company_id and user.company_id.partner_id:
+                if partner.id == user.company_id.partner_id.id:
+                    return False
+            address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery']
+            if not address_id:
+                cr.execute('update mrp_procurement set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id))
+                return False
+        return True
+
+    def test_cancel(self, cr, uid, ids):
+        """ Tests whether state of move is cancelled or not.
+        @return: True or False
+        """
+        for record in self.browse(cr, uid, ids):
+            if record.move_id and record.move_id.state == 'cancel':
+                return True
+        return False
+
+    def action_confirm(self, cr, uid, ids, context={}):
+        """ Confirms procurement and writes exception message if any.
+        @return: True
+        """
+        move_obj = self.pool.get('stock.move')
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.product_qty <= 0.00:
+                raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity of Procurement Order(s), it should not be less than 1!'))
+            if procurement.product_id.type in ('product', 'consu'):
+                if not procurement.move_id:
+                    source = procurement.location_id.id
+                    if procurement.procure_method == 'make_to_order':
+                        source = procurement.product_id.product_tmpl_id.property_stock_procurement.id
+                    id = move_obj.create(cr, uid, {
+                        'name': 'PROC:' + procurement.name,
+                        'location_id': source,
+                        'location_dest_id': procurement.location_id.id,
+                        'product_id': procurement.product_id.id,
+                        'product_qty': procurement.product_qty,
+                        'product_uom': procurement.product_uom.id,
+                        'date_planned': procurement.date_planned,
+                        'state': 'draft',
+                        'company_id': procurement.company_id.id,
+                    })
+                    move_obj.action_confirm(cr, uid, [id], context=context)
+                    self.write(cr, uid, [procurement.id], {'move_id': id, 'close_move': 1})
+        self.write(cr, uid, ids, {'state': 'confirmed', 'message': ''})
+        return True
+
+    def action_move_assigned(self, cr, uid, ids, context={}):
+        """ Changes procurement state to Running and writes message.
+        @return: True
+        """
+        self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')})
+        return True
+
+    def _check_make_to_stock_service(self, cr, uid, procurement, context={}):
+        return True
+
+    def _check_make_to_stock_product(self, cr, uid, procurement, context={}):
+        """ Checks procurement move state.
+        @param procurement: Current procurement.
+        @return: True or move id.
+        """
+        ok = True
+        if procurement.move_id:
+            id = procurement.move_id.id
+            if not (procurement.move_id.state in ('done','assigned','cancel')):
+                ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id])
+                cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,))
+                if not cr.fetchone()[0]:
+                    cr.execute('update mrp_procurement set message=%s where id=%s', (_('Stock is not enough and No minimum orderpoint rule defined'), procurement.id))
+        return ok
+
+    def action_produce_assign_service(self, cr, uid, ids, context={}):
+        """ Changes procurement state to Running.
+        @return: True
+        """
+        for procurement in self.browse(cr, uid, ids):
+            self.write(cr, uid, [procurement.id], {'state': 'running'})
+        return True
+
+    def action_produce_assign_product(self, cr, uid, ids, context={}):
+        """ This is action which call from workflow to assign production order to procurements
+        @return: True
+        """
+        return 0
+
+
+    def action_po_assign(self, cr, uid, ids, context={}):
+        """ This is action which call from workflow to assign purchase order to procurements
+        @return: True
+        """
+        return 0
+
+    def action_cancel(self, cr, uid, ids):
+        """ Cancels procurement and writes move state to Assigned.
+        @return: True
+        """
+        todo = []
+        todo2 = []
+        move_obj = self.pool.get('stock.move')
+        for proc in self.browse(cr, uid, ids):
+            if proc.close_move:
+                if proc.move_id.state not in ('done', 'cancel'):
+                    todo2.append(proc.move_id.id)
+            else:
+                if proc.move_id and proc.move_id.state == 'waiting':
+                    todo.append(proc.move_id.id)
+        if len(todo2):
+            move_obj.action_cancel(cr, uid, todo2)
+        if len(todo):
+            move_obj.write(cr, uid, todo, {'state': 'assigned'})
+        self.write(cr, uid, ids, {'state': 'cancel'})
+        wf_service = netsvc.LocalService("workflow")
+        for id in ids:
+            wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
+        return True
+
+    def action_check_finnished(self, cr, uid, ids):
+        return self.check_move_done(cr, uid, ids)
+
+    def action_check(self, cr, uid, ids):
+        """ Checks procurement move state whether assigned or done.
+        @return: True
+        """
+        ok = False
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.move_id.state == 'assigned' or procurement.move_id.state == 'done':
+                self.action_done(cr, uid, [procurement.id])
+                ok = True
+        return ok
+
+    def action_ready(self, cr, uid, ids):
+        """ Changes procurement state to Ready.
+        @return: True
+        """
+        res = self.write(cr, uid, ids, {'state': 'ready'})
+        return res
+
+    def action_done(self, cr, uid, ids):
+        """ Changes procurement state to Done and writes Closed date.
+        @return: True
+        """
+        move_obj = self.pool.get('stock.move')
+        for procurement in self.browse(cr, uid, ids):
+            if procurement.move_id:
+                if procurement.close_move and (procurement.move_id.state <> 'done'):
+                    move_obj.action_done(cr, uid, [procurement.move_id.id])
+        res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
+        wf_service = netsvc.LocalService("workflow")
+        for id in ids:
+            wf_service.trg_trigger(uid, 'mrp.procurement', id, cr)
+        return res
+
+    def run_scheduler(self, cr, uid, automatic=False, use_new_cursor=False, context=None):
+        ''' Runs through scheduler.
+        @param use_new_cursor: False or the dbname
+        '''
+        if not context:
+            context={}
+        self._procure_confirm(cr, uid, use_new_cursor=use_new_cursor, context=context)
+        self._procure_orderpoint_confirm(cr, uid, automatic=automatic,\
+                use_new_cursor=use_new_cursor, context=context)
+
+mrp_procurement()
+
+
+class stock_warehouse_orderpoint(osv.osv):
+    """
+    Defines Minimum stock rules.
+    """
+    _name = "stock.warehouse.orderpoint"
+    _description = "Orderpoint minimum rule"
+
+    _columns = {
+        'name': fields.char('Name', size=32, required=True),
+        'active': fields.boolean('Active', help="If the active field is set to true, it will allow you to hide the orderpoint without removing it."),
+        'logic': fields.selection([('max','Order to Max'),('price','Best price (not yet active!)')], 'Reordering Mode', required=True),
+        'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
+        'location_id': fields.many2one('stock.location', 'Location', required=True),
+        'product_id': fields.many2one('product.product', 'Product', required=True, ondelete='cascade', domain=[('type','=','product')]),
+        'product_uom': fields.many2one('product.uom', 'Product UOM', required=True ),
+        'product_min_qty': fields.float('Min Quantity', required=True,
+            help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
+            "a procurement to bring the virtual stock to the Max Quantity."),
+        'product_max_qty': fields.float('Max Quantity', required=True,
+            help="When the virtual stock goes belong the Min Quantity, Open ERP generates "\
+            "a procurement to bring the virtual stock to the Max Quantity."),
+        'qty_multiple': fields.integer('Qty Multiple', required=True,
+            help="The procurement quantity will by rounded up to this multiple."),
+        'procurement_id': fields.many2one('mrp.procurement', 'Latest procurement'),
+        'company_id': fields.many2one('res.company','Company',required=True),
+    }
+    _defaults = {
+        'active': lambda *a: 1,
+        'logic': lambda *a: 'max',
+        'qty_multiple': lambda *a: 1,
+        'name': lambda x,y,z,c: x.pool.get('ir.sequence').get(y,z,'mrp.warehouse.orderpoint') or '',
+        'product_uom': lambda sel, cr, uid, context: context.get('product_uom', False),
+        'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c)
+    }
+
+    def onchange_warehouse_id(self, cr, uid, ids, warehouse_id, context={}):
+        """ Finds location id for changed warehouse.
+        @param warehouse_id: Changed id of warehouse.
+        @return: Dictionary of values.
+        """
+        if warehouse_id:
+            w = self.pool.get('stock.warehouse').browse(cr, uid, warehouse_id, context)
+            v = {'location_id': w.lot_stock_id.id}
+            return {'value': v}
+        return {}
+
+    def onchange_product_id(self, cr, uid, ids, product_id, context={}):
+        """ Finds UoM for changed product.
+        @param product_id: Changed id of product.
+        @return: Dictionary of values.
+        """
+        if product_id:
+            prod = self.pool.get('product.product').browse(cr,uid,product_id)
+            v = {'product_uom': prod.uom_id.id}
+            return {'value': v}
+        return {}
+
+    def copy(self, cr, uid, id, default=None,context={}):
+        if not default:
+            default = {}
+        default.update({
+            'name': self.pool.get('ir.sequence').get(cr, uid, 'mrp.warehouse.orderpoint') or '',
+        })
+        return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context)
+
+stock_warehouse_orderpoint()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/procurement_data.xml b/addons/procurement/procurement_data.xml
new file mode 100644 (file)
index 0000000..256472b
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data noupdate="1">
+        
+        <record forcecreate="True" id="ir_cron_scheduler_action" model="ir.cron">
+            <field name="name">Run mrp scheduler</field>
+            <field eval="False" name="active"/>
+            <field name="user_id" ref="base.user_root"/>
+            <field name="interval_number">1</field>
+            <field name="interval_type">days</field>
+            <field name="numbercall">-1</field>
+            <field eval="False" name="doall"/>
+            <field eval="'mrp.procurement'" name="model"/>
+            <field eval="'run_scheduler'" name="function"/>
+            <field eval="'(False,)'" name="args"/>
+        </record>
+        
+    </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/procurement/procurement_view.xml b/addons/procurement/procurement_view.xml
new file mode 100644 (file)
index 0000000..1defa21
--- /dev/null
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+       <data>
+               <!--
+        Procurement
+        -->
+
+        <record id="mrp_procurement_tree_view" model="ir.ui.view">
+            <field name="name">mrp.procurement.tree</field>
+            <field name="model">mrp.procurement</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <tree string="Procurement Lines" colors="red:date_planned&lt;current_date and state in ('exception');black:state=='running';green:state=='confirmed';gray:state in ['done','cancel'];blue:state in ('ready')">
+                    <field name="date_planned" widget="date"/>
+                    <field name="origin"/>
+                    <field name="product_id"/>
+                    <field name="product_qty"/>
+                    <field name="product_uom" string="UOM"/>
+                    <field name="procure_method"/>
+                    <field name="state"/>
+                    <field name="message"/>
+                </tree>
+            </field>
+        </record>
+        <record id="mrp_procurement_form_view" model="ir.ui.view">
+            <field name="name">mrp.procurement.form</field>
+            <field name="model">mrp.procurement</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Procurement">
+                    <group col="2" colspan="2">
+                        <separator colspan="2" string="References"/>
+                        <field name="name" string="Procurement Reason"/>
+                        <field name="origin"/>
+                        <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator colspan="2" string="Planification"/>
+                        <field name="date_planned"/>
+                        <field name="procure_method"/>
+                        <field name="priority" groups="base.group_extended"/>
+                    </group>
+                    <notebook colspan="4">
+                    <page string="Procurement Details">
+                        <separator colspan="4" string="Product &amp; Location"/>
+                        <field name="product_id" on_change="onchange_product_id(product_id)"/>
+                        <field name="location_id" domain="[('usage','=','internal')]"/>
+                        <field name="product_qty"/>
+                        <field name="product_uom" widget="selection"/>
+
+                        <field name="product_uos_qty" groups="product.group_uos,base.group_extended"/>
+                        <field name="product_uos" widget="selection" groups="product.group_uos,base.group_extended"/>
+
+                        <separator colspan="4" string="Status"/>
+                        <field colspan="4" name="message" readonly="1"/>
+                        <field name="state" readonly="1"/>
+                        <group col="7" colspan="2">
+                            <button name="button_confirm" states="draft" string="Confirm" icon="gtk-apply"/>
+                            <button name="button_restart" states="exception" string="Retry" icon="gtk-convert"/>
+                            <button name="button_cancel" states="draft,exception,waiting" string="Cancel" icon="gtk-cancel"/>
+                            <button name="button_check" states="confirmed" string="Run     Procurement" icon="gtk-media-play"/>
+                        </group>
+                    </page>
+                    <page string="Extra Information">
+                        <separator colspan="4" string="Details"/>
+                        <field name="move_id" groups="base.group_extended"/>
+                        <field name="date_close"/>
+                        <field name="close_move" groups="base.group_extended"/>
+                                               <group colspan="4"  groups="base.group_extended">
+                               <separator colspan="4" string="Properties" />
+                               <field colspan="4" name="property_ids" nolabel="1"/>
+                           </group>
+                    </page>
+                    <page string="Notes">
+                        <separator colspan="4" string="Note" />
+                        <field name="note" colspan="4" nolabel="1"/>
+                    </page>
+                    </notebook>
+                </form>
+            </field>
+        </record>
+        <record id="view_mrp_procurement_filter" model="ir.ui.view">
+            <field name="name">mrp.procurement.select</field>
+            <field name="model">mrp.procurement</field>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <search string="Search Procurement">
+                    <group col='10' colspan='4'>
+                       <filter icon="terp-mrp" string="Current" domain="[('state','in',('draft','confirmed'))]" name="current" help="Procurement Orders in draft or open state."/>
+                       <filter icon="terp-mrp" string="Exceptions" domain="[('state','=','exception')]" help="Procurement Orders with exceptions"/>
+                       <filter icon="terp-mrp" string="Late"
+                           domain="['&amp;', ('date_planned::date','&lt;', current_date), ('state', 'in', ('draft', 'confirmed'))]"
+                           help="Procurement started late" />
+                       <filter icon="terp-mrp" string="To Fix" domain="[('state', '=', 'exception'),('message','=','')]" help="Procurement Orders with exceptions and without message"/>
+                       <separator orientation="vertical"/>
+                       <field name="name"/>
+                       <field name="origin"/>
+                       <field name="product_id" />
+                       <field name="date_planned" widget="date"/>
+                       <field name="state" />
+                    </group>
+                    <newline/>
+                    <group expand="1" string="Group By" colspan="4" col="8" groups="base.group_extended">
+                        <filter string="Product" icon="terp-mrp" domain="[]" context="{'group_by':'product_id'}"/>
+                        <filter string="Reason" icon="terp-mrp" domain="[]" context="{'group_by':'name'}"/>
+                        <filter string="Scheduled Date" icon="terp-mrp" domain="[]" context="{'group_by':'date_planned'}"/>
+                       <filter string="State" icon="terp-mrp" domain="[]" context="{'group_by':'state'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+        <record id="mrp_procurement_action" model="ir.actions.act_window">
+            <field name="name">Procurement Orders</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">mrp.procurement</field>
+            <field name="view_type">form</field>
+            <field name="view_id" eval="False"/>
+            <field name="context">{'search_default_current':1}</field>
+            <field name="search_view_id" ref="view_mrp_procurement_filter"/>
+            <field name="context">{'search_default_Current':1}</field>
+        </record>
+
+        <record id="mrp_procurement_action3" model="ir.actions.act_window">
+            <field name="name">Procurements</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">mrp.procurement</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="search_view_id" ref="view_mrp_procurement_filter"/>
+            <field name="domain">[]</field>
+            <field name="context">{}</field>
+        </record>
+
+        <record id="mrp_procurement_action5" model="ir.actions.act_window">
+            <field name="name">Procurement Exceptions</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">mrp.procurement</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="domain">[('state','=','exception')]</field>
+        </record>
+
+        <record id="mrp_procurement_action4" model="ir.actions.act_window">
+            <field name="name">Procurement Exceptions to Fix</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">mrp.procurement</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="domain">[('state','=','exception'), ('message', '&lt;&gt;', '')]</field>
+            <field name="filter" eval="True"/>
+        </record>
+
+        <record id="mrp_procurement_action11" model="ir.actions.act_window">
+            <field name="name">Temporary Procurement Exceptions</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="res_model">mrp.procurement</field>
+            <field name="view_type">form</field>
+            <field name="view_mode">tree,form</field>
+            <field name="domain">[('state','=','exception'), ('message', '=', '')]</field>
+        </record>
+
+        <!-- Order Point -->
+        <record id="view_warehouse_orderpoint_tree" model="ir.ui.view">
+            <field name="name">stock.warehouse.orderpoint.tree</field>
+            <field name="model">stock.warehouse.orderpoint</field>
+            <field name="type">tree</field>
+            <field name="arch" type="xml">
+                <tree string="Minimum Stock Rules">
+                    <field name="name"/>
+                    <field name="warehouse_id"/>
+                    <field name="location_id"/>
+                    <field name="product_id"/>
+                    <field name="product_uom"/>
+                    <field name="product_min_qty"/>
+                    <field name="product_max_qty"/>
+                </tree>
+            </field>
+        </record>
+
+        <record model="ir.ui.view" id="warehouse_orderpoint_search">
+            <field name="name">stock.warehouse.orderpoint.search</field>
+            <field name="model">stock.warehouse.orderpoint</field>
+            <field name="type">search</field>
+            <field name="arch" type="xml">
+                <search string="Minimum Stock Rules Search">
+                    <group col="10" colspan="4">
+                        <field name="name"/>
+                        <field name="warehouse_id" widget="selection"/>
+                        <field name="location_id"/>
+                        <field name="company_id" widget="selection" groups="base.group_multi_company"/>
+                        <field name="product_id"/>
+                    </group>
+                    <newline/>
+                    <group expand="1" string="Group By..." colspan="4" col="10">
+                        <filter string="Warehouse" icon="terp-stock" domain="[]"  context="{'group_by':'warehouse_id'}"/>
+                        <filter string="Location" icon="terp-stock" domain="[]" context="{'group_by':'location_id'}"/>
+                    </group>
+                </search>
+            </field>
+        </record>
+
+        <record id="view_warehouse_orderpoint_form" model="ir.ui.view">
+            <field name="name">stock.warehouse.orderpoint.form</field>
+            <field name="model">stock.warehouse.orderpoint</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Minimum Stock Rules">
+                    <group col="2" colspan="2">
+                        <separator string="General Information" colspan="2" />
+                        <field name="name" />
+                        <field name="product_id" on_change="onchange_product_id(product_id)"/>
+                        <field name="product_uom"/>
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator string="Locations" colspan="2" />
+                        <field name="warehouse_id" on_change="onchange_warehouse_id(warehouse_id)" widget="selection"/>
+                        <field name="location_id"/>
+                        <field name="company_id" groups="base.group_multi_company" widget="selection"/>
+                    </group>
+                    <group col="2" colspan="2">
+                        <separator string="Quantity Rules" colspan="2" />
+                        <field name="product_min_qty"/>
+                        <field name="product_max_qty"/>
+                        <field name="qty_multiple"/>
+                    </group>
+                    <group col="2" colspan="2" groups="base.group_extended">
+                        <separator string="Misc" colspan="2" />
+                        <field name="procurement_id" readonly="1"/>
+                        <field name="active" />
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <record id="action_orderpoint_form" model="ir.actions.act_window">
+            <field name="name">Minimum Stock Rules</field>
+            <field name="res_model">stock.warehouse.orderpoint</field>
+            <field name="type">ir.actions.act_window</field>
+            <field name="view_type">form</field>
+            <field name="view_id" ref="view_warehouse_orderpoint_tree"/>
+            <field name="search_view_id" ref="warehouse_orderpoint_search" />
+        </record>
+
+        <act_window domain="[('warehouse_id', '=', active_id)]" id="act_stock_warehouse_2_stock_warehouse_orderpoint" name="Minimum Stock Rules" res_model="stock.warehouse.orderpoint" src_model="stock.warehouse"/>
+
+        <!-- add product_uom to context to be the default value when adding new orderpoints -->
+        <act_window
+            context="{'product_uom': locals().has_key('uom_id') and uom_id}"
+            domain="[('product_id', '=', active_id)]"
+            id="act_product_product_2_stock_warehouse_orderpoint"
+            name="Minimum Stock Rules"
+            res_model="stock.warehouse.orderpoint"
+            src_model="product.product"/>
+
+        <act_window
+            context="{'product_uom': locals().has_key('uom_id') and uom_id}"
+            domain="[('product_id', '=', active_id)]"
+            id="act_mrp_procurement_2_stock_warehouse_orderpoint"
+            name="Minimum Stock Rules"
+            res_model="stock.warehouse.orderpoint"
+            src_model="mrp.procurement"/>
+
+        <act_window
+            domain="[('id', '=', product_id)]"
+            id="act_product_product_2_stock_warehouse_orderpoint"
+            name="Product"
+            res_model="product.product"
+            src_model="mrp.procurement"/>
+
+    </data>
+</openerp>
diff --git a/addons/procurement/procurement_workflow.xml b/addons/procurement/procurement_workflow.xml
new file mode 100644 (file)
index 0000000..599d11c
--- /dev/null
@@ -0,0 +1,194 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record id="wkf_procurement" model="workflow">
+            <field name="name">mrp.procurement.basic</field>
+            <field name="osv">mrp.procurement</field>
+            <field name="on_create">True</field>
+        </record>
+
+        <record id="act_draft" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="flow_start">True</field>
+            <field name="name">draft</field>
+        </record>
+        <record id="act_cancel" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">cancel</field>
+            <field name="kind">function</field>
+            <field name="action">action_cancel()</field>
+            <field name="flow_stop">True</field>
+        </record>
+        <record id="act_confirm" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">confirm</field>
+            <field name="kind">function</field>
+            <field name="action">action_confirm()</field>
+        </record>
+        <record id="act_confirm_wait" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">confirm_wait</field>
+            <field name="kind">function</field>
+            <field name="action">write({'state':'exception'})</field>
+        </record>
+        <record id="act_confirm_mts" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">confirm_mts</field>
+        </record>
+        <record id="act_confirm_mto" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">confirm_mto</field>
+        </record>
+        <record id="act_make_to_stock" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">make_to_stock</field>
+            <field name="kind">function</field>
+            <field name="action">action_move_assigned()</field>
+        </record>
+        <record id="act_produce_check" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">produce_check</field>
+        </record>
+        <record id="act_produce_service" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">produce_service</field>
+            <field name="kind">function</field>
+            <field name="action">action_produce_assign_service()</field>
+        </record>
+        <record id="act_make_done" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">ready</field>
+            <field name="kind">function</field>
+            <field name="action">action_ready()</field>
+        </record>
+        <record id="act_wait_done" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="name">wait_done</field>
+            <field name="kind">function</field>
+            <field name="action">write({'state':'waiting'})</field>
+        </record>
+
+        <record id="act_done" model="workflow.activity">
+            <field name="wkf_id" ref="wkf_procurement"/>
+            <field name="flow_stop">True</field>
+            <field name="name">done</field>
+            <field name="kind">function</field>
+            <field name="action">action_done()</field>
+        </record>
+
+        <record id="trans_draft_confirm" model="workflow.transition">
+            <field name="act_from" ref="act_draft"/>
+            <field name="act_to" ref="act_confirm"/>
+            <field name="signal">button_confirm</field>
+        </record>
+        <record id="trans_confirm_cancel2" model="workflow.transition">
+            <field name="act_from" ref="act_confirm"/>
+            <field name="act_to" ref="act_wait_done"/>
+            <field name="signal">button_wait_done</field>
+            <field name="condition">True</field>
+        </record>
+        <record id="trans_confirm_wait_done" model="workflow.transition">
+            <field name="act_from" ref="act_wait_done"/>
+            <field name="act_to" ref="act_done"/>
+            <field name="condition">check_move_done()</field>
+            <field name="trigger_model">stock.move</field>
+            <field name="trigger_expr_id">[move_id.id]</field>
+        </record>
+
+        <record id="trans_confirm_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_confirm"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">button_check</field>
+            <field name="condition">test_cancel()</field>
+        </record>
+        <record id="trans_confirm_confirm_wait" model="workflow.transition">
+            <field name="act_from" ref="act_confirm"/>
+            <field name="act_to" ref="act_confirm_wait"/>
+            <field name="signal">button_check</field>
+            <field name="condition">not test_cancel()</field>
+        </record>
+        <record id="trans_confirm_wait_confirm_mto" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_wait"/>
+            <field name="act_to" ref="act_confirm_mto"/>
+            <field name="condition">procure_method=='make_to_order'</field>
+        </record>
+        <record id="trans_confirm_wait_confirm_mts" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_wait"/>
+            <field name="act_to" ref="act_confirm_mts"/>
+            <field name="condition">procure_method=='make_to_stock'</field>
+        </record>
+        <record id="trans_confirm_mts_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mts"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">button_cancel</field>
+        </record>
+        <record id="trans_confirm_waiting_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_wait_done"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">button_cancel</field>
+        </record>
+        <record id="trans_confirm_mts_confirm" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mts"/>
+            <field name="act_to" ref="act_confirm"/>
+            <field name="signal">button_restart</field>
+        </record>
+        <record id="trans_confirm_mto_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mto"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">button_cancel</field>
+        </record>
+        <record id="trans_confirm_mto_confirm" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mto"/>
+            <field name="act_to" ref="act_confirm"/>
+            <field name="signal">button_restart</field>
+        </record>
+        <record id="trans_draft_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_draft"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">button_cancel</field>
+        </record>
+        <record id="trans_confirm_mts_make_to_stock" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mts"/>
+            <field name="act_to" ref="act_make_to_stock"/>
+            <field name="condition">check_make_to_stock()</field>
+        </record>
+        <record id="trans_confirm_mto_produce_check" model="workflow.transition">
+            <field name="act_from" ref="act_confirm_mto"/>
+            <field name="act_to" ref="act_produce_check"/>
+            <field name="condition">check_produce()</field>
+        </record>
+        <record id="trans_product_check_produce_service" model="workflow.transition">
+            <field name="act_from" ref="act_produce_check"/>
+            <field name="act_to" ref="act_produce_service"/>
+            <field name="condition">not check_product()</field>
+        </record>
+        <record id="trans_make_to_stock_make_done" model="workflow.transition">
+            <field name="act_from" ref="act_make_to_stock"/>
+            <field name="act_to" ref="act_make_done"/>
+            <field name="condition">True</field>
+            <field name="trigger_model" eval="False"/>
+            <field name="trigger_expr_id" eval="False"/>
+        </record>
+        <record id="trans_produce_service_cancel" model="workflow.transition">
+            <field name="act_from" ref="act_produce_service"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="signal">subflow.cancel</field>
+        </record>
+        <record id="trans_produce_service_make_done" model="workflow.transition">
+            <field name="act_from" ref="act_produce_service"/>
+            <field name="act_to" ref="act_make_done"/>
+        </record>
+        <record id="trans_make_done_done" model="workflow.transition">
+            <field name="act_from" ref="act_make_done"/>
+            <field name="act_to" ref="act_done"/>
+            <field name="condition">action_check_finnished()</field>
+        </record>
+        <record id="trans_make_done_confirm" model="workflow.transition">
+            <field name="act_from" ref="act_make_done"/>
+            <field name="act_to" ref="act_cancel"/>
+            <field name="condition">check_move_cancel()</field>
+        </record>
+    
+    </data>
+</openerp>
diff --git a/addons/procurement/schedulers.py b/addons/procurement/schedulers.py
new file mode 100644 (file)
index 0000000..6ebc0f6
--- /dev/null
@@ -0,0 +1,242 @@
+# -*- 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/>.
+#
+##############################################################################
+
+from osv import osv
+import netsvc
+import pooler
+from mx import DateTime
+import time
+
+
+class mrp_procurement(osv.osv):
+    _inherit = 'mrp.procurement'
+
+    def _procure_confirm(self, cr, uid, ids=None, use_new_cursor=False, context=None):
+        '''
+        use_new_cursor: False or the dbname
+        '''
+        if not context:
+            context = {}
+
+        if use_new_cursor:
+            cr = pooler.get_db(use_new_cursor).cursor()
+        wf_service = netsvc.LocalService("workflow")
+
+        procurement_obj = self.pool.get('mrp.procurement')
+        if not ids:
+            ids = procurement_obj.search(cr, uid, [], order="date_planned")
+        for id in ids:
+            wf_service.trg_validate(uid, 'mrp.procurement', id, 'button_restart', cr)
+        if use_new_cursor:
+            cr.commit()
+
+        company = self.pool.get('res.users').browse(cr, uid, uid, context=context).company_id
+        maxdate = DateTime.now() + DateTime.RelativeDateTime(days=company.schedule_range)
+        start_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
+        offset = 0
+        report = []
+        report_total = 0
+        report_except = 0
+        report_later = 0
+        while True:
+            cr.execute('select id from mrp_procurement where state=%s and procure_method=%s order by priority,date_planned limit 500 offset %s', ('confirmed', 'make_to_order', offset))
+            ids = map(lambda x: x[0], cr.fetchall())
+            for proc in procurement_obj.browse(cr, uid, ids):
+                if (maxdate.strftime('%Y-%m-%d') >= proc.date_planned):
+                    wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr)
+                else:
+                    offset += 1
+                    report_later += 1
+            for proc in procurement_obj.browse(cr, uid, ids):
+                if proc.state == 'exception':
+                    report.append('PROC %d: on order - %3.2f %-5s - %s' % \
+                            (proc.id, proc.product_qty, proc.product_uom.name,
+                                proc.product_id.name))
+                    report_except += 1
+                report_total += 1
+            if use_new_cursor:
+                cr.commit()
+            if not ids:
+                break
+
+        offset = 0
+        ids = []
+        while True:
+            report_ids = []
+            ids = procurement_obj.search(cr, uid, [('state', '=', 'confirmed'), ('procure_method', '=', 'make_to_stock')], offset=offset)
+            for proc in procurement_obj.browse(cr, uid, ids):
+                if ((maxdate).strftime('%Y-%m-%d') >= proc.date_planned) :
+                    wf_service.trg_validate(uid, 'mrp.procurement', proc.id, 'button_check', cr)
+                    report_ids.append(proc.id)
+                else:
+                    report_later += 1
+                report_total += 1
+            for proc in procurement_obj.browse(cr, uid, report_ids):
+                if proc.state == 'exception':
+                    report.append('PROC %d: from stock - %3.2f %-5s - %s' % \
+                            (proc.id, proc.product_qty, proc.product_uom.name,
+                                proc.product_id.name,))
+                    report_except += 1
+            if use_new_cursor:
+                cr.commit()
+            offset += len(ids)
+            if not ids: break
+        end_date = time.strftime('%Y-%m-%d, %Hh %Mm %Ss')
+        if uid:
+            request = self.pool.get('res.request')
+            summary = '''Here is the procurement scheduling report.
+
+    Computation Started; %s
+    Computation Finished; %s
+
+    Total procurement: %d
+    Exception procurement: %d
+    Not run now procurement: %d
+
+    Exceptions;
+    '''% (start_date, end_date, report_total, report_except, report_later)
+            summary += '\n'.join(report)
+            request.create(cr, uid,
+                {'name': "Procurement calculation report.",
+                    'act_from': uid,
+                    'act_to': uid,
+                    'body': summary,
+                })
+        if use_new_cursor:
+            cr.commit()
+            cr.close()
+        return {}
+
+    def create_automatic_op(self, cr, uid, context=None):
+        if not context:
+            context = {}
+        product_obj = self.pool.get('product.product')
+        proc_obj = self.pool.get('mrp.procurement')
+        warehouse_obj = self.pool.get('stock.warehouse')
+        wf_service = netsvc.LocalService("workflow")
+
+        warehouse_ids = warehouse_obj.search(cr, uid, [], context=context)
+
+        cr.execute('select id from product_product')
+        products_id = [x for x, in cr.fetchall()]
+
+        for warehouse in warehouse_obj.browse(cr, uid, warehouse_ids, context=context):
+            context['warehouse'] = warehouse
+            for product in product_obj.browse(cr, uid, products_id, context=context):
+                if product.virtual_available >= 0.0:
+                    continue
+
+                newdate = DateTime.now()
+                if product.supply_method == 'buy':
+                    location_id = warehouse.lot_input_id.id
+                elif product.supply_method == 'produce':
+                    location_id = warehouse.lot_stock_id.id
+                else:
+                    continue
+                proc_id = proc_obj.create(cr, uid, {
+                    'name': 'Automatic OP: %s' % product.name,
+                    'origin': 'SCHEDULER',
+                    'date_planned': newdate.strftime('%Y-%m-%d %H:%M:%S'),
+                    'product_id': product.id,
+                    'product_qty': -product.virtual_available,
+                    'product_uom': product.uom_id.id,
+                    'location_id': location_id,
+                    'procure_method': 'make_to_order',
+                    })
+                wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_confirm', cr)
+                wf_service.trg_validate(uid, 'mrp.procurement', proc_id, 'button_check', cr)
+
+    def _procure_orderpoint_confirm(self, cr, uid, automatic=False,\
+            use_new_cursor=False, context=None, user_id=False):
+        '''
+        use_new_cursor: False or the dbname
+        '''
+        if not context:
+            context = {}
+        if use_new_cursor:
+            cr = pooler.get_db(use_new_cursor).cursor()
+        orderpoint_obj = self.pool.get('stock.warehouse.orderpoint')
+        location_obj = self.pool.get('stock.location')
+        procurement_obj = self.pool.get('mrp.procurement')
+        request_obj = self.pool.get('res.request')
+        wf_service = netsvc.LocalService("workflow")
+        report = []
+        offset = 0
+        ids = [1]
+        if automatic:
+            self.create_automatic_op(cr, uid, context=context)
+        while ids:
+            ids = orderpoint_obj.search(cr, uid, [], offset=offset, limit=100)
+            for op in orderpoint_obj.browse(cr, uid, ids):
+                if op.procurement_id and op.procurement_id.purchase_id and op.procurement_id.purchase_id.state in ('draft', 'confirmed'):
+                    continue
+                prods = location_obj._product_virtual_get(cr, uid,
+                        op.location_id.id, [op.product_id.id],
+                        {'uom': op.product_uom.id})[op.product_id.id]
+                if prods < op.product_min_qty:
+                    qty = max(op.product_min_qty, op.product_max_qty)-prods
+                    reste = qty % op.qty_multiple
+                    if reste > 0:
+                        qty += op.qty_multiple - reste                    
+                    newdate = DateTime.now() + DateTime.RelativeDateTime(
+                            days = int(op.product_id.seller_delay))
+                    if op.product_id.supply_method == 'buy':
+                        location_id = op.warehouse_id.lot_input_id
+                    elif op.product_id.supply_method == 'produce':
+                        location_id = op.warehouse_id.lot_stock_id
+                    else:
+                        continue
+                    if qty <= 0:
+                        continue
+                    if op.product_id.type not in ('consu'):
+                        proc_id = procurement_obj.create(cr, uid, {
+                            'name': 'OP:' + str(op.id),
+                            'date_planned': newdate.strftime('%Y-%m-%d'),
+                            'product_id': op.product_id.id,
+                            'product_qty': qty,
+                            'product_uom': op.product_uom.id,
+                            'location_id': op.warehouse_id.lot_input_id.id,
+                            'procure_method': 'make_to_order',
+                            'origin': op.name
+                        })
+                        wf_service.trg_validate(uid, 'mrp.procurement', proc_id,
+                                'button_confirm', cr)
+                        wf_service.trg_validate(uid, 'mrp.procurement', proc_id,
+                                'button_check', cr)
+                        orderpoint_obj.write(cr, uid, [op.id],
+                                {'procurement_id': proc_id})
+            offset += len(ids)
+            if use_new_cursor:
+                cr.commit()
+        if user_id and report:
+            request_obj.create(cr, uid, {
+                'name': 'Orderpoint report.',
+                'act_from': user_id,
+                'act_to': user_id,
+                'body': '\n'.join(report)
+                })
+        if use_new_cursor:
+            cr.commit()
+            cr.close()
+        return {}
+mrp_procurement()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/scripts/scheduler.py b/addons/procurement/scripts/scheduler.py
new file mode 100644 (file)
index 0000000..d95e824
--- /dev/null
@@ -0,0 +1,30 @@
+# -*- 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/>.     
+#
+##############################################################################
+
+import xmlrpclib
+
+sock = xmlrpclib.ServerProxy('http://localhost:8069/xmlrpc/wizard')
+wiz_id = sock.create('trunk', 1, 'admin', 'mrp.procurement.compute.all')
+sock.execute('trunk', 1, 'admin', wiz_id, {'form': {'po_cycle': 1.0, 'po_lead': 1.0, 'user_id': 3, 'schedule_cycle': 1.0, 'picking_lead': 1.0, 'security_lead': 50.0, 'automatic': False}, 'ids': [], 'report_type': 'pdf', 'model': 'ir.ui.menu', 'id': False}, 'compute', {})
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/procurement/security/ir.model.access.csv b/addons/procurement/security/ir.model.access.csv
new file mode 100644 (file)
index 0000000..ce022a7
--- /dev/null
@@ -0,0 +1,9 @@
+"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
+"access_mrp_property_group","mrp.property.group","model_mrp_property_group",,1,0,0,0
+"access_mrp_property","mrp.property","model_mrp_property",,1,0,0,0
+"access_mrp_procurement","mrp.procurement","model_mrp_procurement",,1,0,0,0
+"access_stock_warehouse_orderpoint","stock.warehouse.orderpoint","model_stock_warehouse_orderpoint",,1,0,0,0
+"access_mrp_procurement_compute_all","mrp.procurement.compute.all","model_mrp_procurement_compute_all",,1,0,0,0
+"access_mrp_procurement_orderpoint_compute","mrp.procurement.orderpoint.compute","model_mrp_procurement_orderpoint_compute",,1,0,0,0
+"access_mrp_make_procurement","make.procurement","model_make_procurement",,1,0,0,0
+"access_mrp_make_procurement","mrp.procurement.compute","model_mrp_procurement_compute",,1,0,0,0
diff --git a/addons/procurement/security/procurement_security.xml b/addons/procurement/security/procurement_security.xml
new file mode 100644 (file)
index 0000000..a0f2ef4
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+       <data noupdate="0">
+       
+           <record model="ir.rule" id="mrp_procurement_rule">
+               <field name="name">mrp_procurement multi-company</field>
+               <field name="model_id" search="[('model','=','mrp.procurement')]" model="ir.model"/>
+               <field name="global" eval="True"/>
+               <field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
+           </record>
+       
+           <record model="ir.rule" id="stock_warehouse_orderpoint_rule">
+               <field name="name">stock_warehouse.orderpoint multi-company</field>
+               <field name="model_id" search="[('model','=','stock.warehouse.orderpoint')]" model="ir.model"/>
+               <field name="global" eval="True"/>
+               <field name="domain_force">['|',('company_id','child_of',[user.company_id.id]),('company_id','=',False)]</field>
+           </record>
+           
+       </data>
+</openerp>
\ No newline at end of file
diff --git a/addons/procurement/wizard/__init__.py b/addons/procurement/wizard/__init__.py
new file mode 100644 (file)
index 0000000..ae70ffb
--- /dev/null
@@ -0,0 +1,27 @@
+# -*- 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/>.     
+#
+##############################################################################
+
+import orderpoint_procurement
+import mrp_procurement
+import schedulers_all
+import make_procurement_product
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
diff --git a/addons/procurement/wizard/make_procurement_product.py b/addons/procurement/wizard/make_procurement_product.py
new file mode 100644 (file)
index 0000000..fa447e5
--- /dev/null
@@ -0,0 +1,122 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import netsvc
+import time
+
+from osv import fields, osv
+
+class make_procurement(osv.osv_memory):
+    _name = 'make.procurement'
+    _description = 'Make Procurements'
+    
+    def onchange_product_id(self, cr, uid, ids, prod_id):
+        """ On Change of Product ID getting the value of related UoM.
+         @param self: The object pointer.
+         @param cr: A database cursor
+         @param uid: ID of the user currently logged in
+         @param ids: List of IDs selected 
+         @param prod_id: Changed ID of Product 
+         @return: A dictionary which gives the UoM of the changed Product 
+        """
+        product = self.pool.get('product.product').browse(cr, uid, prod_id)
+        return {'value': {'uom_id': product.uom_id.id}}
+    
+    _columns = {
+        'qty': fields.float('Quantity', digits=(16,2), required=True),
+        'product_id': fields.many2one('product.product', 'Product', required=True, readonly=1),
+        'uom_id': fields.many2one('product.uom', 'Unit of Measure', required=True),
+        'warehouse_id': fields.many2one('stock.warehouse', 'Warehouse', required=True),
+        'date_planned': fields.date('Planned Date', required=True),
+    }
+    
+    _defaults = {
+            'date_planned': lambda *args: time.strftime('%Y-%m-%d'),
+            'qty': lambda *args: 1.0,
+    }
+    
+    def make_procurement(self, cr, uid, ids, context=None):
+        """ Creates procurement order for selected product.
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: List of IDs selected 
+        @param context: A standard dictionary 
+        @return: A dictionary which loads Procurement form view. 
+        """
+        user = self.pool.get('res.users').browse(cr, uid, uid, context).login
+        wh_obj = self.pool.get('stock.warehouse')
+        procurement_obj = self.pool.get('mrp.procurement') 
+        wf_service = netsvc.LocalService("workflow")
+        data_obj = self.pool.get('ir.model.data')
+        
+        for proc in self.browse(cr, uid, ids):
+            wh = wh_obj.browse(cr, uid, proc.warehouse_id.id, context)
+            procure_id = procurement_obj.create(cr, uid, {
+                'name':'INT: '+str(user),
+                'date_planned': proc.date_planned,
+                'product_id': proc.product_id.id,
+                'product_qty': proc.qty,
+                'product_uom': proc.uom_id.id,
+                'location_id': wh.lot_stock_id.id,
+                'procure_method':'make_to_order',
+            })
+            
+            wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
+        
+        
+        id2 = data_obj._get_id(cr, uid, 'procurement', 'mrp_procurement_tree_view')
+        id3 = data_obj._get_id(cr, uid, 'procurement', 'mrp_procurement_form_view')
+        
+        if id2:
+            id2 = data_obj.browse(cr, uid, id2, context=context).res_id
+        if id3:
+            id3 = data_obj.browse(cr, uid, id3, context=context).res_id
+        
+        return {
+                'view_type': 'form',
+                'view_mode': 'tree,form',
+                'res_model': 'mrp.procurement',
+                'res_id' : procure_id,
+                'views': [(id3,'form'),(id2,'tree')],
+                'type': 'ir.actions.act_window',
+         }
+    
+    def default_get(self, cr, uid, fields, context=None):
+        """ To get default values for the object.
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param fields: List of fields for which we want default values 
+        @param context: A standard dictionary 
+        @return: A dictionary which of fields with values. 
+        """
+        record_id = context and context.get('active_id', False) or False
+
+        res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
+        product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
+        if 'product_id' in fields:
+            res.update({'product_id':product_id})  
+        return res
+
+make_procurement()
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/procurement/wizard/make_procurement_view.xml b/addons/procurement/wizard/make_procurement_view.xml
new file mode 100644 (file)
index 0000000..2e9b44e
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!--  Make Procurement -->
+
+        <record id="view_make_procurment_wizard" model="ir.ui.view">
+            <field name="name">Procurement Request</field>
+            <field name="model">make.procurement</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Procurement Request">
+                    <label string="This wizard will plan the procurement for this product. This procurement may generate task, production orders or purchase orders." colspan="4"/>
+                    <field name="product_id" on_change="onchange_product_id(product_id)"/>
+                    <field name="qty"/>
+                    <field name="uom_id"/>
+                    <field name="date_planned"/>
+                    <field name="warehouse_id" colspan="4"/>
+                    <newline/>
+                    <separator colspan="4"/>
+                    <group col="2" colspan="4">
+                        <button icon='gtk-cancel' special="cancel"
+                            string="Cancel" />
+                        <button name="make_procurement" string="Ask New Products"
+                            colspan="1" type="object" icon="gtk-ok" />
+                    </group>
+                </form>
+            </field>
+        </record>
+
+        <act_window name="Procurement Request"
+            res_model="make.procurement"
+            src_model="product.product"
+            view_mode="form"
+            target="new"
+            key2="client_action_multi"
+            id="act_make_procurement"
+            groups="base.group_extended"/>
+
+    </data>
+</openerp>
diff --git a/addons/procurement/wizard/mrp_procurement.py b/addons/procurement/wizard/mrp_procurement.py
new file mode 100644 (file)
index 0000000..1c3f3dd
--- /dev/null
@@ -0,0 +1,52 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import threading
+from osv import osv, fields
+
+class procurement_compute(osv.osv_memory):
+    _name = 'mrp.procurement.compute'
+    _description = 'Compute Procurement'
+    
+    def _procure_calculation_procure(self, cr, uid, ids, context):
+        try:
+            proc_obj = self.pool.get('mrp.procurement')
+            proc_obj._procure_confirm(cr, uid, use_new_cursor=cr.dbname, context=context)
+        finally:
+            cr.close()
+        return {}
+    
+    def procure_calculation(self, cr, uid, ids, context):
+        """ 
+         @param self: The object pointer.
+         @param cr: A database cursor
+         @param uid: ID of the user currently logged in
+         @param ids: List of IDs selected 
+         @param context: A standard dictionary 
+        """
+        threaded_calculation = threading.Thread(target=self._procure_calculation_procure, args=(cr, uid, ids, context))
+        threaded_calculation.start()
+        return {}
+    
+procurement_compute()
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/procurement/wizard/mrp_procurement_view.xml b/addons/procurement/wizard/mrp_procurement_view.xml
new file mode 100644 (file)
index 0000000..817f701
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <!--  Compute Procurement -->
+
+        <record id="view_compute_procurment_wizard" model="ir.ui.view">
+            <field name="name">Compute Procurements</field>
+            <field name="model">mrp.procurement.compute</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Parameters">
+                    <label string="This wizard will schedule procurements." colspan="4" align="0.0"/>
+                    <newline/>
+                    <group col="2" colspan="4">
+                        <button icon='gtk-cancel' special="cancel"
+                            string="Cancel" />
+                        <button name="procure_calculation" string="Compute Procurements"
+                            colspan="1" type="object" icon="gtk-ok" />
+                    </group>
+                </form>
+            </field>
+        </record>
+
+<!--        <act_window name="Compute Procurements"            -->
+<!--            res_model="mrp.procurement.compute"-->
+<!--            src_model="mrp.procurement"-->
+<!--            view_mode="form"-->
+<!--            target="new"        -->
+<!--            key2="client_action_multi"    -->
+<!--            id="act_compute_procurement"/>       -->
+        
+    </data>
+</openerp>    
diff --git a/addons/procurement/wizard/orderpoint_procurement.py b/addons/procurement/wizard/orderpoint_procurement.py
new file mode 100644 (file)
index 0000000..5630266
--- /dev/null
@@ -0,0 +1,70 @@
+# -*- 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):
+        """ 
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: List of IDs selected 
+        @param context: A standard dictionary 
+        """        
+        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)
+        
+        return {}
+    
+    def procure_calculation(self, cr, uid, ids, context):
+        """ 
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: List of IDs selected 
+        @param context: A standard dictionary 
+        """
+        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/procurement/wizard/orderpoint_procurement_view.xml b/addons/procurement/wizard/orderpoint_procurement_view.xml
new file mode 100644 (file)
index 0000000..c17beda
--- /dev/null
@@ -0,0 +1,34 @@
+<?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>
+
+        <act_window name="Compute Stock Minimum Rules Only"                
+                   res_model="mrp.procurement.orderpoint.compute"
+                   src_model="mrp.procurement"
+                   view_mode="form"
+                   target="new"        
+            key2="client_action_multi"    
+                   id="action_procurement_compute"/>        
+               
+       </data>
+</openerp>     
diff --git a/addons/procurement/wizard/schedulers_all.py b/addons/procurement/wizard/schedulers_all.py
new file mode 100644 (file)
index 0000000..80694d1
--- /dev/null
@@ -0,0 +1,68 @@
+# -*- 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/>.
+#
+##############################################################################
+
+import threading
+
+from osv import osv, fields
+
+class procurement_compute_all(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):
+        """ 
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: List of IDs selected 
+        @param context: A standard dictionary 
+        """
+        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):
+        """ 
+        @param self: The object pointer.
+        @param cr: A database cursor
+        @param uid: ID of the user currently logged in
+        @param ids: List of IDs selected 
+        @param context: A standard dictionary 
+        """
+        threaded_calculation = threading.Thread(target=self._procure_calculation_all, args=(cr, uid, ids, context))
+        threaded_calculation.start()
+        return {}
+    
+procurement_compute_all()
+
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
diff --git a/addons/procurement/wizard/schedulers_all_view.xml b/addons/procurement/wizard/schedulers_all_view.xml
new file mode 100644 (file)
index 0000000..3386128
--- /dev/null
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+        
+        <!--  Compute Schedulers -->
+        
+               <record id="view_compute_schedulers_wizard" model="ir.ui.view">
+            <field name="name">Compute Schedulers</field>
+            <field name="model">mrp.procurement.compute.all</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <form string="Scheduler 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 Schedulers"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                </form>
+            </field>
+        </record>
+
+         <act_window name="Compute Schedulers"             
+                   res_model="mrp.procurement.compute.all"
+                   src_model="mrp.procurement"
+                   view_mode="form"
+                   target="new"        
+            key2="client_action_multi"    
+                   id="action_compute_schedulers"/>            
+        
+       </data>
+</openerp>     
index 342ff9e..a51a95c 100644 (file)
@@ -47,7 +47,7 @@ automatically created via sale orders.
 """,
     'author': 'Tiny',
     'website': 'http://www.openerp.com',
-    'depends': ['project', 'mrp_procurement', 'sale', 'mrp_jit'],
+    'depends': ['project', 'procurement', 'sale', 'mrp_jit'],
     'init_xml': [],
     'update_xml': ['project_mrp_workflow.xml', 
                    #'process/project_mrp_process.xml',
index 43217d6..cd242e7 100644 (file)
@@ -1,9 +1,9 @@
 <?xml version="1.0"?>
 <openerp>
 <data>
-    <record model="workflow.transition" id="mrp_procurement.trans_produce_service_make_done">
-        <field name="act_from" ref="mrp_procurement.act_produce_service"/>
-        <field name="act_to" ref="mrp_procurement.act_make_done"/>
+    <record model="workflow.transition" id="procurement.trans_produce_service_make_done">
+        <field name="act_from" ref="procurement.act_produce_service"/>
+        <field name="act_to" ref="procurement.act_make_done"/>
         <field name="signal">subflow.done</field>
     </record>
 </data>
index 46d7c32..5b3830f 100644 (file)
@@ -31,7 +31,7 @@
     """,
     'author': 'Tiny',
     'website': 'http://www.openerp.com',
-    'depends': ['base', 'account', 'stock', 'process', 'mrp_procurement'],
+    'depends': ['base', 'account', 'stock', 'process', 'procurement'],
     'init_xml': [],
     'update_xml': [
                    
index 8aa643d..8495ef4 100644 (file)
         <record id="view_procurement_form_inherit" model="ir.ui.view">
                <field name="name">mrp.procurement.form.inherit</field>
                <field name="model">mrp.procurement</field>
-               <field name="inherit_id" ref="mrp_procurement.mrp_procurement_form_view"/>
+               <field name="inherit_id" ref="procurement.mrp_procurement_form_view"/>
                <field name="type">form</field>
                <field name="arch" type="xml">
                        <xpath expr="/form/notebook/page/field[@name='close_move']" position="before">
index d7684be..d14530e 100644 (file)
        
        <!-- Procurement -->
                <record id="act_buy" model="workflow.activity">
-            <field name="wkf_id" ref="mrp_procurement.wkf_procurement"/>
+            <field name="wkf_id" ref="procurement.wkf_procurement"/>
             <field name="name">buy</field>
             <field name="kind">subflow</field>
             <field name="subflow_id" search="[('osv','=','purchase.order')]"/>
         </record>
         
         <record id="trans_confirm_mto_buy" model="workflow.transition">
-            <field name="act_from" ref="mrp_procurement.act_confirm_mto"/>
+            <field name="act_from" ref="procurement.act_confirm_mto"/>
             <field name="act_to" ref="act_buy"/>
             <field name="condition">check_buy()</field>
         </record>
         
         <record id="trans_buy_make_done" model="workflow.transition">
             <field name="act_from" ref="act_buy"/>
-            <field name="act_to" ref="mrp_procurement.act_make_done"/>
+            <field name="act_to" ref="procurement.act_make_done"/>
             <field name="signal">subflow.delivery_done</field>
         </record>
         
         <record id="trans_buy_cancel" model="workflow.transition">
             <field name="act_from" ref="act_buy"/>
-            <field name="act_to" ref="mrp_procurement.act_cancel"/>
+            <field name="act_to" ref="procurement.act_cancel"/>
             <field name="signal">subflow.cancel</field>
         </record>
 
index d432783..2f265b3 100644 (file)
@@ -42,7 +42,7 @@
     """,
     'author': 'Tiny',
     'website': 'http://www.openerp.com',
-    'depends': ['product', 'stock', 'mrp_procurement', 'process'],
+    'depends': ['product', 'stock', 'procurement', 'process'],
     'init_xml': [],
     'update_xml': [
         'wizard/sale_make_invoice_advance.xml',
index 58e4be1..5b71c05 100644 (file)
@@ -35,7 +35,7 @@
             <field eval="&quot;&quot;&quot;Sale Order Requisition&quot;&quot;&quot;" name="name"/>
             <field eval="&quot;&quot;&quot;Drives procurement orders for every sale order line.&quot;&quot;&quot;" name="note"/>
             <field name="subflow_id" ref="process_process_salesprocess0"/>
-            <field name="process_id" ref="mrp_procurement.process_process_procurementprocess0"/>
+            <field name="process_id" ref="procurement.process_process_procurementprocess0"/>
             <field eval="&quot;&quot;&quot;object.state in ('draft', 'waiting_date', 'manual', 'progress', 'shipping_except', 'invoice_except', 'done', 'cancel')&quot;&quot;&quot;" name="model_states"/>
             <field eval="1" name="flow_start"/>
         </record>
@@ -63,8 +63,8 @@
         </record>
 
         <record id="process_node_saleprocurement0" model="process.node">
-            <field name="menu_id" ref="mrp_procurement.menu_mrp_procurement_action"/>
-            <field name="model_id" ref="mrp_procurement.model_mrp_procurement"/>
+            <field name="menu_id" ref="procurement.menu_mrp_procurement_action"/>
+            <field name="model_id" ref="procurement.model_mrp_procurement"/>
             <field eval="&quot;&quot;&quot;subflow&quot;&quot;&quot;" name="kind"/>
             <field eval="&quot;&quot;&quot;Procurement Order&quot;&quot;&quot;" name="name"/>
             <field eval="&quot;&quot;&quot;One Procurement order for each sale order line and for each of the components.&quot;&quot;&quot;" name="note"/>
             <field eval="[(6,0,[])]" name="transition_ids"/>
             <field eval="&quot;&quot;&quot;Procurement of sold material&quot;&quot;&quot;" name="name"/>
             <field eval="&quot;&quot;&quot;For every sale order line, a procurement order is created to supply the sold product.&quot;&quot;&quot;" name="note"/>
-            <field model="process.node" name="target_node_id" ref="mrp_procurement.process_node_procureproducts0"/>
+            <field model="process.node" name="target_node_id" ref="procurement.process_node_procureproducts0"/>
             <field model="process.node" name="source_node_id" ref="process_node_saleorderprocurement0"/>
         </record>
 
index 7af8c1e..726cd67 100644 (file)
@@ -11,7 +11,7 @@
 "access_account_analytic_account_salesman","account_analytic_account salesman","analytic.model_account_analytic_account","group_sale_user",1,1,1,1
 "access_stock_picking_salesman","stock_picking salesman","stock.model_stock_picking","group_sale_user",1,1,1,1
 "access_stock_move_salesman","stock_move salesman","stock.model_stock_move","group_sale_user",1,1,1,0
-"access_mrp_procurement_salesman","mrp.procurement salesman","mrp_procurement.model_mrp_procurement","group_sale_user",1,1,1,1
+"access_mrp_procurement_salesman","mrp.procurement salesman","procurement.model_mrp_procurement","group_sale_user",1,1,1,1
 "access_sale_order_stock_worker","sale.order stock worker","model_sale_order","stock.group_stock_user",1,1,0,0
 "access_sale_order_line_stock_worker","sale.order.line stock worker","model_sale_order_line","stock.group_stock_user",1,1,0,0
 "access_sale_order_manager","sale.order.manager","model_sale_order","group_sale_manager",1,1,1,1