[MERGE]
authorHarry (Open ERP) <hmo@tinyerp.com>
Thu, 11 Mar 2010 14:24:49 +0000 (19:54 +0530)
committerHarry (Open ERP) <hmo@tinyerp.com>
Thu, 11 Mar 2010 14:24:49 +0000 (19:54 +0530)
bzr revid: hmo@tinyerp.com-20100311142449-gfhiuwigpchfr074

52 files changed:
1  2 
addons/caldav/caldav_node.py
addons/delivery/__terp__.py
addons/delivery/delivery_wizard.xml
addons/delivery/wizard/delivery_sale_order.py
addons/delivery/wizard/delivery_sale_order_view.xml
addons/mrp/__init__.py
addons/mrp/__terp__.py
addons/mrp/mrp.py
addons/mrp/mrp_view.xml
addons/mrp/mrp_wizard.py
addons/mrp/mrp_wizard.xml
addons/mrp/mrp_wizard_view.xml
addons/mrp/schedulers.py
addons/mrp/wizard/__init__.py
addons/mrp/wizard/change_production_qty.py
addons/mrp/wizard/change_production_qty_view.xml
addons/mrp/wizard/make_procurement_product.py
addons/mrp/wizard/make_procurement_view.xml
addons/mrp/wizard/mrp_product_produce.py
addons/mrp/wizard/mrp_product_produce_view.xml
addons/mrp/wizard/orderpoint_procurement.py
addons/mrp/wizard/orderpoint_procurement_view.xml
addons/mrp/wizard/schedulers_all_view.xml
addons/mrp_repair/__terp__.py
addons/mrp_repair/mrp_repair.py
addons/mrp_repair/mrp_repair_wizard.xml
addons/mrp_repair/wizard/cancel_repair.py
addons/mrp_repair/wizard/mrp_repair_cancel_view.xml
addons/mrp_repair/wizard/mrp_repair_make_invoice_view.xml
addons/point_of_sale/wizard/pos_add_product.py
addons/point_of_sale/wizard/pos_add_product.xml
addons/product_margin/product_margin_view.xml
addons/product_margin/wizard/product_margin.py
addons/product_margin/wizard/product_margin_view.xml
addons/sale/wizard/sale_line_invoice.py
addons/sale/wizard/sale_line_invoice.xml
addons/sale/wizard/sale_make_invoice_advance.xml
addons/stock/__init__.py
addons/stock/__terp__.py
addons/stock/stock_view.xml
addons/stock/stock_wizard.py
addons/stock/stock_wizard_view.xml
addons/stock/wizard/__init__.py
addons/stock/wizard/stock_fill_inventory.py
addons/stock/wizard/stock_fill_inventory_view.xml
addons/stock/wizard/stock_inventory_set_stock_zero.py
addons/stock/wizard/stock_inventory_set_stock_zero_view.xml
addons/stock/wizard/stock_invoice_onshipping_view.xml
addons/stock/wizard/stock_location_product.py
addons/stock/wizard/stock_location_product_view.xml
addons/stock/wizard/stock_move.py
addons/stock/wizard/stock_move_view.xml

@@@ -64,6 -64,6 +64,9 @@@ class node_calendar(object)
  
      def _get_ttag(self,cr):
          return 'calendar-%d' % self.calendar_id
++    
++    def get_dav_eprop(self,cr,ns,prop):
++        return None
  
  class Calendar(osv.osv):
      _inherit = 'basic.calendar'
@@@ -30,8 -30,9 +30,8 @@@
      'init_xml': ['delivery_data.xml'],
      'update_xml': [
          'security/ir.model.access.csv',
-         'delivery_view.xml',
-         'delivery_wizard.xml',
+         'wizard/delivery_sale_order_view.xml',
 -        'delivery_view.xml',
 -        'delivery_wizard.xml',
++        'delivery_view.xml',        
          'partner_view.xml'
      ],
      'demo_xml': ['delivery_demo.xml'],
diff --cc addons/delivery/delivery_wizard.xml
index b497e61,89c66e7..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,8 -1,8 +1,0 @@@
--<?xml version="1.0" encoding="utf-8"?>
--<openerp>
--    <data>
--        
-         <wizard id="wizard_deliver_line_add" keyword="client_action_multi" model="sale.order" name="delivery.sale.order" string="Delivery Costs"/>
-         
-     </data>
- </openerp>
 -<!--        <wizard id="wizard_deliver_line_add" keyword="client_action_multi" model="sale.order" name="delivery.sale.order" string="Delivery Costs"/>-->
 -        
 -    </data>
 -</openerp>
index c7870e4,0000000..c1896e6
mode 100644,000000..100644
--- /dev/null
@@@ -1,96 -1,0 +1,112 @@@
 +# -*- 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 time
- import wizard
 +import ir
- import pooler
 +from tools.translate import _
 +
- from tools.misc import UpdateableStr
++from osv import osv, fields
 +
- delivery_form = UpdateableStr()
++class make_delivery(osv.osv_memory):
++    _name = "delivery.sale.order"
++    _description = 'Make Delievery'
 +
- delivery_fields = {
-     'carrier_id' : {'string':'Delivery Method', 'type':'many2one', 'relation': 'delivery.carrier','required':True}
- }
- def _delivery_default(self, cr, uid, data, context):
-     order_obj = pooler.get_pool(cr.dbname).get('sale.order')
-     order = order_obj.browse(cr, uid, data['ids'])[0]
-     delivery_form.string="""<?xml version="1.0"?>
-     <form string="Create deliveries">
-         <separator colspan="4" string="Delivery Method" />
-         <field name="carrier_id" context="{'order_id': %d}"/>
-     </form>
-     """ % (data['id'],)
-     if not order.state in ('draft'):
-         raise wizard.except_wizard(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
-     carrier_id = order.partner_id.property_delivery_carrier.id
-     return {'carrier_id': carrier_id}
- def _delivery_set(self, cr, uid, data, context):
-     order_obj = pooler.get_pool(cr.dbname).get('sale.order')
-     line_obj = pooler.get_pool(cr.dbname).get('sale.order.line')
-     order_objs = order_obj.browse(cr, uid, data['ids'], context)
-     for order in order_objs:
-         grid_id = pooler.get_pool(cr.dbname).get('delivery.carrier').grid_get(cr, uid, [data['form']['carrier_id']],order.partner_shipping_id.id)
-         if not grid_id:
-             raise wizard.except_wizard(_('No grid avaible !'), _('No grid matching for this carrier !'))
-         grid_obj=pooler.get_pool(cr.dbname).get('delivery.grid')
-         grid = grid_obj.browse(cr, uid, [grid_id])[0]
-         taxes = grid.carrier_id.product_id.taxes_id
-         fpos = order.fiscal_position or False
-         taxes_ids = pooler.get_pool(cr.dbname).get('account.fiscal.position').map_tax(cr, uid, fpos, taxes)
-         line_obj.create(cr, uid, {
-             'order_id': order.id,
-             'name': grid.carrier_id.name,
-             'product_uom_qty': 1,
-             'product_uom': grid.carrier_id.product_id.uom_id.id,
-             'product_id': grid.carrier_id.product_id.id,
-             'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
-             'tax_id': [(6,0,taxes_ids)],
-             'type': 'make_to_stock'
-         })
++    _columns = {
++        'carrier_id': fields.many2one('delivery.carrier','Delivery Method', required=True),
++    }
 +
-     return {}
 +
- class make_delivery(wizard.interface):
-     states = {
-         'init' : {
-             'actions' : [_delivery_default],
-             'result' : {'type' : 'form', 'arch' : delivery_form, 'fields' : delivery_fields, 'state' : [('end', 'Cancel', 'gtk-cancel'),('delivery', 'Add Delivery Costs', 'gtk-ok') ]}
-         },
-         'delivery' : {
-             'actions' : [_delivery_set],
-             'result' : {'type' : 'state', 'state' : 'end'}
-         },
-     }
- make_delivery("delivery.sale.order")
++    def default_get(self, cr, uid, fields, context):
++        """ 
++             @summary: 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. 
++        
++        """        
++        rec_id = context and context.get('active_id',False)        
++        res = {}
++        order_obj = self.pool.get('sale.order')
++        order = order_obj.browse(cr, uid, rec_id)
++    
++        if not order.state in ('draft'):
++            raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
++    
++        carrier_id = order.partner_id.property_delivery_carrier.id
++        res['carrier_id'] = carrier_id
++        return res
++    
++    def delivery_set(self, cr, uid, ids, context):
++        """ 
++             @summary: Adds delivery costs to Sale Order Line.
++            
++             @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:  
++        
++        """
++        rec_ids = context and context.get('active_ids',[])
++        order_obj = self.pool.get('sale.order')
++        line_obj = self.pool.get('sale.order.line')
++        grid_obj = self.pool.get('delivery.grid')
++        carrier_obj = self.pool.get('delivery.carrier')
++        acc_fp_obj = self.pool.get('account.fiscal.position')
++        order_objs = order_obj.browse(cr, uid, rec_ids, context)
++        for datas in self.browse(cr, uid, ids):    
++            for order in order_objs:
++                grid_id = carrier_obj.grid_get(cr, uid, [datas.carrier_id.id],order.partner_shipping_id.id)
++                if not grid_id:
++                    raise osv.except_osv(_('No grid available !'), _('No grid matching for this carrier !'))
++
++                if not order.state in ('draft'):
++                    raise osv.except_osv(_('Order not in draft state !'), _('The order state have to be draft to add delivery lines.'))
++                
++                grid = grid_obj.browse(cr, uid, grid_id)
++        
++                taxes = grid.carrier_id.product_id.taxes_id
++                fpos = order.fiscal_position or False
++                taxes_ids = acc_fp_obj.map_tax(cr, uid, fpos, taxes)
++                line_obj.create(cr, uid, {
++                    'order_id': order.id,
++                    'name': grid.carrier_id.name,
++                    'product_uom_qty': 1,
++                    'product_uom': grid.carrier_id.product_id.uom_id.id,
++                    'product_id': grid.carrier_id.product_id.id,
++                    'price_unit': grid_obj.get_price(cr, uid, grid.id, order, time.strftime('%Y-%m-%d'), context),
++                    'tax_id': [(6,0,taxes_ids)],
++                    'type': 'make_to_stock'
++                })
++    
++        return {}
++
++make_delivery()
 +
 +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
 +
index 0000000,795ebb7..c2609bc
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,46 +1,36 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+         
+         <!--  Delivery Sale Order -->
+         
+               <record id="view_make_delivery_wizard" model="ir.ui.view">
 -            <field name="name">Create Deliveries</field>
++            <field name="name">Delivery Costs</field>
+             <field name="model">delivery.sale.order</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                 <form string="Create Deliveries">
+                       <separator colspan="4" string="Delivery Method" />
+                                   <field name="carrier_id"/>
+                                   <newline/>
+                                   <group col="2" colspan="4">
+                               <button icon='gtk-cancel' special="cancel"
+                                       string="Cancel" />
+                               <button name="delivery_set" string="Add Delivery Costs"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                 </form>
+             </field>
+         </record>
 -        <record id="action_make_delivery" model="ir.actions.act_window">
 -            <field name="name">Create Deliveries</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">delivery.sale.order</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id': active_id, 'active_ids': active_ids}</field>
 -        </record>
++        <act_window name="Delivery Costs"                 
++                  res_model="delivery.sale.order"
++                  src_model="sale.order"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="act_delivery_cost"/>
 -       <record model="ir.values" id="values_make_delivery">
 -            <field name="model_id" ref="sale.model_sale_order" />
 -            <field name="object" eval="1" />
 -            <field name="name">Create Deliveries</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_delivery'))"/>
 -            <field name="key">action</field>
 -            <field name="model">sale.order</field>
 -        </record>
++       
+       </data>
+ </openerp>    
@@@ -21,7 -21,7 +21,6 @@@
  
  import mrp
  import installer
--import mrp_wizard
  import wizard
  import report
  import company
          'security/ir.model.access.csv',
          'mrp_workflow.xml',
          'mrp_data.xml',
--        'mrp_wizard_view.xml',
++        'wizard/mrp_product_produce_view.xml',
+         'wizard/make_procurement_view.xml',
+         'wizard/change_production_qty_view.xml',
+         'wizard/orderpoint_procurement_view.xml',
          'mrp_view.xml',
+         'wizard/schedulers_all_view.xml',
          'mrp_wizard.xml',
          'mrp_report.xml',
          'company_view.xml',
@@@ -188,7 -188,8 +188,7 @@@ class mrp_bom(osv.osv)
          'revision_type': fields.selection([('numeric','numeric indices'),('alpha','alphabetical indices')], 'Index type'),
          'child_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
          'child_complete_ids': fields.function(_child_compute,relation='mrp.bom', method=True, string="BoM Hierarchy", type='many2many'),
--        'company_id': fields.many2one('res.company','Company',required=True),
 -        'multi_level_bom': fields.boolean('Multi-level BoM'),
++        'company_id': fields.many2one('res.company','Company',required=True),        
      }
      _defaults = {
          'active': lambda *a: 1,
          'product_qty': lambda *a: 1.0,
          'product_rounding': lambda *a: 1.0,
          'type': lambda *a: 'normal',
-         'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c)
 -        'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c),
 -        'multi_level_bom': lambda *a: 0, 
++        'company_id': lambda self,cr,uid,c: self.pool.get('res.company')._company_default_get(cr, uid, 'mrp.bom', context=c),        
      }
      _order = "sequence"
      _sql_constraints = [
@@@ -375,30 -377,30 +375,7 @@@ class one2many_domain(fields.one2many)
  class mrp_production(osv.osv):
      _name = 'mrp.production'
      _description = 'Production'
--    _date_name  = 'date_planned'
--
--    def _get_sale_order(self,cr,uid,ids,field_name=False):
--        move_obj=self.pool.get('stock.move')
--        def get_parent_move(move_id):
--            move = move_obj.browse(cr,uid,move_id)
--            if move.move_dest_id:
--                return get_parent_move(move.move_dest_id.id)
--            return move_id
--        productions=self.read(cr,uid,ids,['id','move_prod_id'])
--        res={}
--        for production in productions:
--            res[production['id']]=False
--            if production.get('move_prod_id',False):
--                parent_move_line=get_parent_move(production['move_prod_id'][0])
--                if parent_move_line:
--                    move = move_obj.browse(cr,uid,parent_move_line)
--                    #TODO: fix me sale module can not be used here,
--                    #as may be mrp can be installed without sale module
--                    if field_name=='name':
--                        res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.name or False
--                    if field_name=='client_order_ref':
--                        res[production['id']]=move.sale_line_id and move.sale_line_id.order_id.client_order_ref or False
--        return res
++    _date_name  = 'date_planned'    
  
      def _production_calc(self, cr, uid, ids, prop, unknow_none, context={}):
          result = {}
              result[prod.id] = prod.date_planned[:10]
          return result
  
--    def _sale_name_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
--        return self._get_sale_order(cr,uid,ids,field_name='name')
--
--    def _sale_ref_calc(self, cr, uid, ids, prop, unknow_none, unknow_dict):
--        return self._get_sale_order(cr,uid,ids,field_name='client_order_ref')
++    def _ref_calc(self, cr, uid, ids, field_names=None, arg=False, context={}):
++        res = {}
++        for f in field_names:
++            for order_id in ids:
++                res[order_id] = {f:False}
++        return res
  
      _columns = {
          'name': fields.char('Reference', size=64, required=True),
          'hour_total': fields.function(_production_calc, method=True, type='float', string='Total Hours', multi='workorder'),
          'cycle_total': fields.function(_production_calc, method=True, type='float', string='Total Cycles', multi='workorder'),
  
--        'sale_name': fields.function(_sale_name_calc, method=True, type='char', string='Sale Name', help='Indicate the name of sale order.'),
--        'sale_ref': fields.function(_sale_ref_calc, method=True, type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
++        'sale_name': fields.function(_ref_calc, method=True, multi='sale_name', type='char', string='Sale Name', help='Indicate the name of sale order.'),
++        'sale_ref': fields.function(_ref_calc, method=True, multi='sale_ref', type='char', string='Sale Reference', help='Indicate the Customer Reference from sale order.'),
          'company_id': fields.many2one('res.company','Company',required=True),
      }
      _defaults = {
                      <field name="cycle_total" operator="+"/>
                  </graph>
              </field>
--        </record>
--
-         <wizard
-             string="Change Product Qty."
-             model="mrp.production"
-             name="change_production_qty"
-             id="mrp.wizard_change_production_qty"
-             keyword="client_action_multi"
-             multi="True"/>
 -<!--        <wizard-->
 -<!--            string="Change Product Qty."-->
 -<!--            model="mrp.production"-->
 -<!--            name="change_production_qty"-->
 -<!--            id="mrp.wizard_change_production_qty"-->
 -<!--            keyword="client_action_multi"-->
 -<!--            multi="True"/>-->
++        </record>        
  
          <record id="mrp_production_form_view" model="ir.ui.view">
              <field name="name">mrp.production.form</field>
                              <field colspan="2" name="move_lines" nolabel="1" widget="one2many_list"
                                  mode="tree,form" height="275" domain="[('state','&lt;&gt;', ('done', 'cancel'))]">
                                  <tree string="Products to Consume">
 -                                    <field name="product_id" select="1"/>
 -                                                  <field name="product_qty" select="1" string="Qty"/>
 -                                                  <field name="product_uom" select="1" string="UOM"/>
 +                                    <field name="product_id" />
-                                     <field name="product_qty" />
-                                     <field name="product_uom" />
-                                     <field name="state" invisible="1" />
-                                     <button
-                                         name="%(stock.move_consume)d"
-                                         string=">" type="action"
-                                         icon="gtk-go-forward" context="{'consume': True}"
-                                         states="draft,waiting,confirmed,assigned"/>
-                                     <button name="%(stock.move_scrap)d"
-                                         string="D" type="action"
-                                         icon="gtk-justify-fill" context="{'scrap': True}"
-                                         states="draft,waiting,confirmed,assigned" />
++                                                  <field name="product_qty"  string="Qty"/>
++                                                  <field name="product_uom"  string="UOM"/>
+                                                   <button name="%(stock.move_consume)d"
+                                                       string="Consume Products" type="action"
+                                                       icon="gtk-go-forward" context="{'consume': True}"
+                                                       states="draft,waiting,confirmed,assigned" />
+                                                   <button name="%(stock.move_scrap)d"
+                                                       string="Scrap Products" type="action"
+                                                       icon="gtk-justify-fill" context="{'scrap': True}"
 -                                                      states="draft,waiting,confirmed,assigned" />
 -                                                  <field name="state"/>
 -                                                  <field name="location_id" select="1" string="Source" />
 -                                                  <field name="location_dest_id" select="1" string="Destination"/>
 -                                                  <field name="prodlot_id" select="1"/>
++                                                      states="draft,waiting,confirmed,assigned" />                                                
                                  </tree>
-                                 <form string="Products to Consume">
-                                     <field name="product_id" />
-                                     <field name="product_qty" />
-                                     <field name="product_uom" />
-                                 </form>
                              </field>
  
                              <field colspan="2" name="move_lines2" nolabel="1"  domain="[('state','in', ('done', 'cancel'))]"
                                                widget="one2many_list" mode="tree,form" height="275">
-                                       <tree string="Consumed Products" editable="bottom">
+                                       <tree string="Consumed Products" editable="bottom" colors="red:state=='cancel';black:state=='done';">
                                                <field name="product_id" readonly="1"/>
-                                               <field name="product_qty" readonly="1"/>
-                                               <field name="product_uom" readonly="1" />
-                                               <field name="state" invisible="1" />
-                                               <field name="location_id" readonly="1"/>
-                                               <field name="prodlot_id" />
 -                                              <field name="product_qty" select="1" string="Qty"/>
 -                                                  <field name="product_uom" select="1" string="UOM"/>
++                                              <field name="product_qty" readonly="1" string="Qty"/>
++                                                  <field name="product_uom" readonly="1" string="UOM"/>
++                                    <field name="location_dest_id"  readonly="1" string="Destination"/>
++                                                  <field name="prodlot_id" />
                                                <button
                                                        name="%(stock.track_line)d"
                                                        string="Split in production lots"
                                                        states="done,cancel" />
                                                <button
                                                        name="%(stock.move_scrap)d"
-                                                       string="D" type="action"
+                                                       string="Scrap Products" type="action"
                                                        icon="gtk-convert"
--                                                      states="done,cancel" />
 -                                              <field name="state"/>
 -                                                  <field name="location_id" select="1" string="Source" />
 -                                                  <field name="location_dest_id" select="1" string="Destination"/>
 -                                                  <field name="prodlot_id" select="1"/>
++                                                      states="done,cancel" />                                                 
++                                                  
                                        </tree>
-                                       <form string="Consumed Products">
-                                               <field name="product_id" />
-                                               <field name="product_qty" />
-                                               <field name="product_uom" />
-                                       </form>
                                </field>
  
                              <group col="9" colspan="4">
                              <field colspan="2" name="move_created_ids" nolabel="1" widget="one2many_list"
                                  mode="tree,form" height="275" domain="[('state','&lt;&gt;', ('done', 'cancel'))]">
                                  <tree string="Products to Finish">
 -                                    <field name="product_id" select="1"/>
 -                                                  <field name="product_qty" select="1" string="Qty"/>
 -                                                  <field name="product_uom" select="1" string="UOM"/>
 +                                    <field name="product_id" />
-                                     <field name="product_qty" />
-                                     <field name="product_uom" />
-                                     <field name="state" invisible="1" />
-                                     <button
-                                         name="%(stock.move_consume)d"
-                                         string=">" type="action"
-                                         icon="gtk-go-forward"
-                                         states="draft,waiting,confirmed,assigned"/>
-                                     <button name="%(stock.move_scrap)d"
-                                         string="D" type="action"
-                                         icon="gtk-justify-fill" context="{'scrap': True}"
-                                         states="draft,waiting,confirmed,assigned" />
++                                                  <field name="product_qty"  string="Qty"/>
++                                                  <field name="product_uom"  string="UOM"/>
+                                                   <button name="%(stock.move_consume)d"
+                                                       string="Consume Products" type="action"
+                                                       icon="gtk-go-forward" context="{'consume': True}"
+                                                       states="draft,waiting,confirmed,assigned" />
+                                                   <button name="%(stock.move_scrap)d"
+                                                       string="Scrap Products" type="action"
+                                                       icon="gtk-justify-fill" context="{'scrap': True}"
 -                                                      states="draft,waiting,confirmed,assigned" />
 -                                                  <field name="state"/>
 -                                                  <field name="location_id" select="1" string="Source" />
 -                                                  <field name="location_dest_id" select="1" string="Destination"/>
 -                                                  <field name="prodlot_id" select="1"/>
++                                                      states="draft,waiting,confirmed,assigned" />                                                
                                  </tree>
-                                 <form string="Products to Finish">
-                                     <field name="product_id" />
-                                     <field name="product_qty" />
-                                     <field name="product_uom" />
-                                 </form>
                              </field>
  
                              <field colspan="2" name="move_created_ids2" nolabel="1"  domain="[('state','in', ('done', 'cancel'))]"
                                        <tree string="Finished Products" editable="bottom">
                                                <field name="product_id" readonly="1"/>
                                                <field name="product_qty" readonly="1"/>
--                                              <field name="product_uom" readonly="1" />
--                                              <field name="state" invisible="1" />
++                                              <field name="product_uom" readonly="1" />                                               
                                                <field name="location_id" readonly="1"/>
                                                <field name="prodlot_id" />
                                                <button name="%(stock.track_line)d"
diff --cc addons/mrp/mrp_wizard.py
index 40d9f2e,40d9f2e..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,59 -1,59 +1,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 fields, osv
--from tools.translate import _
--import netsvc
--
--class mrp_product_produce(osv.osv_memory):
--    _name = "mrp.product.produce"
--    _description = "Product Produce"
--    
--    _columns = {
--        'product_qty': fields.float('Quantity', required=True), 
--        'mode': fields.selection([('consume_produce', 'Consume & Produce'), 
--                                  ('consume', 'Consume Only')], 'Mode', required=True)
--    }
--
--    def _get_product_qty(self, cr, uid, context):
--        prod = self.pool.get('mrp.production').browse(cr, uid, 
--                                context['active_id'], context=context)
--        done = 0.0
--        for move in prod.move_created_ids2:
--                done += move.product_qty
--        return (prod.product_qty - done) or prod.product_qty
--    
--    _defaults = {
--                 'product_qty': _get_product_qty, 
--                 'mode': lambda *x: 'consume_produce'
--                 }
--
--    def do_produce(self, cr, uid, ids, context={}):
--        prod_obj = self.pool.get('mrp.production')
--        move_ids = context['active_ids']
--        for data in self.read(cr, uid, ids):
--            for move_id in move_ids:
--                prod_obj.do_produce(cr, uid, move_id, 
--                                    data['product_qty'], data['mode'], context=context)
--        return {}
--
--mrp_product_produce()
--
@@@ -1,17 -1,17 +1,6 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
      <data>
-         <wizard id="wiz_mrp_proc0" model="mrp.procurement" string="Compute Schedulers" name="mrp.procurement.compute.all"/>
-         <menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
-         <menuitem action="wiz_mrp_proc0" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" type="wizard" sequence="90"/>
-         <!--
-           <menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/>
-         -->
-         <wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>
-         <!--
-              <menuitem action="wiz_mrp_proc2" id="menu_wiz_mrp_proc2" parent="mrp.mrp_Sched_all" type="wizard"/>
-         -->
 -<!--        <wizard id="wiz_mrp_proc0" model="mrp.procurement" string="Compute Schedulers" name="mrp.procurement.compute.all"/>-->
 -<!--        <menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>-->
 -<!--        <menuitem action="wiz_mrp_proc0" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" type="wizard" sequence="90"/>-->
 -        <!--
 -          <menuitem action="wiz_mrp_proc1" id="menu_wiz_mrp_proc1" parent="mrp.mrp_Sched_all" type="wizard"/>
 -        -->
 -
 -<!--        <wizard id="wiz_mrp_proc2" model="mrp.procurement" string="Compute Stock Minimum Rules Only" name="mrp.procurement.orderpoint.compute"/>-->
 -        <!--
 -             <menuitem action="wiz_mrp_proc2" id="menu_wiz_mrp_proc2" parent="mrp.mrp_Sched_all" type="wizard"/>
 -        -->
  
          <wizard id="wizard_workcenter_load" model="mrp.workcenter" name="mrp.workcenter.load" string="Work Center load"/>
  
              <field eval="True" name="object"/>
          </record>
  
-         <wizard
-             string="Requisition Request"
-             model="product.product"
-             name="product.product.procurement"
-             keyword="client_action_multi"
-             id="product_procurement_wizard"/>
 -<!--        <wizard-->
 -<!--            string="Requisition Request"-->
 -<!--            model="product.product"-->
 -<!--            name="product.product.procurement"-->
 -<!--            keyword="client_action_multi"-->
 -<!--            id="product_procurement_wizard"/>-->
 -
      </data>
  </openerp>
diff --cc addons/mrp/mrp_wizard_view.xml
index f730c4a,f730c4a..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,41 -1,41 +1,0 @@@
--<?xml version="1.0" encoding="utf-8"?>
--<openerp>
--    <data>
--    
--        
--        <!--  Produce -->
--        
--              <record id="view_mrp_product_produce_wizard" model="ir.ui.view">
--            <field name="name">MRP Product Produce</field>
--            <field name="model">mrp.product.produce</field>
--            <field name="type">form</field>
--            <field name="arch" type="xml">
--                <form string="Produce">
--                      <separator string="Produce" colspan="4"/>
--                                  <field name="mode" colspan="4"/>
--                                  <field name="product_qty" colspan="2"/>
--                      <newline/>
--                      <separator string="" colspan="4" />
--                      <label string="" colspan="2" />
--                      <group col="2" colspan="1">
--                              <button icon='gtk-cancel' special="cancel"
--                                      string="Cancel" />
--                              <button name="do_produce" string="Confirm"
--                                      colspan="1" type="object" icon="gtk-ok" />
--                      </group>
--                </form>
--            </field>
--        </record>
--
--        <record id="act_mrp_product_produce" model="ir.actions.act_window">
--            <field name="name">Produce</field>
--            <field name="type">ir.actions.act_window</field>
--            <field name="res_model">mrp.product.produce</field>
--            <field name="view_type">form</field>
--            <field name="view_mode">form</field>
--            <field name="target">new</field>
--        </record>    
--        
--        
--      </data>
--</openerp>    
@@@ -195,9 -195,9 +195,9 @@@ class mrp_procurement(osv.osv)
                      qty = max(op.product_min_qty, op.product_max_qty)-prods
                      reste = qty % op.qty_multiple
                      if reste > 0:
--                        qty += op.qty_multiple - reste
++                        qty += op.qty_multiple - reste                    
                      newdate = DateTime.now() + DateTime.RelativeDateTime(
--                            days=op.product_id.seller_delay)
++                            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':
  #
  ##############################################################################
  
- import wizard_orderpoint_procurement
++import mrp_product_produce
+ import orderpoint_procurement
  import wizard_procurement
- import wizard_schedulers_all
+ import schedulers_all
  import wizard_price
  import wizard_workcenter_load
  import wizard_track_prod
index 0000000,292e8a3..cf3a906
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,111 +1,114 @@@
+ # -*- 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 time
+ import ir
+ from osv.osv import except_osv
+ from osv import fields, osv
+ import netsvc
+ from tools.translate import _
+ class change_production_qty(osv.osv_memory):
+     _name = 'change.production.qty'
+     _description = 'Change Quantity of Products'
+     
+     _columns = {
+         'product_qty': fields.float('Product Qty', required=True),
+     }
+     def default_get(self, cr, uid, fields, context):
+         """ 
+              @summary: 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('record_id',False)
++        """        
+         res = {}
++        record_id = context and context.get('active_id',False)
++        if not record_id:
++           return res
+         prod_obj = self.pool.get('mrp.production')
+         prod = prod_obj.browse(cr, uid, record_id)
 -        if prod.state in ('cancel', 'done'):
++        if prod.state in ('in_production','cancel', 'done'):
+             raise osv.except_osv(_('Warning !'), _('The production is in "%s" state. You can not change the production quantity anymore') % (prod.state).upper() )
 -        if prod.state in ('draft'):
 -            return res
 -        if record_id:
 -            res['product_qty'] = prod.product_qty
++        
++        res['product_qty'] = prod.product_qty        
+         return res
+     
+     def change_prod_qty(self, cr, uid, ids, context):
+         """ 
+              @summary: Changes the Quantity of 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:  
+         
+         """
 -        record_id = context and context.get('record_id',False)
++        record_id = context and context.get('active_id',False)
++        assert record_id, _('Active Id is not found')
+         prod_obj = self.pool.get('mrp.production')
 -        wiz_qty = self.browse(cr, uid, ids[0])
 -        prod = prod_obj.browse(cr, uid,record_id)
 -        prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty})
 -        prod_obj.action_compute(cr, uid, [prod.id])
 -    
 -        move_lines_obj = self.pool.get('stock.move')
 -        for move in prod.move_lines:
 -            bom_point = prod.bom_id
 -            bom_id = prod.bom_id.id
 -            if not bom_point:
 -                bom_id = self.pool.get('mrp.bom')._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
++        product_lines_obj = self.pool.get('mrp.production.product.line')
++        bom_obj = self.pool.get('mrp.bom')
++        for wiz_qty in self.browse(cr, uid, ids):
++            prod = prod_obj.browse(cr, uid,record_id)
++            prod_obj.write(cr, uid,prod.id, {'product_qty': wiz_qty.product_qty})
++            prod_obj.action_compute(cr, uid, [prod.id])
++        
++            move_lines_obj = self.pool.get('stock.move')
++            for move in prod.move_lines:
++                bom_point = prod.bom_id
++                bom_id = prod.bom_id.id
++                if not bom_point:
++                    bom_id = bom_obj._bom_find(cr, uid, prod.product_id.id, prod.product_uom.id)
++                    if not bom_id:
++                        raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
++                    prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
++                    bom_point = sbom_obj.browse(cr, uid, [bom_id])[0]
++        
+                 if not bom_id:
+                     raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
 -                prod_obj.write(cr, uid, [prod.id], {'bom_id': bom_id})
 -                bom_point = self.pool.get('mrp.bom').browse(cr, uid, [bom_id])[0]
 -    
 -            if not bom_id:
 -                raise osv.except_osv(_('Error'), _("Couldn't find bill of material for product"))
 -    
 -            factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
 -            res = self.pool.get('mrp.bom')._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
 -            for r in res[0]:
 -                if r['product_id']== move.product_id.id:
 -                    move_lines_obj.write(cr, uid,move.id, {'product_qty' :  r['product_qty']})
 -    
 -        product_lines_obj = self.pool.get('mrp.production.product.line')
 -    
 -        for m in prod.move_created_ids:
 -            move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty})
++        
++                factor = prod.product_qty * prod.product_uom.factor / bom_point.product_uom.factor
++                res = bom_obj._bom_explode(cr, uid, bom_point, factor / bom_point.product_qty, [])
++                for r in res[0]:
++                    if r['product_id']== move.product_id.id:
++                        move_lines_obj.write(cr, uid,move.id, {'product_qty' :  r['product_qty']})
++        
++            
++        
++            for m in prod.move_created_ids:
++                move_lines_obj.write(cr, uid,m.id, {'product_qty': wiz_qty.product_qty})
+     
+         return {}
+     
+ change_production_qty()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,8b0e5ff..34520a7
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,45 +1,35 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+         
+         <!--  Change Product Quantity -->
+         
+               <record id="view_change_production_qty_wizard" model="ir.ui.view">
+             <field name="name">Change Product Qty</field>
+             <field name="model">change.production.qty</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                 <form string="Change Product Qty">
+                                   <field name="product_qty"/>
+                                   <newline/>
+                                   <group col="2" colspan="4">
+                               <button icon='gtk-cancel' special="cancel"
+                                       string="Cancel" />
+                               <button name="change_prod_qty" string="Validate"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                 </form>
+             </field>
+         </record>
+         <record id="action_change_production_qty" model="ir.actions.act_window">
+             <field name="name">Change Product Qty</field>
+             <field name="type">ir.actions.act_window</field>
+             <field name="res_model">change.production.qty</field>
+             <field name="view_type">form</field>
+             <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 -
 -       <record model="ir.values" id="values_change_production_qty">
 -            <field name="model_id" ref="mrp.model_mrp_production" />
 -            <field name="object" eval="1" />
 -            <field name="name">Change Product Qty</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_change_production_qty'))"/>
 -            <field name="key">action</field>
 -            <field name="model">mrp.production</field>
++            <field name="target">new</field>            
+         </record>
++       
+       </data>
+ </openerp>    
index 0000000,77c4959..ce703a4
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,130 +1,130 @@@
+ # -*- 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):
+         """ 
+              @summary: 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):
+         """ 
+              @summary: 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
+         for proc in self.browse(cr, uid, ids):
+             wh = self.pool.get('stock.warehouse').browse(cr, uid, proc.warehouse_id.id, context)
+             procure_id = self.pool.get('mrp.procurement').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 = netsvc.LocalService("workflow")
+             wf_service.trg_validate(uid, 'mrp.procurement', procure_id, 'button_confirm', cr)
+         
+         data_obj = self.pool.get('ir.model.data')
+         id2 = data_obj._get_id(cr, uid, 'mrp', 'mrp_procurement_tree_view')
+         id3 = data_obj._get_id(cr, uid, 'mrp', '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):
+         """ 
+              @summary: 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('record_id', False) or False
++        record_id = context and context.get('active_id', False) or False
+         res = super(make_procurement, self).default_get(cr, uid, fields, context=context)
+         if record_id:
+             product_id = self.pool.get('product.product').browse(cr, uid, record_id, context=context).id
+             res['product_id'] = product_id
+         return res
+ make_procurement()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,e2488fe..08c4b2c
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,51 +1,39 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+         
+         <!--  Make Procurement -->
+         
+               <record id="view_make_procurment_wizard" model="ir.ui.view">
+             <field name="name">Requisition Request</field>
+             <field name="model">make.procurement</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                 <form string="Requisition 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/>
+                                   <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>
 -        <record id="action_make_procurement" model="ir.actions.act_window">
 -            <field name="name">Requisition Request</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">make.procurement</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 -        
 -       <record model="ir.values" id="make_procurement_products">
 -            <field name="model_id" ref="product.model_product_product" />
 -            <field name="object" eval="1" />
 -            <field name="name">Requisition Request</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_procurement'))"/>
 -            <field name="key">action</field>
 -            <field name="model">product.product</field>
 -        </record>
++        <act_window name="Requisition Request"                    
++                  res_model="make.procurement"
++                  src_model="product.product"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="act_make_procurement"/>       
+               
+       </data>
+ </openerp>    
index 0000000,0000000..40d9f2e
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,59 @@@
++# -*- 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 fields, osv
++from tools.translate import _
++import netsvc
++
++class mrp_product_produce(osv.osv_memory):
++    _name = "mrp.product.produce"
++    _description = "Product Produce"
++    
++    _columns = {
++        'product_qty': fields.float('Quantity', required=True), 
++        'mode': fields.selection([('consume_produce', 'Consume & Produce'), 
++                                  ('consume', 'Consume Only')], 'Mode', required=True)
++    }
++
++    def _get_product_qty(self, cr, uid, context):
++        prod = self.pool.get('mrp.production').browse(cr, uid, 
++                                context['active_id'], context=context)
++        done = 0.0
++        for move in prod.move_created_ids2:
++                done += move.product_qty
++        return (prod.product_qty - done) or prod.product_qty
++    
++    _defaults = {
++                 'product_qty': _get_product_qty, 
++                 'mode': lambda *x: 'consume_produce'
++                 }
++
++    def do_produce(self, cr, uid, ids, context={}):
++        prod_obj = self.pool.get('mrp.production')
++        move_ids = context['active_ids']
++        for data in self.read(cr, uid, ids):
++            for move_id in move_ids:
++                prod_obj.do_produce(cr, uid, move_id, 
++                                    data['product_qty'], data['mode'], context=context)
++        return {}
++
++mrp_product_produce()
++
index 0000000,0000000..f730c4a
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,41 @@@
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++    <data>
++    
++        
++        <!--  Produce -->
++        
++              <record id="view_mrp_product_produce_wizard" model="ir.ui.view">
++            <field name="name">MRP Product Produce</field>
++            <field name="model">mrp.product.produce</field>
++            <field name="type">form</field>
++            <field name="arch" type="xml">
++                <form string="Produce">
++                      <separator string="Produce" colspan="4"/>
++                                  <field name="mode" colspan="4"/>
++                                  <field name="product_qty" colspan="2"/>
++                      <newline/>
++                      <separator string="" colspan="4" />
++                      <label string="" colspan="2" />
++                      <group col="2" colspan="1">
++                              <button icon='gtk-cancel' special="cancel"
++                                      string="Cancel" />
++                              <button name="do_produce" string="Confirm"
++                                      colspan="1" type="object" icon="gtk-ok" />
++                      </group>
++                </form>
++            </field>
++        </record>
++
++        <record id="act_mrp_product_produce" model="ir.actions.act_window">
++            <field name="name">Produce</field>
++            <field name="type">ir.actions.act_window</field>
++            <field name="res_model">mrp.product.produce</field>
++            <field name="view_type">form</field>
++            <field name="view_mode">form</field>
++            <field name="target">new</field>
++        </record>    
++        
++        
++      </data>
++</openerp>    
index 0000000,86b4b3c..731c3fc
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,73 +1,71 @@@
+ # -*- 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 
 -        """
 -        try:
 -            proc_obj = self.pool.get('mrp.procurement')
 -            for proc in self.browse(cr, uid, ids):
 -                proc_obj._procure_orderpoint_confirm(cr, uid, automatic=proc.automatic, use_new_cursor=cr.dbname, context=context)
 -        finally:
 -            cr.close()
++        """        
++        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:
index 0000000,65acca7..c17beda
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,46 +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>
 -        <record id="action_procurement_compute" model="ir.actions.act_window">
 -            <field name="name">Compute Stock Minimum Rules Only</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">mrp.procurement.orderpoint.compute</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 -        
 -       <record model="ir.values" id="procurement_compute_order_point">
 -            <field name="model_id" ref="mrp.model_mrp_procurement" />
 -            <field name="object" eval="1" />
 -            <field name="name">Compute Stock Minimum Rules Only</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_procurement_compute'))" />
 -            <field name="key">action</field>
 -            <field name="model">mrp.procurement</field>
 -        </record>
++        <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>    
index 0000000,4574a96..b8b465e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,49 +1,37 @@@
+ <?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>
 -        <record id="action_compute_schedulers" model="ir.actions.act_window">
 -            <field name="name">Compute Schedulers</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">mrp.procurement.compute.all</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 -        
 -       <record model="ir.values" id="compute_all_schedulers">
 -            <field name="model_id" ref="mrp.model_mrp_procurement" />
 -            <field name="object" eval="1" />
 -            <field name="name">Compute Schedulers</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_compute_schedulers'))" />
 -            <field name="key">action</field>
 -            <field name="model">mrp.procurement</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"/>            
+         
+         <menuitem id="menu_mrp_scheduler" name="Schedulers" parent="base.menu_mrp_root" sequence="4"/>
+         <menuitem action="action_compute_schedulers" id="mrp_Sched_all" parent="mrp.menu_mrp_scheduler" sequence="90"/>
+               
+       </data>
+ </openerp>    
      'depends': ['base', 'sale', 'account'],
      'update_xml': [
          'security/ir.model.access.csv',
--        'mrp_repair_sequence.xml',
--        'mrp_repair_wizard.xml',
++        'mrp_repair_sequence.xml',        
+         'wizard/mrp_repair_cancel_view.xml',
+         'wizard/mrp_repair_make_invoice_view.xml',
          'mrp_repair_view.xml',
          'mrp_repair_workflow.xml',
-         'mrp_repair_report.xml'
+         'mrp_repair_report.xml',
      ],
      'demo_xml': [],
      'installable': True,
@@@ -95,7 -95,7 +95,7 @@@ class mrp_repair(osv.osv)
              \n* The \'To be Invoiced\' state is used to generate the invoice before or after repairing done. \
              \n* The \'Done\' state is set when repairing is completed.\
              \n* The \'Cancelled\' state is used when user cancel repair order.'),
--        'location_id': fields.many2one('stock.location', 'Current Location', required=True, select=True, readonly=True, states={'draft':[('readonly',False)]}),
++        'location_id': fields.many2one('stock.location', 'Current Location', select=True, readonly=True, states={'draft':[('readonly',False)]}),
          'location_dest_id': fields.many2one('stock.location', 'Delivery Location', readonly=True, states={'draft':[('readonly',False)]}),
          'move_id': fields.many2one('stock.move', 'Move',required=True, domain="[('product_id','=',product_id)]", readonly=True, states={'draft':[('readonly',False)]}),
          'guarantee_limit': fields.date('Guarantee limit', help="The guarantee limit is computed as: last move date + warranty defined on selected product. If the current date is below the guarantee limit, each operation and fee you will add will be set as 'not to invoiced' by default. Note that you can change manually afterwards."),
      def action_invoice_create(self, cr, uid, ids, group=False, context=None):
          res={}
          invoices_group = {}
--        for repair in self.browse(cr, uid, ids, context=context):
++        for repair in self.browse(cr, uid, ids, context=context):            
              res[repair.id]=False
              if repair.state in ('draft','cancel') or repair.invoice_id:
                  continue
              if not (repair.partner_id.id and repair.partner_invoice_id.id):
--                raise osv.except_osv(_('No partner !'),_('You have to select a partner in the repair form !'))
++                raise osv.except_osv(_('No partner !'),_('You have to select a Partner Invoice Address in the repair form !'))
              comment=repair.quotation_notes
              if (repair.invoice_method != 'none'):
                  if group and repair.partner_invoice_id.id in invoices_group:
diff --cc addons/mrp_repair/mrp_repair_wizard.xml
index 42383f5,b0b2c89..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,22 -1,23 +1,0 @@@
--<?xml version="1.0" encoding="utf-8"?>
--<openerp>
--    <data>
-           <wizard 
-                   id="action_cancel_repair" 
-                   model="mrp.repair" 
-                   name="mrp.repair.cancel"
-                   string="Cancel Repair"
-                   menu = "False"
-                   multi = "True"
-                   />
-                <wizard
-                               id="wizard_mrp_repair_make_invoice"
-                               keyword="client_action_multi"
-                               model="mrp.repair"
-                               name="mrp.repair.make_invoice"
-                               multi="True"
-                               string="Make invoices"/>
-                                       
-     </data>
- </openerp>
-               
 -<!--      <wizard -->
 -<!--              id="action_cancel_repair" -->
 -<!--              model="mrp.repair" -->
 -<!--              name="mrp.repair.cancel"-->
 -<!--              string="Cancel Repair"-->
 -<!--              menu = "False"-->
 -<!--              multi = "True"-->
 -<!--              />-->
 -
 -<!--           <wizard-->
 -<!--                          id="wizard_mrp_repair_make_invoice"-->
 -<!--                          keyword="client_action_multi"-->
 -<!--                          model="mrp.repair"-->
 -<!--                          name="mrp.repair.make_invoice"-->
 -<!--                          multi="True"-->
 -<!--                          string="Make invoices"/>-->
 -                                      
 -    </data>
 -</openerp>
 -              
index 0000000,dbc1e0a..1dc4159
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,88 +1,87 @@@
+ # -*- 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
+ from osv import osv,fields
+ from tools.translate import _
+ class repair_cancel(osv.osv_memory):
+     _name = 'mrp.repair.cancel'
+     _description = 'Cancel Repair'
+     def cancel_repair(self, cr, uid, ids, context):
+         """ 
+              @summary: Cancels the repair
+         
+              @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:  
+         
+         """
 -        record_id = context and context.get('record_id', False) or False
 -        if record_id:
 -            repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])
 -            
 -            if repair_obj[0].invoiced or repair_obj[0].invoice_method == 'none':
 -                self.pool.get('mrp.repair').write(cr, uid, record_id, {'state':'cancel'})
 -                mrp_line_obj = self.pool.get('mrp.repair.line')
 -                for line in repair_obj:
 -                    mrp_line_obj.write(cr, uid, [l.id for l in line.operations], {'state': 'cancel'})
 -            else:
 -                raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.'))
++        record_id = context and context.get('active_id', False) or False
++        assert record_id, _('Active ID is not Found')
++        repair_order_obj = self.pool.get('mrp.repair')
++        repair_line_obj = self.pool.get('mrp.repair.line')
++        repair_order = repair_order_obj.browse(cr, uid, record_id)
++        
++        if repair_order.invoiced or repair_order.invoice_method == 'none':
++            repair_order_obj.action_cancel(cr, uid, [record_id], context=context)            
++        else:
++            raise osv.except_osv(_('Warning!'),_('Repair is not cancelled. It is not invoiced.'))
+         
+         return {}
+     
+     def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+         """ 
+              @summary: Changes the view dynamically
+         
+              @param self: The object pointer.
+              @param cr: A database cursor
+              @param uid: ID of the user currently logged in
+              @param context: A standard dictionary 
+              
+              @return: New arch of view.
+         
+         """
 -        record_id = context and context.get('record_id', False) or False
++        record_id = context and context.get('order_id', False) or False        
+         res = super(repair_cancel, self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar,submenu=False)
+         if record_id:
 -            repair_obj = self.pool.get('mrp.repair').browse(cr, uid, [record_id])[0]
 -            if not repair_obj.invoice_id:
++            repair_order = self.pool.get('mrp.repair').browse(cr, uid, record_id)
++            if not repair_order.invoiced:
+                 res['arch'] = """ <form string="Cancel Repair" colspan="4">
+                                 <group col="2" colspan="2">
+                                     <label string="Do you want to continue?" colspan="4"/>
+                                     <separator colspan="4"/>
+                                     <button icon="gtk-cancel" special="cancel" string="No" readonly="0"/>
+                                     <button name="cancel_repair" string="Yes" type="object" icon="gtk-ok"/>
+                                 </group>
+                             </form>                             
+                         """
+         return res
+ repair_cancel()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,6e90093..c4c9394
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,45 +1,37 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+         
+         <!--  Cancel Repair -->
+         
+               <record id="view_cancel_repair" model="ir.ui.view">
+             <field name="name">Cancel Repair</field>
+             <field name="model">mrp.repair.cancel</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
 -                <form string="Requisition Request">
++                <form string="Cancel Repair Order">
+                                   <label string="This operation will cancel the Repair process, but will not cancel it's Invoice. Do you want to continue?" colspan="4"/>
+                                   <newline/>
+                                   <group col="2" colspan="4">
+                               <button icon='gtk-cancel' special="cancel"
+                                       string="No" />
+                               <button name="cancel_repair" string="Yes"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                 </form>
+             </field>
 -        </record>
++        </record>         
+         <record id="action_cancel_repair" model="ir.actions.act_window">
 -            <field name="name">Cancel Repair</field>
++            <field name="name">Cancel Repair Order</field>
+             <field name="type">ir.actions.act_window</field>
+             <field name="res_model">mrp.repair.cancel</field>
+             <field name="view_type">form</field>
+             <field name="view_mode">form</field>
+             <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 - 
 -              <record model="ir.values" id="action_cancel_repair_related">
 -                      <field name="model_id" ref="mrp_repair.model_mrp_repair" />
 -            <field name="object" eval="1" />
 -            <field name="name">Cancel Repair</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_cancel_repair'))" />
 -            <field name="key">action</field>
 -            <field name="model">mrp.repair</field>
 -        </record>
++            <field name="context">{'order_id':active_id}</field>
++        </record> 
++              
+         
+       </data>
+ </openerp>    
index 0000000,6d489e5..f914d19
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,46 +1,35 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+         
+         <!--  Make Invoice -->
+         
+               <record id="view_make_invoice" model="ir.ui.view">
+             <field name="name">Make Invoice</field>
+             <field name="model">mrp.repair.make_invoice</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                 <form string="Create invoices">
+                                   <separator colspan="4" string="Do you really want to create the invoices ?" />  
+                                   <field name="group"/>
+                                   <newline/>  
+                                   <group col="2" colspan="4">
+                               <button icon='gtk-cancel' special="cancel"
+                                       string="Cancel" />
+                               <button name="make_invoices" string="Create Invoice"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                 </form>
+             </field>
+         </record>
 -        <record id="action_make_invoice" model="ir.actions.act_window">
 -            <field name="name">Make Invoice</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">mrp.repair.make_invoice</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'active_ids' : active_ids}</field>
 -        </record>
 - 
 -              <record model="ir.values" id="action_make_invoice_related">
 -            <field name="object" eval="1" />
 -            <field name="name">Make Invoice</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_make_invoice'))" />
 -            <field name="key2">client_action_multi</field>
 -            <field name="key">action</field>
 -            <field name="model">mrp.repair</field>
 -        </record>
++        <act_window name="Make Invoice"                   
++                  res_model="mrp.repair.make_invoice"
++                  src_model="mrp.repair"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="act_mrp_repair_invoice"/>        
+         
+       </data>
+ </openerp>    
index 0000000,e11dd89..5ff3c38
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,66 +1,67 @@@
+ # -*- 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
+ from osv import osv,fields
+ from tools.translate import _
+ class add_product(osv.osv_memory):
+     _name = 'pos.add.product'
+     _description = 'Add Product'
+     _columns = {
+                 'product_id': fields.many2one('product.product', 'Product',required=True),
+                 'quantity': fields.float('Quantity ', required=True),
+     }
+     _defaults = {
+                     'quantity': lambda *a: 1,
+                 }
+     
+     def select_product(self, cr, uid, ids, context):
+         """ 
+              @summary: To get the product and quantity and add in order .            
+              @param self: The object pointer.
+              @param cr: A database cursor
+              @param uid: ID of the user currently logged in
+              @param context: A standard dictionary 
+              @return : Retrun the add product form again for addin more product
+         """        
+         this = self.browse(cr, uid, ids[0], context=context)
 -        record_id = context and context.get('record_id',False)
++        record_id = context and context.get('active_id',False)
++        assert record_id, _('Active ID is not found')
+         if record_id:
+              order_obj = self.pool.get('pos.order')
+              order_obj.add_product(cr, uid, record_id, this.product_id.id,this.quantity,context=context)
+         
+         return {            
+                 'name': _('Add Product'),
+                 'view_type': 'form',
+                 'view_mode': 'form',
+                 'res_model': 'pos.add.product',
+                 'view_id': False,
+                 'target':'new',
+                 'views': False,
+                 'type': 'ir.actions.act_window',
+                 }
+ add_product()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,fe9d7ed..5d38062
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,35 +1,34 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>        
+         <!--  Add  Product -->
+         
+               <record id="view_add_product" model="ir.ui.view">
+             <field name="name">Add  Product</field>
+             <field name="model">pos.add.product</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                 <form string="Add product :">
+                                   <group col="2" colspan="4">
+                                       <field name="product_id"/>
+                                       <field name="quantity"/>
+                               <button icon='gtk-cancel' special="cancel"
+                                       string="Close" />
+                               <button name="select_product" string="Contiue"
+                                       colspan="1" type="object" icon="gtk-ok" />
+                       </group>
+                 </form>
+             </field>
+         </record>
+         <record id="action_add_product" model="ir.actions.act_window">
+             <field name="name">Add  Product</field>
+             <field name="type">ir.actions.act_window</field>
+             <field name="res_model">pos.add.product</field>
+             <field name="view_type">form</field>
+             <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
++            <field name="target">new</field>            
+         </record>
+         
+       </data>
 -</openerp>            
++</openerp>            
@@@ -1,15 -1,13 +1,13 @@@
  <?xml version="1.0" encoding="utf-8"?>
  <openerp>
  <data>
-     <wizard id="action_open_margin" menu="False" model="product.product" name="product.margins" string="Product Margins"/>
- <!--    <menuitem id="menu_product_reporting"-->
- <!--        name="Reporting" parent ="product.menu_main_product"-->
- <!--        groups="product.group_product_manager"/>-->
- <!---->
- <!--    <menuitem icon="STOCK_JUSTIFY_FILL" action="action_open_margin" id="menu_action_product_margin" type="wizard" sequence="5" parent="menu_product_reporting" />-->
+       
 -      <menuitem id="main" name="OSV Memory Wizard Test"/>
++      <menuitem id="base.next_id_64" name="Reporting" parent="base.menu_base_partner" sequence="8"/>
+       <menuitem
+             action="product_margin_action"
+             id="menu_mrp_property_action"
 -            parent="main" />
++            parent="base.next_id_64" />
+             
      <record model="ir.ui.view" id="view_product_margin_graph">
              <field name="name">product.margin.graph</field>
              <field name="model">product.product</field>
index 0000000,4e499eb..e3f03b6
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,98 +1,98 @@@
+ # -*- 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 time
+ from osv import osv
+ from osv import fields
+ import netsvc
+ import time
+ from tools.translate import _
+ class product_margin(osv.osv_memory):
+     '''
+     Product Margin
+     '''
+     _name = 'product.margin'
+     _description = 'Product Margin'
 -    def _action_open_window(self, cr, uid, ids, context):
++    def action_open_window(self, cr, uid, ids, context):
+         """
+             @summary:
+             @param cr: the current row, from the database cursor,
+             @param uid: the current user’s ID for security checks,
+             @param ids: the account  ID or list of IDs if we want more than one
+             @return:
+         """
+         mod_obj = self.pool.get('ir.model.data')
+         result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
+         id = mod_obj.read(cr, uid, result, ['res_id'])
+         cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.graph', 'graph'))
+         view_res3 = cr.fetchone()[0]
+         cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.form.inherit', 'form'))
+         view_res2 = cr.fetchone()[0]
+         cr.execute('select id,name from ir_ui_view where name=%s and type=%s', ('product.margin.tree', 'tree'))
+         view_res = cr.fetchone()[0]
+         #get the current product.margin object to obtain the values from it
+         product_margin_obj = self.browse(cr,uid,ids)[0]
+         return {
+             'name': _('Product Margins'),
+             'context':{'date_from':product_margin_obj.from_date,'date_to':product_margin_obj.to_date,'invoice_state' : product_margin_obj.invoice_state},
+             'view_type': 'form',
+             "view_mode": 'tree,form,graph',
+             'res_model':'product.product',
+             'type': 'ir.actions.act_window',
+             'views': [(view_res,'tree'), (view_res2,'form'), (view_res3,'graph')],
+             'view_id': False,
+             'search_view_id': id['res_id']
+         }
+     def action_cancel(self, cr, uid, ids, context=None):
+         """
+             @summary:
+             @param cr: the current row, from the database cursor,
+             @param uid: the current user’s ID for security checks,
+             @param ids: the account  ID or list of IDs if we want more than one
+             @return:
+         """
+         return {'type':'ir.actions.act_window_close'}
+     _columns = {
+         #TODO : import time required to get currect date
+         'from_date': fields.date('From'),
+         #TODO : import time required to get currect date
+         'to_date': fields.date('To'),
+         'invoice_state':fields.selection([
+            ('paid','Paid'),
+            ('open_paid','Open and Paid'),
+            ('draft_open_paid','Draft, Open and Paid'),
+         ],'Invoice State', select=True, required=True),
+     }
+     _defaults = {
+         'from_date':  lambda *a:time.strftime('%Y-01-01'),
+         'to_date': lambda *a:time.strftime('%Y-01-01'),
+         'invoice_state': lambda *a:"open_paid",
+     }
 -product_margin()
++product_margin()
index 0000000,1d2a474..dae9a8f
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,31 +1,31 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+         <data>
+               <record id="product_margin_form_view" model="ir.ui.view">
+                   <field name="name">product.margin.form</field>
+                   <field name="model">product.margin</field>
+                   <field name="type">form</field>
+                   <field name="arch" type="xml">
+                       <form string="Properties categories">
+                           <separator colspan="4" string="General Information"/>
+                                               <field name="from_date" />
+                                               <field name="to_date" />
+                                               <field name="invoice_state" />
+                                               <group col="4" colspan="2">
+                                                       <button special="cancel" string="Cancel" type="object"/>
 -                                                      <button name="_action_open_window" string="Open Margins" type="object"/>
++                                                      <button name="action_open_window" string="Open Margins" type="object"/>
+                                               </group>
+                       </form>
+                   </field>
+               </record>
+               <record id="product_margin_action" model="ir.actions.act_window">
+                   <field name="name">Product Margine</field>
+                   <field name="type">ir.actions.act_window</field>
+                   <field name="target">new</field>
+                   <field name="res_model">product.margin</field>
+                   <field name="view_type">form</field>
+                   <field name="view_mode">form</field>
+                   <field name="view_id" ref="product_margin_form_view"/>
+               </record>
+         </data>
 -</openerp>
++</openerp>
index 0000000,7dd7fef..0c08a06
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,100 +1,100 @@@
+ # -*- 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 fields, osv
+ from service import web_services
+ import wizard
+ import netsvc
+ import ir
+ import pooler
+ class sale_order_line_make_invoice(osv.osv_memory):
+     _name = "sale.order.line.make.invoice"
+     _description = "Sale OrderLine Make_invoice"
+     _columns = {
+         'grouped': fields.boolean('Group the invoices'),
+     }
+     _default = {
+         'grouped' : lambda *a: False
 -               }
++    }
+     def makeInvoices(self, cr, uid, ids, context):
+         res = False
+         invoices = {}
+     #TODO: merge with sale.py/make_invoice
+         def make_invoice(order, lines):
+             a = order.partner_id.property_account_receivable.id
+             if order.partner_id and order.partner_id.property_payment_term.id:
+                 pay_term = order.partner_id.property_payment_term.id
+             else:
+                 pay_term = False
+             inv = {
+                 'name': order.name,
+                 'origin': order.name,
+                 'type': 'out_invoice',
+                 'reference': "P%dSO%d" % (order.partner_id.id, order.id),
+                 'account_id': a,
+                 'partner_id': order.partner_id.id,
+                 'address_invoice_id': order.partner_invoice_id.id,
+                 'address_contact_id': order.partner_invoice_id.id,
+                 'invoice_line': [(6,0,lines)],
+                 'currency_id' : order.pricelist_id.currency_id.id,
+                 'comment': order.note,
+                 'payment_term': pay_term,
+                 'fiscal_position': order.partner_id.property_account_position.id
+             }
+             inv_id = self.pool.get('account.invoice').create(cr, uid, inv)
+             return inv_id
+         for line in self.pool.get('sale.order.line').browse(cr,uid,context['active_ids']):
+             if (not line.invoiced) and (line.state not in ('draft','cancel')):
+                 if not line.order_id.id in invoices:
+                     invoices[line.order_id.id] = []
+                 line_id = self.pool.get('sale.order.line').invoice_line_create(cr, uid,
+                         [line.id])
+                 for lid in line_id:
+                     invoices[line.order_id.id].append((line, lid))
+                 self.pool.get('sale.order.line').write(cr, uid, [line.id],
+                         {'invoiced': True})
+             flag = True
+             data_sale = self.pool.get('sale.order').browse(cr,uid,line.order_id.id)
+             for line in data_sale.order_line:
+                 if not line.invoiced:
+                     flag = False
+                     break
+             if flag:
+                 wf_service = netsvc.LocalService('workflow')
+                 wf_service.trg_validate(uid, 'sale.order', line.order_id.id, 'all_lines', cr)
+                 self.pool.get('sale.order').write(cr,uid,[line.order_id.id],{'state' : 'progress'})
+         for result in invoices.values():
+             order = result[0][0].order_id
+             il = map(lambda x: x[1], result)
+             res = make_invoice(order, il)
+             cr.execute('INSERT INTO sale_order_invoice_rel \
+                     (order_id,invoice_id) values (%s,%s)', (order.id, res))
+         return {}
+ sale_order_line_make_invoice()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,823b5a0..a9ea13e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,40 +1,28 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+       <record id="view_sale_order_line_make_invoice" model="ir.ui.view">
+             <field name="name">Sale OrderLine Make Invoice</field>
+             <field name="model">sale.order.line.make.invoice</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+              <form string="Create invoices">
+                       <separator colspan="4" string="Do you really want to create the invoices ?" />
+                       <field name="grouped" />
+               <separator string="" colspan="6" />
+                       <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                       <button name="makeInvoices" string="Create Invoices" type="object" icon="gtk-ok"/>
+              </form>
+             </field>
+               </record>
 -              <record id="action_view_sale_order_line_make_invoice" model="ir.actions.act_window">
 -            <field name="name">Make Invoices</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">sale.order.line.make.invoice</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -              <field name="context">{'record_id' : active_id}</field>
 -      </record>
 -
 -        <record model="ir.values" id="sale_make_invoice">
 -            <field name="model_id" ref="sale.model_sale_order_line" />
 -            <field name="object" eval="1" />
 -            <field name="name">Make Invoices</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_sale_order_line_make_invoice'))" />
 -            <field name="key">action</field>
 -            <field name="model">sale.order.line</field>
 -        </record>
++        <act_window name="Make Invoices"                  
++                  res_model="sale.order.line.make.invoice"
++                  src_model="sale.order.line"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_view_sale_order_line_make_invoice"/>             
+     </data>
 -</openerp>
++</openerp>
index 0000000,eb333f4..e0ad560
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,70 +1,59 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+       <record id="view_sale_advance_payment_inv" model="ir.ui.view">
+             <field name="name">Sale Advance Payment Invoive</field>
+             <field name="model">sale.advance.payment.inv</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+              <form string="Advance Payment">
+                           <field name="product_id"/>
+                           <newline />
+                           <field name="qtty"/>
+                           <field name="amount"/>
+                           <newline />
+               <separator string="" colspan="4"/>
+               <label string=""  colspan="2" />
+                       <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                       <button name="createInvoices" string="Create Advance Invoice" type="object" icon="gtk-ok"/>
+              </form>
+             </field>
+               </record>
 -              <record id="action_view_sale_advance_payment_inv" model="ir.actions.act_window">
 -            <field name="name">Advance Invoice</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">sale.advance.payment.inv</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -              <field name="context">{'record_id' : active_id}</field>
 -      </record>
 -       <record model="ir.values" id="sale_advance_payment_inv1">
 -            <field name="model_id" ref="sale.model_sale_order" />
 -            <field name="object" eval="1" />
 -            <field name="name">Advance Invoice</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_sale_advance_payment_inv'))" />
 -            <field name="key">action</field>
 -            <field name="model">sale.order</field>
 -        </record>
++        <act_window name="Advance Invoice"                
++                  res_model="sale.advance.payment.inv"
++                  src_model="sale.order"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_view_sale_advance_payment_inv"/> 
+       <record id="view_sale_open_invoice" model="ir.ui.view">
+             <field name="name">Open Invoice</field>
+             <field name="model">sale.open.invoice</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+              <form string="Invoices">
+               <label string="You invoice has been successfully created!" />
+                <newline />
+               <separator string="" colspan="4"/>
+               <group colspan="4">
+                       <button special="cancel" string="Cancel" icon="gtk-cancel"/>
+                       <button name="open_invoice" string="Open Invoice" type="object" icon="gtk-open"/>
+                       </group>
+              </form>
+             </field>
+               </record>
+               <record id="action_view_sale_open_invoice" model="ir.actions.act_window">
+             <field name="name">Open Invoice</field>
+             <field name="type">ir.actions.act_window</field>
+             <field name="res_model">sale.open.invoice</field>
+             <field name="view_type">form</field>
+             <field name="view_mode">form</field>
+             <field name="target">new</field>
+       </record>
+     </data>
+ </openerp>
@@@ -26,8 -26,8 +26,7 @@@ import produc
  import report
  import wizard
  import report_stock
 -import stock_wizard
  
- import stock_wizard
  
  
  # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
@@@ -41,11 -41,16 +41,16 @@@ Thanks to the double entry management, 
      "init_xml" : [],
      "demo_xml" : ["stock_demo.xml"],
      "update_xml" : [
-         "stock_workflow.xml",
          "stock_data.xml",
++        "wizard/stock_move_view.xml",
+         "wizard/stock_inventory_set_stock_zero_view.xml",
+         "wizard/stock_fill_inventory_view.xml",
+         "wizard/stock_invoice_onshipping_view.xml",
+         "wizard/stock_location_product_view.xml",
+         "wizard/stock_inventory_line_split_view.xml",
+         "stock_workflow.xml",
          "stock_incoterms.xml",
--        "stock_wizard.xml",
-         "stock_wizard_view.xml", 
 -        "stock_wizard_view.xml",
++        "stock_wizard.xml",        
          "stock_view.xml",
          "stock_report.xml",
          "stock_sequence.xml",
                      <field name="product_qty"/>
                      <field name="product_uom"/>
                      <field name="prod_lot_id"/>
--                    <field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>
-                     <button name="%(split_inventory_lots)d" string="Split Inventory Lines" type="action" icon="gtk-justify-fill"/>
 -                  <!--   <button name="%(split_inventory_lots)d"
 -                      string="Split Inventory Lines" type="action"
 -                      icon="gtk-justify-fill" /> -->
++                    <field colspan="4" domain="[('usage','=','internal')]" name="location_id" select="1"/>                  
+                        <button name="%(stock.action_view_stock_inventory_line_split)d"
+                                               string="Split inventory lines"
+                                                       type="action" icon="gtk-justify-fill"/>
                  </form>
              </field>
          </record>
                              <newline/>
                              <field name="move_type"/>
                          </page>
--                    </notebook>
 -                    <button
 -                      name="%(stock.action_stock_invoice_onshipping)d"
 -                      string="Create Invoices" type="action" />
++                    </notebook>                    
                  </form>
              </field>
          </record>
                          <field name="location_dest_id" select="1"/>
                          <field name="name" select="1"/>
                          <field name="address_id" select="1"/>
--                    </group>
 -                    <newline/>
++                    </group>  
++                    <newline/>                   
                      <group expand="1" string="Group By..." colspan="4" col="8">
                          <filter string="Partner" icon="terp-stock" domain="[]" context="{'group_by':'address_id'}"/>
                          <filter string="State" icon="terp-stock" domain="[]" context="{'group_by':'state'}"/>
                              <field name="date_done" select="2"/>
                              <field name="move_type"/>
                          </page>
--                    </notebook>
 -                                      <button
 -                      name="%(stock.action_stock_invoice_onshipping)d"
 -                      string="Create Invoice" type="action" />
++                    </notebook>                                       
                  </form>
              </field>
          </record>
                          <field name="name" select="1"/>
                          <field name="address_id" select="1"/>
                          <field name="origin" select="1"/>
--                    </group>
 -                    <newline/>
++                    </group> 
++                    <newline/>                    
                      <group expand="1" string="Group By..." colspan="4" col="10">
                          <filter string="Partner" icon="terp-stock" domain="[]"  context="{'group_by':'address_id'}"/>
                          <filter string="State" icon="terp-stock" domain="[]" context="{'group_by':'state'}"/>
                          <field name="name" select="1"/>
                          <field name="address_id" select="1"/>
                          <field name="company_id" select="1" widget="selection"/>
--                   </group>
-                     <group expand="context.get('report',False)" string="Group By..." colspan="4" col="8">
 -                   <newline/>
 -                    <group expand="context.get('report',False)" string="Group By..." colspan="4" col="8">
++                   </group>   
++                    <newline/>                 
++                    <group expand="1" string="Group By..." colspan="4" col="8">
                          <filter string="Partner" icon="terp-stock" domain="[]" context="{'group_by':'address_id'}"/>
                          <filter string="State" icon="terp-stock" domain="[]" context="{'group_by':'state'}"/>
                                                <filter string="Date" icon="terp-stock" domain="[]"  context="{'group_by':'date'}"/>
                          <field name="name" select="1"/>
                          <field name="address_id" select="1"/>
                          <field name="company_id" select="1" widget="selection" groups="base.group_multi_company" />
--                    </group>
 -                    <newline/>
++                    </group>  
++                    <newline/>                   
                      <group expand="1" string="Group By..." colspan="4" col="8">
                          <filter string="Partner" icon="terp-stock" domain="[]" context="{'group_by':'address_id'}"/>
                          <filter string="Date" icon="terp-stock" domain="[]"  context="{'group_by':'date'}"/>
                          <field name="name" select="1"/>
                          <field name="origin" select="1"/>
                          <field name="company_id" select="1" widget="selection"/>
--                    </group>
 -                    <newline/>
++                    </group>  
++                    <newline/>                   
                      <group expand="1" string="Group By..." colspan="4" col="8">
                          <filter string="Partner" icon="terp-stock" domain="[]" context="{'group_by':'address_id'}"/>
                          <filter string="Date" icon="terp-stock" domain="[]"  context="{'group_by':'date'}"/>
                          <field name="location_id" select="1"/>
                          <field name="location_dest_id" select="1"/>
                          <field name="product_id" select="1"/>
--                    </group>
 -                    <newline/>
++                    </group> 
++                    <newline/>                    
                      <group expand="1" string="Group By..." colspan="4" col="8">
                          <filter string="Product" icon="terp-stock" domain="[]"  context="{'group_by':'product_id'}"/>
                          <filter string="Date" icon="terp-stock" domain="[]" context="{'group_by':'date'}"/>
                                <filter icon="terp-stock" string="Back Orders" domain="[('backorder_id','!=',False)]" help="Back Orders"/>
                                <filter icon="terp-stock" string="Planned Today" domain="[('date_planned::date','=',time.strftime('%%Y-%%m-%%d'))]" help="Orders planned for today"/>
                                <separator orientation="vertical"/>
-                         <field name="origin" string="Purchase Order" select="1"/>
+                         <field name="origin" string="Latest Requisition" select="1"/>
                                <field name="partner_id" string="Supplier" select="1"/>
                            <field name="product_id"/>
--                    </group>
-                     <group expand="context.get('report',False)" string="Group By..." colspan="4" col="8">
 -                    <newline/>
 -                    <group expand="context.get('report',False)" string="Group By..." colspan="4" col="8">
++                    </group>   
++                    <newline/>                 
++                    <group expand="1" string="Group By..." colspan="4" col="8">
                                                <filter string="Product" icon="terp-stock" domain="[]" context="{'group_by':'product_id'}"/>
                                                <filter string="State" icon="terp-stock" domain="[]" context="{'group_by':'state'}"/>
                                                <filter string="Date" icon="terp-stock" domain="[]" context="{'group_by':'date'}"/>
              <field name="key2">tree_but_open</field>
              <field name="model">stock.location</field>
              <field name="name">Open Products</field>
--            <field eval="'ir.actions.wizard,%d'%ref('location_product')" name="value"/>
++            <field eval="'ir.actions.act_window,%d'%action_view_stock_location_product" name="value"/>
              <field eval="True" name="object"/>
          </record> Â 
  
diff --cc addons/stock/stock_wizard.py
index 548375d,548375d..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,206 -1,206 +1,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 fields, osv
--from tools.translate import _
--
--class stock_move_track(osv.osv_memory):
--    _name = "stock.move.track"
--    _description = "Track moves"
--    
--    _columns = {
--        'tracking_prefix': fields.char('Tracking prefix', size=64), 
--        'quantity': fields.float("Quantity per lot")
--              }
--
--    _defaults = {
--        'quantity': lambda *x: 1
--                 }
--    
--    def track_lines(self, cr, uid, ids, context={}):
--        datas = self.read(cr, uid, ids)[0]
--        move_obj = self.pool.get('stock.move')
--        move_obj._track_lines(cr, uid, context['active_id'], datas, context=context)
--        return {}
--
--stock_move_track()
--
--class stock_move_consume(osv.osv_memory):
--    _name = "stock.move.consume"
--    _description = "Consume Products"
--    
--    _columns = {
--        'product_id': fields.many2one('product.product', 'Product', required=True, select=True), 
--        'product_qty': fields.float('Quantity', required=True), 
--        'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), 
--        'location_id': fields.many2one('stock.location', 'Location', required=True)
--              }
--
--    def _get_product_id(self, cr, uid, context):
--        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
--        return move.product_id.id
--    
--    def _get_product_qty(self, cr, uid, context):
--        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
--        return move.product_qty
--    
--    def _get_product_uom(self, cr, uid, context):
--        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
--        return move.product_uom.id
--    
--    def _get_location_id(self, cr, uid, context):
--        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
--        return move.location_id.id
--    
--    _defaults = {
--                 'product_id': _get_product_id, 
--                 'product_qty': _get_product_qty, 
--                 'product_uom': _get_product_uom, 
--                 'location_id': _get_location_id
--                 }
--
--    def do_move_consume(self, cr, uid, ids, context={}):
--        move_obj = self.pool.get('stock.move')
--        move_ids = context['active_ids']
--        for data in self.read(cr, uid, ids):            
--            move_obj.consume_moves(cr, uid, move_ids, 
--                             data['product_qty'], data['location_id'], 
--                             context=context)
--        return {}
--
--stock_move_consume()
--
--
--class stock_move_scrap(osv.osv_memory):
--    _name = "stock.move.scrap"
--    _description = "Scrap Products"
--    _inherit = "stock.move.consume"
--    
--    _defaults = {
--                 'location_id': lambda *x: False
--    }
--
--    def move_scrap(self, cr, uid, ids, context={}):
--        move_obj = self.pool.get('stock.move')        
--        move_ids = context['active_ids']
--        for data in self.read(cr, uid, ids):
--            move_obj.scrap_moves(cr, uid, move_ids, 
--                             data['product_qty'], data['location_id'], 
--                             context=context)
--        return {}
--
--stock_move_scrap()
--
--
--class split_in_production_lot(osv.osv_memory):
--    _name = "stock.move.split"
--    _description = "Split in Production lots"
--    
--    _columns = {
--        'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
--        'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number')
--     }
--    
--    def _get_product_id(self, cr, uid, context):
--        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
--        return move.product_id.id
--    
--    _defaults = {
--                 'product_id': _get_product_id, 
--                 }
--
--    def split_lot(self, cr, uid, ids, context=None):
--        self.split(cr, uid, ids, context.get('active_ids'), context=context)
--        return {}
--
--    def split(self, cr, uid, ids, move_ids, context=None):
--        prodlot_obj = self.pool.get('stock.production.lot')
--        ir_sequence_obj = self.pool.get('ir.sequence')
--        move_obj = self.pool.get('stock.move')
--        new_move = []        
--        for data in self.browse(cr, uid, ids):
--            for move in move_obj.browse(cr, uid, move_ids):
--                move_qty = move.product_qty
--                quantity_rest = move.product_qty
--                uos_qty_rest = move.product_uos_qty
--                new_move = []                            
--                for line in data.line_ids:
--                    quantity = line.quantity
--                    
--
--                    if quantity <= 0 or move_qty == 0:
--                        continue
--                    quantity_rest -= quantity
--                    uos_qty = quantity / move_qty * move.product_uos_qty
--                    uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
--                    if quantity_rest <= 0:
--                        quantity_rest = quantity
--                        break
--                    default_val = {
--                        'product_qty': quantity, 
--                        'product_uos_qty': uos_qty, 
--                        'state': move.state
--                    }
--                    current_move = move_obj.copy(cr, uid, move.id, default_val)
--                    new_move.append(current_move)
--                    prodlot_id = False
--                    if line.use_exist and line.name:
--                        prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)])
--                        if prodlot_id:
--                            prodlot_id = prodlot_id[0]                    
--                    if not prodlot_id:
--                        sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
--                        prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name}, 
--                                                 {'product_id': move.product_id.id})                    
--                    move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id})
--                    prodlot = prodlot_obj.browse(cr, uid, prodlot_id) 
--                    ref = '%d' % (current_move)
--                    if prodlot.ref:
--                        ref = '%s, %s' % (prodlot.ref, ref) 
--                    prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
--                    
--                    update_val = {}
--                    if quantity_rest > 0:                        
--                        update_val['product_qty'] = quantity_rest
--                        update_val['product_uos_qty'] = uos_qty_rest                          
--                        move_obj.write(cr, uid, [move.id], update_val)
--
--                    
--        return new_move
--split_in_production_lot()
--
--class stock_move_split_lines(osv.osv_memory):
--    _name = "stock.move.split.lines"
--    _description = "Split lines"
--    
--    _columns = {
--        'name': fields.char('Tracking serial', size=64), 
--        'quantity': fields.integer('Quantity'), 
--        'use_exist' : fields.boolean('Use Exist'),
--        'lot_id': fields.many2one('stock.move.split', 'Lot'),
--        'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
--    }
--    _defaults = {
--        'quantity': lambda *x: 1,
--        'action' : lambda *x: 'split', 
--    }
--
--stock_move_split_lines()
diff --cc addons/stock/stock_wizard_view.xml
index 55fc8a6,55fc8a6..0000000
deleted file mode 100644,100644
+++ /dev/null
@@@ -1,141 -1,141 +1,0 @@@
--<?xml version="1.0" encoding="utf-8"?>
--<openerp>
--    <data>
--    
--          <record id="view_stock_move_track_wizard" model="ir.ui.view">
--                  <field name="name">Tracking a move</field>
--                  <field name="model">stock.move.track</field>
--                  <field name="type">form</field>
--                  <field name="arch" type="xml">
--                      <form string="Tracking a move">
--                              <field name="tracking_prefix" colspan="4"/>
--                              <field name="quantity" colspan="4"/>
--                              <newline/>
--                              <separator string="" colspan="4" />
--                              <button icon='gtk-cancel' special="cancel"
--                                      string="Cancel" />
--                              <button name="track_lines" string="Ok"
--                                      type="object" icon="gtk-ok" />
--                      </form>
--                  </field>
--              </record>
--      
--              <record id="track_line_old" model="ir.actions.act_window">
--                  <field name="name">Tracking a move</field>
--                  <field name="type">ir.actions.act_window</field>
--                  <field name="res_model">stock.move.track</field>
--                  <field name="view_type">form</field>
--                  <field name="view_mode">form</field>
--                  <field name="target">new</field>
--              </record>
--              
--        
--        <!--  Consume, scrap move -->
--        
--              <record id="view_stock_move_consume_wizard" model="ir.ui.view">
--            <field name="name">Consume Move</field>
--            <field name="model">stock.move.consume</field>
--            <field name="type">form</field>
--            <field name="arch" type="xml">
--                <form string="Consume Move">
--                      <separator string="Consume Products" colspan="4"/>
--                                  <field name="product_id" colspan="4" readonly="1"/>
--                                  <field name="location_id" colspan="4"/>
--                                  <field name="product_qty" colspan="2"/>
--                                  <field name="product_uom" nolabel="1" readonly="1"/>
--                      <newline/>
--                      <separator string="" colspan="4" />
--                      <label string="" colspan="2" />
--                      <group col="2" colspan="1">
--                              <button icon='gtk-cancel' special="cancel"
--                                      string="Cancel" />
--                              <button name="do_move_consume" string="Ok"
--                                      colspan="1" type="object" icon="gtk-ok" />
--                      </group>
--                </form>
--            </field>
--        </record>
--
--        <record id="move_consume" model="ir.actions.act_window">
--            <field name="name">Consume Move</field>
--            <field name="type">ir.actions.act_window</field>
--            <field name="res_model">stock.move.consume</field>
--            <field name="view_type">form</field>
--            <field name="view_mode">form</field>
--            <field name="target">new</field>
--        </record>
--        
--       <record id="view_stock_move_scrap_wizard" model="ir.ui.view">
--            <field name="name">Scrap Move</field>
--            <field name="model">stock.move.scrap</field>
--            <field name="type">form</field>
--            <field name="arch" type="xml">
--                <form string="Scrap Move">
--                      <separator string="Scrap Products" colspan="4"/>
--                                  <field name="product_id" colspan="4" readonly="1"/>
--                                  <field name="location_id" colspan="4" string="Dest. Location" domain="[('usage','&lt;&gt;','view')]"/>
--                                  <field name="product_qty" colspan="2"/>
--                                  <field name="product_uom" nolabel="1" readonly="1"/>
--                      <newline/>
--                      <separator string="" colspan="4" />
--                      <label string="" colspan="2" />
--                      <group col="2" colspan="1">
--                              <button icon='gtk-cancel' special="cancel"
--                                      string="Cancel" />
--                              <button name="move_scrap" string="Ok"
--                                      colspan="1" type="object" icon="gtk-ok" />
--                      </group>
--                </form>
--            </field>
--        </record>
--
--        <record id="move_scrap" model="ir.actions.act_window">
--            <field name="name">Scrap Move</field>
--            <field name="type">ir.actions.act_window</field>
--            <field name="res_model">stock.move.scrap</field>
--            <field name="view_type">form</field>
--            <field name="view_mode">form</field>
--            <field name="target">new</field>
--        </record>
--        
--        <record id="view_split_in_lots" model="ir.ui.view">
--                  <field name="name">Split in lots</field>
--                  <field name="model">stock.move.split</field>
--                  <field name="type">form</field>
--                  <field name="arch" type="xml">
--                      <form string="Split in lots">
--                              <field name="product_id" colspan="4" readonly="1"/>
--                              <newline/>
--                              <field name="line_ids" colspan="4" nolabel="1">
--                                      <tree string="Lots Number" editable="top">
--                                              <field name="name" string="Lots"/>
--                                              <field name="quantity" />
--                                <field name="use_exist" />
--                                      </tree>
--                                      <form string="Lots Number">
--                                              <field name="name" string="Lots"/>
--                                              <field name="quantity" />
--                                <field name="use_exist" />
--                                      </form>
--                              </field>
--                              <separator string="" colspan="4" />
--                              <label string="" colspan="2" />
--                              <button icon='gtk-cancel' special="cancel"
--                                      string="Cancel" />
--                              <button name="split_lot" string="Ok"
--                                      type="object" icon="gtk-ok" />
--                      </form>
--                  </field>
--              </record>
--      
--              <record id="track_line" model="ir.actions.act_window">
--                  <field name="name">Split in lots</field>
--                  <field name="type">ir.actions.act_window</field>
--                  <field name="res_model">stock.move.split</field>
--                  <field name="view_type">form</field>
--                  <field name="view_mode">form</field>
--                  <field name="target">new</field>
--              </record>          
--
--      </data>
--</openerp>    
@@@ -20,6 -20,6 +20,7 @@@
  ##############################################################################
  
  import stock_traceability
++import stock_move   
  import wizard_partial_picking
  import wizard_partial_move
  import wizard_picking_make
index 0000000,246aff9..1874e66
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,90 +1,90 @@@
+ # -*- 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 fields, osv
+ from service import web_services
+ from tools.misc import UpdateableStr, UpdateableDict
+ from tools.translate import _
+ import netsvc
+ import pooler
+ import time
+ import wizard
+ class stock_fill_inventory(osv.osv_memory):
+     _name = "stock.fill.inventory"
+     _description = "Fill Inventory"
+     _columns = {
+             'location_id': fields.many2one('stock.location', 'Location', required=True),
+             'recursive': fields.boolean("Include all childs for the location"),
+             }
+     def fill_inventory(self, cr, uid, ids, context):
+         inventory_line_obj = self.pool.get('stock.inventory.line')
+         location_obj = self.pool.get('stock.location')
+         for fill_inventory in self.browse(cr, uid, ids):
+             res = {}
+             res_location = {}
+             if fill_inventory.recursive :
+                 location_ids = location_obj.search(cr, uid, [('location_id',
+                                  'child_of', fill_inventory.location_id.id)])
+                 for location in location_ids :
+                     res = location_obj._product_get(cr, uid, location)
+                     res_location[location] = res
+             else:
+                 context.update({'compute_child': False})
+                 res = location_obj._product_get(cr, uid,
+                             fill_inventory.location_id.id, context=context)
+                 res_location[fill_inventory.location_id.id] = res
+                 product_ids = []
+                 for location in res_location.keys():
+                     res = res_location[location]
+                     for product_id in res.keys():
+                         prod = self.pool.get('product.product').browse(cr, uid, [product_id])[0]
+                         uom = prod.uom_id.id
+                         context.update({'uom': uom})
+                         amount = self.pool.get('stock.location')._product_get(cr, uid,
+                                  location, [product_id], context=context)[product_id]
+                         if(amount):
+                             line_ids=inventory_line_obj.search(cr, uid,
+                                 [('inventory_id', '=', context['active_ids']),
+                                  ('location_id', '=', location),
+                                  ('product_id', '=', product_id),
+                                  ('product_uom', '=', uom),
+                                 ('product_qty', '=', amount)])
+                             if not len(line_ids):
+                                 inventory_line = {'inventory_id': context['active_ids'][0],
+                                                 'location_id': location,
+                                                 'product_id': product_id,
+                                                 'product_uom': uom,
+                                                 'product_qty': amount}
+                                 inventory_line_obj.create(cr, uid, inventory_line)
+                             product_ids.append(product_id)
+                 if(len(product_ids) == 0):
+                     raise osv.except_osv(_('Message !'), _('No product in this location.'))
 -                return {}
++        return {}
+ stock_fill_inventory()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,5ac6732..ef95a3b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,43 +1,31 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+               <record id="view_stock_fill_inventory" model="ir.ui.view">
+             <field name="name">Fill Inventory</field>
+             <field name="model">stock.fill.inventory</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+               <form string="Fill Inventory">
+                       <separator string="Fill Inventory for specific location" colspan="4" />
+                       <field name="location_id"/>
+                       <newline/>
+                       <field name="recursive"/>
+                               <newline/>
+                       <separator string="" colspan="4" />
 -                                      <button special="cancel" string="Cancel" />
 -                  <button name="fill_inventory" string="Fill Inventory" type="object"/>
++                                      <button special="cancel" string="Cancel" icon='gtk-cancel'/>
++                  <button name="fill_inventory" string="Fill Inventory" type="object" icon="gtk-ok"/>
+              </form>
+             </field>
+               </record>
 -              <record id="action_view_stock_fill_inventory" model="ir.actions.act_window">
 -            <field name="name">Fill Inventory</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">stock.fill.inventory</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -            <field name="context">{'record_id' : active_id}</field>
 -        </record>
 -
 -        <record model="ir.values" id="wiki_stock_fill_inventory">
 -            <field name="model_id" ref="stock.model_stock_inventory" />
 -            <field name="object" eval="1" />
 -            <field name="name">Fill Inventory</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_fill_inventory'))" />
 -            <field name="key">action</field>
 -            <field name="model">stock.inventory</field>
 -        </record>
++         <act_window name="Fill Inventory"                
++                  res_model="stock.fill.inventory"
++                  src_model="stock.inventory"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_view_stock_fill_inventory"/>     
+     </data>
 -</openerp>
++</openerp>
index 0000000,cfb1d4a..3d14d8b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,72 +1,72 @@@
+ # -*- 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 fields, osv
+ from service import web_services
+ from tools.misc import UpdateableStr, UpdateableDict
+ from tools.translate import _
+ import netsvc
+ import pooler
+ import time
+ import wizard
+ class inventory_merge_stock_zero(osv.osv_memory):
+     _name = "stock.inventory.merge.stock.zero"
+     _description = "Set Stock to 0"
+     _columns = {
+             'location_id': fields.many2one('stock.location', 'Location', required=True), 
+             }
+     
+     def do_merge(self, cr, uid, ids, context):
+         invent_obj = pooler.get_pool(cr.dbname).get('stock.inventory')
+         invent_line_obj = pooler.get_pool(cr.dbname).get('stock.inventory.line')
+         prod_obj =  pooler.get_pool(cr.dbname).get('product.product')
+     
+         if len(context['active_ids']) <> 1:
+             raise wizard.except_wizard(_('Warning'), 
+                                        _('Please select one and only one inventory !'))
+         for id in ids:
+             datas = self.read(cr, uid, id)
+             loc = str(datas['location_id'])
+         
+             cr.execute('select distinct location_id,product_id \
+                         from stock_inventory_line \
 -                        where inventory_id=%s', (context['active_ids'][0],))
++                        where inventory_id=%s', (context['active_id'],))
+             inv = cr.fetchall()
+             cr.execute('select distinct product_id from stock_move where \
+                         location_dest_id=%s or location_id=%s', (loc, loc,))
+             stock = cr.fetchall()
+             for s in stock:
+                 if (loc, s[0]) not in inv:
+                     p = prod_obj.browse(cr, uid, s[0])
+                     invent_line_obj.create(cr, uid, {
 -                        'inventory_id': context['active_ids'][0], 
++                        'inventory_id': context['active_id'], 
+                         'location_id': loc, 
+                         'product_id': s[0], 
+                         'product_uom': p.uom_id.id, 
+                         'product_qty': 0.0, 
+                         })
+         return {}
+ inventory_merge_stock_zero()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,2948b30..a645691
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,43 +1,31 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+       <record id="view_inventory_merge_stock_zero" model="ir.ui.view">
+             <field name="name">Set Stock to Zero</field>
+             <field name="model">stock.inventory.merge.stock.zero</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+               <form string="Set Stock to Zero">
+                       <separator string="Set Stocks to Zero" colspan="4" />
+                       <field name="location_id"/>
+                               <newline/>
+                               <label colspan="4" string="Do you want to set stocks to zero ?"/>
+                       <separator string="" colspan="4" />
 -                                      <button special="cancel" string="Cancel" />
 -                  <button name="do_merge" string="Set Stock to Zero" type="object"/>
++                                      <button special="cancel" icon='gtk-cancel' string="Cancel" />
++                  <button name="do_merge" string="Set Stock to Zero" type="object" icon="gtk-ok"/>
+              </form>
+             </field>
+               </record>
 -              <record id="action_view_inventory_merge_stock_zero" model="ir.actions.act_window">
 -            <field name="name">Set Stock to Zero</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">stock.inventory.merge.stock.zero</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -              <field name="context">{'record_id' : active_id}</field>
 -      </record>
 -
 -               <record model="ir.values" id="wiki_merge_stock_zero">
 -            <field name="model_id" ref="stock.model_stock_inventory" />
 -            <field name="object" eval="1" />
 -            <field name="name">Set Stock to Zero</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_inventory_merge_stock_zero'))" />
 -            <field name="key">action</field>
 -            <field name="model">stock.inventory</field>
 -        </record>
++        <act_window name="Set Stock to Zero"              
++                  res_model="stock.inventory.merge.stock.zero"
++                  src_model="stock.inventory"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_view_inventory_merge_stock_zero"/>                       
+         
+     </data>
 -</openerp>
++</openerp>
index 0000000,c4bec60..6268901
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,45 +1,33 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+       <record id="view_stock_invoice_onshipping" model="ir.ui.view">
+             <field name="name">Stock Invoice Onshipping</field>
+             <field name="model">stock.invoice.onshipping</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+               <form string="Create invoices">
+                                       <separator colspan="4" string="Create invoices" />
+                               <field name="journal_id"/>
+                               <newline/>
+                                       <field name="group"/>
+                                       <newline/>
+                                       <field name="type"/>
+                                       <newline/>
+                                       <field name="invoice_date" />
+                                   <separator string="" colspan="4" />
 -                                      <button special="cancel" string="Cancel" />
 -                              <button name="create_invoice" string="Create Invoices" type="object"/>
++                                      <button special="cancel" string="Cancel" icon='gtk-cancel'/>
++                              <button name="create_invoice" string="Create Invoices" type="object" icon="gtk-ok"/>
+              </form>
+             </field>
+               </record>
 -              <record id="action_stock_invoice_onshipping" model="ir.actions.act_window">
 -            <field name="name">Create Invoice</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">stock.invoice.onshipping</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -              <field name="context">{'record_id' : active_id}</field>
 -      </record>
 -
 -       <record model="ir.values" id="stock_stock_invoice_onshipping">
 -            <field name="model_id" ref="stock.model_stock_picking" />
 -            <field name="object" eval="1" />
 -            <field name="name">Create Invoice</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_stock_invoice_onshipping'))" />
 -            <field name="key">action</field>
 -            <field name="model">stock.picking</field>
 -        </record>
++        <act_window name="Create Invoice"                 
++                  res_model="stock.invoice.onshipping"
++                  src_model="stock.picking"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_stock_invoice_onshipping"/>              
+     </data>
 -</openerp>
++</openerp>
index 0000000,44f6cb4..0c30749
mode 000000,100755..100755
--- /dev/null
@@@ -1,0 -1,59 +1,59 @@@
+ # -*- 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 fields, osv
+ from service import web_services
+ from tools.misc import UpdateableStr, UpdateableDict
+ from tools.translate import _
+ import netsvc
+ import pooler
+ import time
+ import wizard
+ class stock_location_product(osv.osv_memory):
+     _name = "stock.location.product"
+     _description = "Products by Location"
+     _columns = {
+                 'from_date': fields.datetime('From'), 
+                 'to_date': fields.datetime('To'), 
+                 }
+     def action_open_window(self, cr, uid, ids, context):
+         mod_obj = self.pool.get('ir.model.data')
+         for location_obj in self.read(cr, uid, ids, ['from_date', 'to_date']):
+             result = mod_obj._get_id(cr, uid, 'product', 'product_search_form_view')
+             id = mod_obj.read(cr, uid, result, ['res_id'])
+             return {
+                     'name': 'product', 
+                     'view_type': 'form', 
+                     'view_mode': 'tree,form', 
+                     'res_model': 'product.product', 
+                     'type': 'ir.actions.act_window', 
 -                    'context': {'location': context['active_ids'][0], 
++                    'context': {'location': context['active_id'], 
+                            'from_date': location_obj['from_date'], 
+                            'to_date': location_obj['to_date']}, 
+                     'domain': [('type', '<>', 'service')], 
+                     'search_view_id': id['res_id']
+                     }
+ stock_location_product()
+ # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index 0000000,5d54ee8..518bc6e
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,45 +1,34 @@@
+ <?xml version="1.0" encoding="utf-8"?>
+ <openerp>
+     <data>
+       <record id="view_stock_location_product" model="ir.ui.view">
+             <field name="name">Products by Location</field>
+             <field name="model">stock.location.product</field>
+             <field name="type">form</field>
+             <field name="arch" type="xml">
+                <form string="View Stock of Products">
+                               <separator string="Stock Location Analysis" colspan="4"/>
+                                       <field name="from_date" colspan="4"/>
+                                       <newline/>
+                                       <field name="to_date" colspan="4"/>
+                                       <newline/>
+                                       <label string=""/>
+                                       <label string="(Keep empty to open the current situation. Adjust HH:MM:SS to 00:00:00 to filter all resources of the day for the 'From' date and 23:59:59 for the 'To' date)" align="0.0" colspan="3"/>
+                               <separator string="" colspan="4" />
+                               <label string=""/>
+                                       <button special="cancel" string="Cancel" icon="gtk-cancel" />
+                       <button name="action_open_window" string="Open Product" type="object" icon="gtk-ok"/>
+                       </form>
+             </field>
+               </record>
 -              <record id="action_view_stock_location_product" model="ir.actions.act_window">
 -            <field name="name">Products by Location</field>
 -            <field name="type">ir.actions.act_window</field>
 -            <field name="res_model">stock.location.product</field>
 -            <field name="view_type">form</field>
 -            <field name="view_mode">form</field>
 -            <field name="target">new</field>
 -              <field name="context">{'record_id' : active_id}</field>
 -      </record>
 -       <record model="ir.values" id="stock_location_product">
 -            <field name="model_id" ref="stock.model_stock_location" />
 -            <field name="object" eval="1" />
 -            <field name="name">Products by Location</field>
 -            <field name="key2">client_action_multi</field>
 -            <field name="value" eval="'ir.actions.act_window,' + str(ref('action_view_stock_location_product'))" />
 -            <field name="key">action</field>
 -            <field name="model">stock.location</field>
 -        </record>
++        <act_window name="Products by Location"                   
++                  res_model="stock.location.product"
++                  src_model="stock.location"
++                  view_mode="form"
++                  target="new"        
++            key2="client_action_multi"    
++                  id="action_view_stock_location_product"/>                   
+     </data>
 -</openerp>
++</openerp>
index 0000000,0000000..548375d
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,206 @@@
++# -*- 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 fields, osv
++from tools.translate import _
++
++class stock_move_track(osv.osv_memory):
++    _name = "stock.move.track"
++    _description = "Track moves"
++    
++    _columns = {
++        'tracking_prefix': fields.char('Tracking prefix', size=64), 
++        'quantity': fields.float("Quantity per lot")
++              }
++
++    _defaults = {
++        'quantity': lambda *x: 1
++                 }
++    
++    def track_lines(self, cr, uid, ids, context={}):
++        datas = self.read(cr, uid, ids)[0]
++        move_obj = self.pool.get('stock.move')
++        move_obj._track_lines(cr, uid, context['active_id'], datas, context=context)
++        return {}
++
++stock_move_track()
++
++class stock_move_consume(osv.osv_memory):
++    _name = "stock.move.consume"
++    _description = "Consume Products"
++    
++    _columns = {
++        'product_id': fields.many2one('product.product', 'Product', required=True, select=True), 
++        'product_qty': fields.float('Quantity', required=True), 
++        'product_uom': fields.many2one('product.uom', 'Product UOM', required=True), 
++        'location_id': fields.many2one('stock.location', 'Location', required=True)
++              }
++
++    def _get_product_id(self, cr, uid, context):
++        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
++        return move.product_id.id
++    
++    def _get_product_qty(self, cr, uid, context):
++        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
++        return move.product_qty
++    
++    def _get_product_uom(self, cr, uid, context):
++        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
++        return move.product_uom.id
++    
++    def _get_location_id(self, cr, uid, context):
++        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
++        return move.location_id.id
++    
++    _defaults = {
++                 'product_id': _get_product_id, 
++                 'product_qty': _get_product_qty, 
++                 'product_uom': _get_product_uom, 
++                 'location_id': _get_location_id
++                 }
++
++    def do_move_consume(self, cr, uid, ids, context={}):
++        move_obj = self.pool.get('stock.move')
++        move_ids = context['active_ids']
++        for data in self.read(cr, uid, ids):            
++            move_obj.consume_moves(cr, uid, move_ids, 
++                             data['product_qty'], data['location_id'], 
++                             context=context)
++        return {}
++
++stock_move_consume()
++
++
++class stock_move_scrap(osv.osv_memory):
++    _name = "stock.move.scrap"
++    _description = "Scrap Products"
++    _inherit = "stock.move.consume"
++    
++    _defaults = {
++                 'location_id': lambda *x: False
++    }
++
++    def move_scrap(self, cr, uid, ids, context={}):
++        move_obj = self.pool.get('stock.move')        
++        move_ids = context['active_ids']
++        for data in self.read(cr, uid, ids):
++            move_obj.scrap_moves(cr, uid, move_ids, 
++                             data['product_qty'], data['location_id'], 
++                             context=context)
++        return {}
++
++stock_move_scrap()
++
++
++class split_in_production_lot(osv.osv_memory):
++    _name = "stock.move.split"
++    _description = "Split in Production lots"
++    
++    _columns = {
++        'product_id': fields.many2one('product.product', 'Product', required=True, select=True),
++        'line_ids': fields.one2many('stock.move.split.lines', 'lot_id', 'Lots Number')
++     }
++    
++    def _get_product_id(self, cr, uid, context):
++        move = self.pool.get('stock.move').browse(cr, uid, context['active_id'], context=context)
++        return move.product_id.id
++    
++    _defaults = {
++                 'product_id': _get_product_id, 
++                 }
++
++    def split_lot(self, cr, uid, ids, context=None):
++        self.split(cr, uid, ids, context.get('active_ids'), context=context)
++        return {}
++
++    def split(self, cr, uid, ids, move_ids, context=None):
++        prodlot_obj = self.pool.get('stock.production.lot')
++        ir_sequence_obj = self.pool.get('ir.sequence')
++        move_obj = self.pool.get('stock.move')
++        new_move = []        
++        for data in self.browse(cr, uid, ids):
++            for move in move_obj.browse(cr, uid, move_ids):
++                move_qty = move.product_qty
++                quantity_rest = move.product_qty
++                uos_qty_rest = move.product_uos_qty
++                new_move = []                            
++                for line in data.line_ids:
++                    quantity = line.quantity
++                    
++
++                    if quantity <= 0 or move_qty == 0:
++                        continue
++                    quantity_rest -= quantity
++                    uos_qty = quantity / move_qty * move.product_uos_qty
++                    uos_qty_rest = quantity_rest / move_qty * move.product_uos_qty
++                    if quantity_rest <= 0:
++                        quantity_rest = quantity
++                        break
++                    default_val = {
++                        'product_qty': quantity, 
++                        'product_uos_qty': uos_qty, 
++                        'state': move.state
++                    }
++                    current_move = move_obj.copy(cr, uid, move.id, default_val)
++                    new_move.append(current_move)
++                    prodlot_id = False
++                    if line.use_exist and line.name:
++                        prodlot_id = prodlot_obj.search(cr, uid, [('prefix','=',line.name),('product_id','=',data.product_id.id)])
++                        if prodlot_id:
++                            prodlot_id = prodlot_id[0]                    
++                    if not prodlot_id:
++                        sequence = ir_sequence_obj.get(cr, uid, 'stock.lot.serial')
++                        prodlot_id = prodlot_obj.create(cr, uid, {'name': sequence, 'prefix' : line.name}, 
++                                                 {'product_id': move.product_id.id})                    
++                    move_obj.write(cr, uid, [current_move], {'prodlot_id': prodlot_id})
++                    prodlot = prodlot_obj.browse(cr, uid, prodlot_id) 
++                    ref = '%d' % (current_move)
++                    if prodlot.ref:
++                        ref = '%s, %s' % (prodlot.ref, ref) 
++                    prodlot_obj.write(cr, uid, [prodlot_id], {'ref': ref})
++                    
++                    update_val = {}
++                    if quantity_rest > 0:                        
++                        update_val['product_qty'] = quantity_rest
++                        update_val['product_uos_qty'] = uos_qty_rest                          
++                        move_obj.write(cr, uid, [move.id], update_val)
++
++                    
++        return new_move
++split_in_production_lot()
++
++class stock_move_split_lines(osv.osv_memory):
++    _name = "stock.move.split.lines"
++    _description = "Split lines"
++    
++    _columns = {
++        'name': fields.char('Tracking serial', size=64), 
++        'quantity': fields.integer('Quantity'), 
++        'use_exist' : fields.boolean('Use Exist'),
++        'lot_id': fields.many2one('stock.move.split', 'Lot'),
++        'action': fields.selection([('split','Split'),('keepinone','Keep in one lot')],'Action'),
++    }
++    _defaults = {
++        'quantity': lambda *x: 1,
++        'action' : lambda *x: 'split', 
++    }
++
++stock_move_split_lines()
index 0000000,0000000..55fc8a6
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,141 @@@
++<?xml version="1.0" encoding="utf-8"?>
++<openerp>
++    <data>
++    
++          <record id="view_stock_move_track_wizard" model="ir.ui.view">
++                  <field name="name">Tracking a move</field>
++                  <field name="model">stock.move.track</field>
++                  <field name="type">form</field>
++                  <field name="arch" type="xml">
++                      <form string="Tracking a move">
++                              <field name="tracking_prefix" colspan="4"/>
++                              <field name="quantity" colspan="4"/>
++                              <newline/>
++                              <separator string="" colspan="4" />
++                              <button icon='gtk-cancel' special="cancel"
++                                      string="Cancel" />
++                              <button name="track_lines" string="Ok"
++                                      type="object" icon="gtk-ok" />
++                      </form>
++                  </field>
++              </record>
++      
++              <record id="track_line_old" model="ir.actions.act_window">
++                  <field name="name">Tracking a move</field>
++                  <field name="type">ir.actions.act_window</field>
++                  <field name="res_model">stock.move.track</field>
++                  <field name="view_type">form</field>
++                  <field name="view_mode">form</field>
++                  <field name="target">new</field>
++              </record>
++              
++        
++        <!--  Consume, scrap move -->
++        
++              <record id="view_stock_move_consume_wizard" model="ir.ui.view">
++            <field name="name">Consume Move</field>
++            <field name="model">stock.move.consume</field>
++            <field name="type">form</field>
++            <field name="arch" type="xml">
++                <form string="Consume Move">
++                      <separator string="Consume Products" colspan="4"/>
++                                  <field name="product_id" colspan="4" readonly="1"/>
++                                  <field name="location_id" colspan="4"/>
++                                  <field name="product_qty" colspan="2"/>
++                                  <field name="product_uom" nolabel="1" readonly="1"/>
++                      <newline/>
++                      <separator string="" colspan="4" />
++                      <label string="" colspan="2" />
++                      <group col="2" colspan="1">
++                              <button icon='gtk-cancel' special="cancel"
++                                      string="Cancel" />
++                              <button name="do_move_consume" string="Ok"
++                                      colspan="1" type="object" icon="gtk-ok" />
++                      </group>
++                </form>
++            </field>
++        </record>
++
++        <record id="move_consume" model="ir.actions.act_window">
++            <field name="name">Consume Move</field>
++            <field name="type">ir.actions.act_window</field>
++            <field name="res_model">stock.move.consume</field>
++            <field name="view_type">form</field>
++            <field name="view_mode">form</field>
++            <field name="target">new</field>
++        </record>
++        
++       <record id="view_stock_move_scrap_wizard" model="ir.ui.view">
++            <field name="name">Scrap Move</field>
++            <field name="model">stock.move.scrap</field>
++            <field name="type">form</field>
++            <field name="arch" type="xml">
++                <form string="Scrap Move">
++                      <separator string="Scrap Products" colspan="4"/>
++                                  <field name="product_id" colspan="4" readonly="1"/>
++                                  <field name="location_id" colspan="4" string="Dest. Location" domain="[('usage','&lt;&gt;','view')]"/>
++                                  <field name="product_qty" colspan="2"/>
++                                  <field name="product_uom" nolabel="1" readonly="1"/>
++                      <newline/>
++                      <separator string="" colspan="4" />
++                      <label string="" colspan="2" />
++                      <group col="2" colspan="1">
++                              <button icon='gtk-cancel' special="cancel"
++                                      string="Cancel" />
++                              <button name="move_scrap" string="Ok"
++                                      colspan="1" type="object" icon="gtk-ok" />
++                      </group>
++                </form>
++            </field>
++        </record>
++
++        <record id="move_scrap" model="ir.actions.act_window">
++            <field name="name">Scrap Move</field>
++            <field name="type">ir.actions.act_window</field>
++            <field name="res_model">stock.move.scrap</field>
++            <field name="view_type">form</field>
++            <field name="view_mode">form</field>
++            <field name="target">new</field>
++        </record>
++        
++        <record id="view_split_in_lots" model="ir.ui.view">
++                  <field name="name">Split in lots</field>
++                  <field name="model">stock.move.split</field>
++                  <field name="type">form</field>
++                  <field name="arch" type="xml">
++                      <form string="Split in lots">
++                              <field name="product_id" colspan="4" readonly="1"/>
++                              <newline/>
++                              <field name="line_ids" colspan="4" nolabel="1">
++                                      <tree string="Lots Number" editable="top">
++                                              <field name="name" string="Lots"/>
++                                              <field name="quantity" />
++                                <field name="use_exist" />
++                                      </tree>
++                                      <form string="Lots Number">
++                                              <field name="name" string="Lots"/>
++                                              <field name="quantity" />
++                                <field name="use_exist" />
++                                      </form>
++                              </field>
++                              <separator string="" colspan="4" />
++                              <label string="" colspan="2" />
++                              <button icon='gtk-cancel' special="cancel"
++                                      string="Cancel" />
++                              <button name="split_lot" string="Ok"
++                                      type="object" icon="gtk-ok" />
++                      </form>
++                  </field>
++              </record>
++      
++              <record id="track_line" model="ir.actions.act_window">
++                  <field name="name">Split in lots</field>
++                  <field name="type">ir.actions.act_window</field>
++                  <field name="res_model">stock.move.split</field>
++                  <field name="view_type">form</field>
++                  <field name="view_mode">form</field>
++                  <field name="target">new</field>
++              </record>          
++
++      </data>
++</openerp>