[IMP] UoM in mrp + rereserve of partial
authorJosse Colpaert <jco@odoo.com>
Mon, 22 Sep 2014 15:42:59 +0000 (17:42 +0200)
committerJosse Colpaert <jco@odoo.com>
Tue, 30 Sep 2014 08:31:33 +0000 (10:31 +0200)
addons/mrp/mrp.py
addons/mrp/stock.py
addons/stock/stock.py
addons/stock/stock_view.xml

index db62e26..9086870 100644 (file)
@@ -707,6 +707,7 @@ class mrp_production(osv.osv):
             factor = uom_obj._compute_qty(cr, uid, production.product_uom.id, production.product_qty, bom_point.product_uom.id)
             # product_lines, workcenter_lines
             results, results2 = bom_obj._bom_explode(cr, uid, bom_point, production.product_id, factor / bom_point.product_qty, properties, routing_id=production.routing_id.id, context=context)
+
             # reset product_lines in production order
             for line in results:
                 line['production_id'] = production.id
@@ -825,6 +826,7 @@ class mrp_production(osv.osv):
             Calculates the quantity still needed to produce an extra number of products
         """
         quant_obj = self.pool.get("stock.quant")
+        uom_obj = self.pool.get("product.uom")
         produced_qty = self._get_produced_qty(cr, uid, production, context=context)
         consumed_data = self._get_consumed_data(cr, uid, production, context=context)
 
@@ -857,6 +859,9 @@ class mrp_production(osv.osv):
                 total_consume = (production.product_qty * scheduled.product_qty / production.product_qty)
             qty = total_consume - consumed_qty
 
+            # Convert to UoM of product itself
+            qty = uom_obj._compute_qty(cr, uid, scheduled.product_uom.id, qty, scheduled.product_id.uom_id.id, round=False)
+
             # Search for quants related to this related move
             for move in production.move_lines:
                 if qty <= 0.0:
@@ -902,11 +907,7 @@ class mrp_production(osv.osv):
         """
         stock_mov_obj = self.pool.get('stock.move')
         production = self.browse(cr, uid, production_id, context=context)
-        if not production.move_lines and production.state == 'ready':
-            # trigger workflow if not products to consume (eg: services)
-            self.signal_workflow(cr, uid, [production_id], 'button_produce')
 
-        produced_qty = self._get_produced_qty(cr, uid, production, context=context)
 
         main_production_move = False
         if production_mode == 'consume_produce':
index e8613e7..15eddd6 100644 (file)
@@ -177,10 +177,9 @@ class StockMove(osv.osv):
 
         for move in self.browse(cr, uid, ids2, context=context):
             move_qty = move.product_qty
-            uom_qty = uom_obj._compute_qty(cr, uid, move.product_id.uom_id.id, product_qty, move.product_uom.id)
             if move_qty <= 0:
                 raise osv.except_osv(_('Error!'), _('Cannot consume a move with negative or zero quantity.'))
-            quantity_rest = move.product_qty - uom_qty
+            quantity_rest = move_qty - product_qty
             if quantity_rest > 0:
                 ctx = context.copy()
                 if location_id:
index 973136c..bd667d6 100644 (file)
@@ -2155,7 +2155,6 @@ class stock_move(osv.osv):
                 move = record.move_id
                 if move.id in main_domain:
                     domain = main_domain[move.id] + self.pool.get('stock.move.operation.link').get_specific_domain(cr, uid, record, context=context)
-                    qty = record.qty
                     if qty:
                         quants = quant_obj.quants_get_prefered_domain(cr, uid, ops.location_id, move.product_id, qty, domain=domain, prefered_domain_list=[], restrict_lot_id=move.restrict_lot_id.id, restrict_partner_id=move.restrict_partner_id.id, context=context)
                         quant_obj.quants_reserve(cr, uid, quants, move, record, context=context)
index 51e0e59..675a5bc 100644 (file)
                 <form string="Transfer">
                 <header>
                     <button name="action_confirm" states="draft" string="Mark as Todo" type="object" class="oe_highlight" groups="base.group_user"/>
-                    <button name="action_assign" states="confirmed,partially_available" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
+                    <button name="action_assign" states="confirmed" string="Check Availability" type="object" class="oe_highlight" groups="base.group_user"/>
+                    <button name="rereserve_pick" states="partially_available" string="Recheck Availability" class="oe_highlight" groups="base.group_user"/>
                     <button name="force_assign" states="confirmed,waiting,partially_available" string="Force Availability" type="object" groups="base.group_user"/>
                     <button name="do_enter_transfer_details" states="assigned,partially_available" string="Transfer" groups="stock.group_stock_user" type="object" class="oe_highlight"/>
                     <button name="do_print_picking" string="Print Picking List" groups="stock.group_stock_user" type="object" attrs="{'invisible': ['|', ('picking_type_code', '=', 'outgoing'), ('state', '!=', 'assigned')]}"/>