[WIP] Make module stock work, for stock_location check removal strategy, journal_id...
authorJosse Colpaert <jco@openerp.com>
Mon, 1 Jul 2013 19:13:08 +0000 (21:13 +0200)
committerJosse Colpaert <jco@openerp.com>
Mon, 1 Jul 2013 19:13:08 +0000 (21:13 +0200)
bzr revid: jco@openerp.com-20130701191308-0ztvfe7bq4kfrqv8

16 files changed:
addons/procurement/procurement.py
addons/stock/__init__.py
addons/stock/procurement.py
addons/stock/product.py
addons/stock/product_view.xml
addons/stock/stock.py
addons/stock/stock_data.xml
addons/stock/stock_view.xml
addons/stock/wizard/stock_partial_picking.py
addons/stock_location/__openerp__.py
addons/stock_location/security/ir.model.access.csv
addons/stock_location/security/stock_location_security.xml
addons/stock_location/stock_location.py
addons/stock_location/stock_location_demo_cpu1.xml
addons/stock_location/stock_location_demo_cpu3.yml
addons/stock_location/stock_location_view.xml

index c7b1e63..bee3bdb 100644 (file)
@@ -26,6 +26,7 @@ from dateutil.relativedelta import relativedelta
 
 from openerp.osv import fields, osv
 import openerp.addons.decimal_precision as dp
+import openerp
 
 class procurement_group(osv.osv):
     '''
@@ -70,7 +71,7 @@ class procurement_rule(osv.osv):
         'name': fields.char('Name', required=True,
             help="This field will fill the packing origin and the name of its moves"),
         'group_id': fields.many2one('procurement.group', 'Procurement Group'),
-        'action': fields.selection(selection=lambda s, c, u, ctx: s._get_action(c, u, context=ctx),
+        'action': fields.selection(selection=lambda s, c, u, context: s._get_action(c, u, context),
             string='Action', required=True)
     }
     def _get_action(self, cr, uid, context=None):
index 058ebb4..4495c45 100644 (file)
@@ -22,6 +22,7 @@
 from stock import *
 import partner
 import product
+import procurement
 #import stock_fifo_lifo
 import report
 import wizard
index ee7f540..e883e14 100644 (file)
@@ -35,11 +35,11 @@ class procurement_group(osv.osv):
 
 class procurement_rule(osv.osv):
     _inherit = 'procurement.rule'
-    def _get_action(self, cr, uid, context=context):
+    def _get_action(self, cr, uid, context=None):
         result = super(procurement_rule, self)._get_action(cr, uid, context=context)
         return result + [('move','Move From Another Location')]
     _columns = {
-        'location_id': fields.many2one('stock.location', 'Destination Location')
+        'location_id': fields.many2one('stock.location', 'Destination Location'), 
         'location_src_id': fields.many2one('stock.location', 'Source Location',
             help="Source location is action=move")
     }
@@ -47,8 +47,8 @@ class procurement_rule(osv.osv):
 class procurement_order(osv.osv):
     _inherit = "procurement.order"
     _columns = {
-        'location_id': fields.many2one('stock.location', 'Destination Location')
-        'move_id': fields.many2one('stock.move', 'Move')
+        'location_id': fields.many2one('stock.location', 'Destination Location'), 
+        'move_id': fields.many2one('stock.move', 'Move'), 
         'move_dest_id': fields.many2one('stock.move', 'Destination Move')
     }
     def _assign(self, cr, uid, procurement, context=None):
@@ -58,7 +58,7 @@ class procurement_order(osv.osv):
             return super(procurement_order, self)._assign(cr, uid, procurement, context=context)
         return rule_obj.browse(cr, uid, res[0], context=context)
 
-    def _run_move_create(self, cr, uid, procurement, context=None)
+    def _run_move_create(self, cr, uid, procurement, context=None): 
         return {
             'name': procurement.name,
             'company_id':  procurement.company_id.id,
index ed93816..ed39faf 100644 (file)
@@ -443,20 +443,10 @@ class product_template(osv.osv):
     }
 
 
-# TODO: move this on stock module
-
-class product_removal_strategy(osv.osv):
-    _name = 'product.removal'
-    _description = 'Removal Strategy'
-    _columns = {
-        'categ_ids':fields.one2many('product.category','removal_strategy_id', 'Product Categories', required=True),
-        'method': fields.selection([('fifo', 'FIFO'), ('lifo', 'LIFO')], "Method", required=True), 
-    }
 
 class product_category(osv.osv):
     _inherit = 'product.category'
     _columns = {
-        'removal_strategy_id': fields.many2one('product.removal', 'Removal Strategy'),
         'property_stock_journal': fields.property(
             relation='account.journal',
             type='many2one',
index 2ea5fda..d7617ba 100644 (file)
@@ -27,9 +27,6 @@
                             <field name="property_stock_valuation_account_id" domain="[('type','&lt;&gt;','view'), ('type','&lt;&gt;','consolidation')]"/>
                             <field name="property_stock_journal"/>
                         </group>
-                        <group name="removal">
-                            <field name="removal_strategy"/>
-                        </group>
                     </group>
                 </data>
             </field>
index 12097a0..936c66d 100644 (file)
@@ -143,10 +143,11 @@ class stock_location(osv.osv):
         'scrap_location': False,
     }
     def get_removal_strategy(self, cr, uid, location, product, context=None):
-        categ = product.categ_id
-        while (not categ.removal_strategy_id) and categ.parent_id:
-            categ = categ.parent_id
-        return categ and categ.removal_strategy_id or None
+        return None
+#         categ = product.categ_id
+#         while (not categ.removal_strategy_id) and categ.parent_id:
+#             categ = categ.parent_id
+#         return categ and categ.removal_strategy_id or None
 
 #----------------------------------------------------------
 # Quants
@@ -2022,10 +2023,14 @@ class stock_move(osv.osv):
                             dp.append(q.id)
                 quants = quant_obj.quants_get(cr, uid, move.location_id, move.product_id, qty, domain_preference=dp and [('id', 'in', dp)], context=context)
                 quant_obj.quants_reserve(cr, uid, quants, move, context=context)
+                #TODO Should have a check to really check it passed
+                sum_of_qua = 0
+                for qua in quants:
+                    sum_of_qua += qua[1]
+                if qua >= move.product_uom_qty:
+                    done.append(move.id)
         self.write(cr, uid, done, {'state': 'assigned'})
 
-    # FP Note: remove this line
-    check_assign = action_assign
 
     #
     # Cancel move => cancel others move and pickings
index 4f7ed9d..4062cc6 100644 (file)
@@ -114,14 +114,14 @@ watch your stock valuation, and track production lots upstream and downstream (b
              Procurement rules
         -->
 
-        <record id="procurement_rule_customer" model="procurement.rule">
+        <record id="procurement_rule_customer0" model="procurement.rule">
             <field name="name">Output > Customer</field>
             <field name="action">move</field>
             <field name="location_id" ref="stock_location_customers"/>
             <field name="location_src_id" ref="stock_location_output"/>
         </record>
 
-        <record id="procurement_rule_customer" model="procurement.rule">
+        <record id="procurement_rule_customer1" model="procurement.rule">
             <field name="name">Stock > Output</field>
             <field name="action">move</field>
             <field name="location_id" ref="stock_location_output"/>
index 8d67303..e47bbf6 100644 (file)
                 </xpath>
                 <xpath expr="/form/header//button[@name='draft_validate']" position="replace">
                     <button name="draft_validate" states="draft" string="Confirm &amp; Deliver" type="object" class="oe_highlight"/>
-                    <button name="check_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight"/>
+                    <button name="action_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight"/>
                 </xpath>
                 <xpath expr="/form/header//button[@name='action_process']" position="replace">
                     <button name="action_process" states="assigned" string="Deliver" type="object" class="oe_highlight"/>
index 8646df6..740b92f 100644 (file)
@@ -148,7 +148,6 @@ class stock_partial_picking(osv.osv_memory):
             'product_id': move.product_id.id,
             'quantity': move.product_qty - move.remaining_qty if move.state == 'assigned' else 0,
             'product_uom': move.product_uom.id,
-            'lot_id': move.lot_id.id,
             'move_id': move.id,
             'location_id': move.location_id.id,
             'location_dest_id': move.location_dest_id.id,
index 65fd8c0..ca1ebc3 100644 (file)
@@ -95,7 +95,7 @@ You can use the demo data as follow:
     """,
     'author': 'OpenERP SA',
     'images': ['images/pulled_flow.jpeg','images/pushed_flow.jpeg'],
-    'depends': ['procurement','stock','sale'],
+    'depends': ['procurement','stock'],
     'data': ['stock_location_view.xml', 'security/stock_location_security.xml', 'security/ir.model.access.csv'],
     'demo': [
         'stock_location_demo_cpu1.xml',
index ebee12c..cffbf9e 100644 (file)
@@ -1,12 +1,12 @@
-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink\r
-access_product_pulled_flow_user,product_pulled_flow user,model_product_pulled_flow,stock.group_stock_user,1,0,0,0\r
-access_product_pulled_flow_manager,product_pulled_flow manager,model_product_pulled_flow,stock.group_stock_manager,1,1,1,1\r
-access_product_pulled_flow_salemanager,product_pulled_flow salemanager,model_product_pulled_flow,base.group_sale_manager,1,1,1,1\r
-access_product_pulled_flow_stock_manager,product_pulled_flow stock manager,model_product_pulled_flow,stock.group_stock_manager,1,1,1,1\r
-access_stock_location_path_user,stock location path user,model_stock_location_path,stock.group_stock_user,1,0,0,0\r
-access_stock_location_path_internal_user,stock location path internal user,model_stock_location_path,base.group_user,1,0,0,0\r
-access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_manager,1,1,1,1\r
-access_stock_location_path_stock_user,stock.location.path stock user,model_stock_location_path,stock.group_stock_user,1,1,1,1\r
-access_stock_location_path,stock.location.path,model_stock_location_path,base.group_sale_salesman,1,0,0,0\r
-access_product_pulled_flow,product.pulled.flow,model_product_pulled_flow,base.group_sale_salesman,1,0,0,0\r
-access_product_pulled_flow_internal,product.pulled.flow internal,model_product_pulled_flow,base.group_user,1,0,0,0\r
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_procurement_rule_user,procurement_rule user,model_procurement_rule,stock.group_stock_user,1,0,0,0
+access_procurement_rule_manager,procurement_rule manager,model_procurement_rule,stock.group_stock_manager,1,1,1,1
+access_procurement_rule_salemanager,procurement_rule salemanager,model_procurement_rule,base.group_sale_manager,1,1,1,1
+access_procurement_rule_stock_manager,procurement_rule stock manager,model_procurement_rule,stock.group_stock_manager,1,1,1,1
+access_stock_location_path_user,stock location path user,model_stock_location_path,stock.group_stock_user,1,0,0,0
+access_stock_location_path_internal_user,stock location path internal user,model_stock_location_path,base.group_user,1,0,0,0
+access_stock_location_path_sale_manager,stock.location.path partner salemanager,model_stock_location_path,base.group_sale_manager,1,1,1,1
+access_stock_location_path_stock_user,stock.location.path stock user,model_stock_location_path,stock.group_stock_user,1,1,1,1
+access_stock_location_path,stock.location.path,model_stock_location_path,base.group_sale_salesman,1,0,0,0
+access_procurement_rule,procurement.rule.flow,model_procurement_rule,base.group_sale_salesman,1,0,0,0
+access_procurement_rule_internal,procurement.rule.flow internal,model_procurement_rule,base.group_user,1,0,0,0
index 310c45d..2f40661 100644 (file)
@@ -5,7 +5,7 @@
 <!-- multi -->
      <record model="ir.rule" id="product_pulled_flow_comp_rule">
         <field name="name">product_pulled_flow multi-company</field>
-        <field name="model_id" ref="model_product_pulled_flow"/>
+        <field name="model_id" ref="model_procurement_rule"/>
         <field name="global" eval="True"/>
         <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field>
     </record>
index 20c4f47..edcb667 100644 (file)
@@ -31,7 +31,6 @@ class stock_location_route(osv.osv):
         'sequence': fields.integer('Sequence'),
         'pull_ids': fields.one2many('procurement.rule', 'route_id', 'Pull Rules'),
         'push_ids': fields.one2many('stock.location.path', 'route_id', 'Push Rules'),
-        'journal_id': fields.many2one('stock.journal','Journal'),
     }
     _defaults = {
         'sequence': lambda self,cr,uid,ctx: 0,
@@ -85,7 +84,7 @@ class stock_location_path(osv.osv):
                 vals['stock_journal_id'] = route.journal_id.id
             vals['type'] = rule.picking_type
             if rule.location_dest_id.id<>move.location_dest_id.id:
-                move_obj._push_apply(self, cr, uid, move.id, context):
+                move_obj._push_apply(self, cr, uid, move.id, context)
             return move.id
         else:
             move_id = move_obj.copy(cr, uid, move.id, {
@@ -94,7 +93,7 @@ class stock_location_path(osv.osv):
                 'date': time.strftime('%Y-%m-%d'),
                 'company_id': rule.company_id.id,
                 'date_expected': newdate,
-            )
+            })
             move_obj.write(cr, uid, [move.id], {
                 'move_dest_id': move_id,
             })
@@ -102,13 +101,12 @@ class stock_location_path(osv.osv):
             return move_id
 
 
-class procurement.rule(osv.osv):
+class procurement_rule(osv.osv):
     _inherit = 'procurement.rule'
     _columns = {
         'route_id': fields.many2one('stock.location.route', 'Route',
             help="If route_id is False, the route is global"),
         'delay': fields.integer('Number of Hours'),
-        'route_id': fields.many2one('stock.location.route', 'Route'),
         'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procure Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until re-supplying. 'Make to Order': When needed, purchase or produce for the procurement request."),
         'type_proc': fields.selection([('produce','Produce'),('buy','Buy'),('move','Move')], 'Type of Procurement', required=True),
         'partner_address_id': fields.many2one('res.partner', 'Partner Address'),
@@ -126,12 +124,14 @@ class procurement.rule(osv.osv):
 
 
 class procurement_order(osv.osv):
+    _inherit = 'procurement.order'
+    
     def _run_move_create(self, cr, uid, procurement, move, context=None):
         d = super(procurement_order, self)._run_move_create(cr, uid, procurement, move, context=context)
         newdate = (datetime.strptime(move.date, '%Y-%m-%d %H:%M:%S') - relativedelta(days=rule.delay or 0)).strftime('%Y-%m-%d %H:%M:%S')
         d.update({
             'date_planned': newdate,
-            'procure_method': rule.procure_method,
+            'procure_method': procurement.rule_id.procure_method,
         })
         return d
 
@@ -159,11 +159,13 @@ class product_putaway_strategy(osv.osv):
 # TODO: move this on stock module
 
 class product_removal_strategy(osv.osv):
-    _inherit = 'product.removal'
+    _name = 'product.removal'
+    _description = 'Removal Strategy'
     _order = 'sequence'
     _columns = {
+        'product_categ_id': fields.many2one('product.removal', 'Category', required=True), 
         'sequence': fields.integer('Sequence'),
-        'location_id': fields.many2one('stock.location', 'Locations'),
+        'location_id': fields.many2one('stock.location', 'Locations', required=True),
     }
 
 class product_product(osv.osv):
index c756dac..abfa79a 100644 (file)
@@ -14,7 +14,6 @@
                 <field name="usage">internal</field>
                 <field name="chained_location_type">none</field>
                 <field name="name">Quality Control</field>
-                <field name="chained_auto_packing">manual</field>
         </record>
         <record id="stock_location_path_4" model="stock.location.path">
             <field model="stock.location" name="location_from_id" search="[('name', '=', u'Input')]"/>
             <field name="product_id" ref="product.product_product_10"/>
             <field name="auto">manual</field>
             <field name="invoice_state">none</field>
-            <field name="journal_id" ref="stock_journal_quality"/>
             <field name="name">Store in Shelf</field>
             <field eval="5" name="delay"/>
             <field name="location_dest_id" ref="stock.stock_location_14"/>
             <field name="picking_type">internal</field>
         </record>
 
-        <record id="product_pulled_flow_l0" model="product.pulled.flow">
+        <record id="product_pulled_flow_l0" model="procurement.rule">
             <field name="product_id" ref="product.product_product_9"/>
             <field name="location_src_id" ref="stock.stock_location_intermediatelocation0"/>
             <field name="location_id" ref="stock.stock_location_shop0"/>
@@ -51,8 +49,9 @@
             <field name="procure_method">make_to_order</field>
             <field name="picking_type">in</field>
             <field name="name">Receive from Warehouse</field>
+            <field name="action">move</field>
         </record>
-        <record id="product_pulled_flow_l1" model="product.pulled.flow">
+        <record id="product_pulled_flow_l1" model="procurement.rule">
             <field name="product_id" ref="product.product_product_9"/>
             <field name="location_id" ref="stock.stock_location_intermediatelocation0"/>
             <field name="location_src_id" ref="stock.stock_location_stock"/>
@@ -64,6 +63,7 @@
             <field name="procure_method">make_to_stock</field>
             <field name="picking_type">out</field>
             <field name="name">Deliver Shop</field>
+            <field name="action">move</field>
         </record>
         <record id="stock_warehouse_orderpoint_shop1_cpu1" model="stock.warehouse.orderpoint">
             <field name="product_max_qty">20.0</field>
@@ -73,6 +73,7 @@
             <field name="warehouse_id" ref="stock.stock_warehouse_shop0"/>
             <field name="location_id" ref="stock.stock_location_shop0"/>
             <field name="product_id" ref="product.product_product_9"/>
+            <field name="action">move</field>
         </record>
 
     </data>
index 8bb27c9..e1df7f1 100644 (file)
     name: Gate A
     usage: internal
     location_id: location_dispatch_zone
-    chained_journal_id: journal_gate_a
-    chained_location_type: customer
-    chained_auto_packing: manual
-    chained_picking_type: out
 - 
   !record {model: stock.location, id: location_pack_zone}:
     name: Pack Zone
     usage: internal
     location_id: location_order
-    chained_journal_id: journal_pack
-    chained_location_id: location_gate_a
-    chained_location_type: fixed
-    chained_auto_packing: manual
-    chained_picking_type: internal
 - 
   !record {model: stock.location, id: location_gate_b}:
     name: Gate B
@@ -48,8 +39,6 @@
   !record {model: stock.location.path, id: push_pick}:
     name: Pick List
     product_id: product.product_product_10
-    journal_id: journal_pick
     location_from_id: stock.stock_location_output
     location_dest_id: location_pack_zone
     picking_type: internal
-    auto: transparent
index 0ace8fe..1afa6c5 100644 (file)
@@ -45,7 +45,6 @@
                                 <field name="name"/>
                                 <field name="location_id" attrs="{'required': [('type_proc', '=', 'move')]}"/>
                                 <field name="type_proc"/>
-                                <field name="journal_id"/>
                                 <field name="company_id" groups="base.group_multi_company"/>
                             </tree>
                             <form string="Pulled Paths">
@@ -66,7 +65,6 @@
                                     <field name="procure_method"/>
                                     <field name="cancel_cascade"/>
                                     <field name="invoice_state"/>
-                                    <field name="journal_id"/>
                                 </group>
                             </form>
                         </field>
@@ -87,7 +85,6 @@
                                 <field name="location_dest_id"/>
                                 <field name="auto"/>
                                 <field name="delay"/>
-                                <field name="journal_id"/>
                                 <field name="picking_type"/>
                                 <field name="invoice_state"/>
                                 <field name="company_id" groups="base.group_multi_company"/>