From c6c622542bd3c2d054f066b57017fc4f1a809be3 Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Mon, 22 Sep 2014 17:42:59 +0200 Subject: [PATCH] [IMP] UoM in mrp + rereserve of partial --- addons/mrp/mrp.py | 9 +++++---- addons/mrp/stock.py | 3 +-- addons/stock/stock.py | 1 - addons/stock/stock_view.xml | 3 ++- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index db62e265430..90868700c17 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -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': diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index e8613e7fb8e..15eddd61b69 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -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: diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 973136c1ed7..bd667d6044b 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -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) diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 51e0e595e65..675a5bcb883 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -645,7 +645,8 @@