[REF] stock: small code refactoring
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Mon, 28 Apr 2014 09:27:26 +0000 (11:27 +0200)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Mon, 28 Apr 2014 09:27:26 +0000 (11:27 +0200)
bzr revid: qdp-launchpad@openerp.com-20140428092726-1vo51if06q2o2b8y

addons/stock/doc/stock.rst
addons/stock/product.py
addons/stock/report/product_stock.py
addons/stock/stock.py

index 0501d03..42b9c79 100644 (file)
@@ -515,7 +515,7 @@ Negative stocks
 
 It is still possible that upon transferring for an internal shipment or delivery, the necessary quants or stock can not be found.  In that case, it will create negative stock (negative quants).    
 
-When later on, a move brings in some goods that correspond to this negative stock, the quant can be reconciled with it.  This will however not happen if this incoming quant has a chained move to another location.  
+When later on, a move brings in some goods that correspond to this negative stock, the quant can be reconciled with it.
 
 Normally, chained moves have to take from their original moves.  Only when you do force assign a move with original moves it can also take from the regular stock that is not chained.  It will however not assign this stock before actually doing the transfer.  
 
index 766ab67..54353cd 100644 (file)
@@ -90,9 +90,8 @@ class product_product(osv.osv):
             for w in warehouse_obj.browse(cr, uid, wids, context=context):
                 location_ids.append(w.view_location_id.id)
 
-        operator = context.get('compute_child',True) and 'child_of' or 'in'
+        operator = context.get('compute_child', True) and 'child_of' or 'in'
         domain = context.get('force_company', False) and ['&', ('company_id', '=', context['force_company'])] or []
-        domain += [('product_id', 'in', ids)]
         return (
             domain + [('location_id', operator, location_ids)],
             domain + ['&', ('location_dest_id', operator, location_ids), '!', ('location_id', operator, location_ids)],
index b899436..8122e60 100644 (file)
@@ -42,8 +42,6 @@ class external_pdf(render):
         return self.pdf
 
 
-# FP Note: change to use product_qty instead of product_uom_qty to avoid doing conversions
-
 class report_stock(report_int):
     def create(self, cr, uid, ids, datas, context=None):
         if context is None:
index 6eea4d3..c7cb577 100644 (file)
@@ -286,13 +286,12 @@ class stock_quant(osv.osv):
 
         'history_ids': fields.many2many('stock.move', 'stock_quant_move_rel', 'quant_id', 'move_id', 'Moves', help='Moves that operate(d) on this quant'),
         'company_id': fields.many2one('res.company', 'Company', help="The company to which the quants belong", required=True),
+        'inventory_value': fields.function(_calc_inventory_value, string="Inventory Value", type='float', readonly=True),
 
         # Used for negative quants to reconcile after compensated by a new positive one
         'propagated_from_id': fields.many2one('stock.quant', 'Linked Quant', help='The negative quant this is coming from'),
         'negative_move_id': fields.many2one('stock.move', 'Move Negative Quant', help='If this is a negative quant, this will be the move that caused this negative quant.'),
         'negative_dest_location_id': fields.related('negative_move_id', 'location_dest_id', type='many2one', relation='stock.location', string="Negative Destination Location",
-                                                    help="Technical field used to record the destination location of a move that created a negative quant"),
-        'inventory_value': fields.function(_calc_inventory_value, string="Inventory Value", type='float', readonly=True),
     }
 
     _defaults = {
@@ -489,7 +488,7 @@ class stock_quant(osv.osv):
             negative_quant_id = self.create(cr, SUPERUSER_ID, negative_vals, context=context)
             vals.update({'propagated_from_id': negative_quant_id})
 
-        #create the quant as superuser, because we want to restrict the creation of quant manually: they should always use this method to create quants
+        #create the quant as superuser, because we want to restrict the creation of quant manually: we should always use this method to create quants
         quant_id = self.create(cr, SUPERUSER_ID, vals, context=context)
         return self.browse(cr, uid, quant_id, context=context)
 
@@ -3755,17 +3754,12 @@ class stock_pack_operation(osv.osv):
             new_lot_id = self.pool.get('stock.production.lot').create(cr, uid, {'product_id': product_id}, context=context)
             self.write(cr, uid, id, {'lot_id': new_lot_id}, context=context)
 
-    def _search_and_increment(self, cr, uid, picking_id, domain, filter_visible=False ,visible_op_ids=False, increment=True, context=None):
+    def _search_and_increment(self, cr, uid, picking_id, domain, filter_visible=False, visible_op_ids=False, increment=True, context=None):
         '''Search for an operation with given 'domain' in a picking, if it exists increment the qty (+1) otherwise create it
 
         :param domain: list of tuple directly reusable as a domain
         context can receive a key 'current_package_id' with the package to consider for this operation
         returns True
-
-        previously: returns the update to do in stock.move one2many field of picking (adapt remaining quantities) and to the list of package in the classic one2many syntax
-                 (0, 0,  { values })    link to a new record that needs to be created with the given values dictionary
-                 (1, ID, { values })    update the linked record with id = ID (write *values* on it)
-                 (2, ID)                remove and delete the linked record with id = ID (calls unlink on ID, that will delete the object completely, and the link to it as well)
         '''
         if context is None:
             context = {}