diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index 356326d0738..9151c150983 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -509,7 +509,7 @@ class mrp_production(osv.osv): for production in self.browse(cr, uid, ids, context=context): res[production.id] = True states = [x.state != 'assigned' for x in production.move_lines if x] - if any(states) or len(states) == 0: + if any(states) or len(states) == 0: #When no moves, ready_production will be False, but test_ready will pass res[production.id] = False return res @@ -831,6 +831,8 @@ class mrp_production(osv.osv): dicts = {} # Find product qty to be consumed and consume it for scheduled in production.product_lines: + if scheduled.product_id.type == 'service': + continue product_id = scheduled.product_id.id consumed_qty = consumed_data.get(product_id, 0.0) @@ -1018,11 +1020,12 @@ class mrp_production(osv.osv): return res def test_ready(self, cr, uid, ids): - res = False + res = True for production in self.browse(cr, uid, ids): - if production.ready_production: - res = True + if production.move_lines and not production.ready_production: + res = False return res + def _make_production_produce_line(self, cr, uid, production, context=None): @@ -1155,9 +1158,6 @@ class mrp_production(osv.osv): stock_moves.append(stock_move_id) if stock_moves: self.pool.get('stock.move').action_confirm(cr, uid, stock_moves, context=context) - else: - raise osv.except_osv(_('Error!'), - _('It does not make sense to create a production order without any physical product to consume')) production.write({'state': 'confirmed'}, context=context) return 0 @@ -1165,9 +1165,12 @@ class mrp_production(osv.osv): """ Checks the availability on the consume lines of the production order """ + from openerp import workflow move_obj = self.pool.get("stock.move") for production in self.browse(cr, uid, ids, context=context): move_obj.action_assign(cr, uid, [x.id for x in production.move_lines], context=context) + if self.pool.get('mrp.production').test_ready(cr, uid, [production.id]): + workflow.trg_validate(uid, 'mrp.production', production.id, 'moves_ready', cr) def force_production(self, cr, uid, ids, *args): @@ -1175,9 +1178,12 @@ class mrp_production(osv.osv): @param *args: Arguments @return: True """ + from openerp import workflow move_obj = self.pool.get('stock.move') for order in self.browse(cr, uid, ids): move_obj.force_assign(cr, uid, [x.id for x in order.move_lines]) + if self.pool.get('mrp.production').test_ready(cr, uid, [order.id]): + workflow.trg_validate(uid, 'mrp.production', order.id, 'moves_ready', cr) return True diff --git a/addons/mrp/mrp_workflow.xml b/addons/mrp/mrp_workflow.xml index ce565f9bcd1..c22b90811cb 100644 --- a/addons/mrp/mrp_workflow.xml +++ b/addons/mrp/mrp_workflow.xml @@ -56,9 +56,7 @@ - stock.move - consume_lines_get() - test_ready() + moves_ready diff --git a/addons/mrp/stock.py b/addons/mrp/stock.py index 270ccc7f9b6..fcd2ae66cef 100644 --- a/addons/mrp/stock.py +++ b/addons/mrp/stock.py @@ -228,9 +228,12 @@ class StockMove(osv.osv): ids = [ids] res = super(StockMove, self).write(cr, uid, ids, vals, context=context) from openerp import workflow - for move in self.browse(cr, uid, ids, context=context): - if move.raw_material_production_id and move.raw_material_production_id.state == 'confirmed': - workflow.trg_trigger(uid, 'stock.move', move.id, cr) + if vals.get('state') == 'assigned': + moves = self.browse(cr, uid, ids, context=context) + orders = list(set([x.raw_material_production_id.id for x in moves if x.raw_material_production_id and x.raw_material_production_id.state == 'confirmed'])) + for order_id in orders: + if self.pool.get('mrp.production').test_ready(cr, uid, [order_id]): + workflow.trg_validate(uid, 'mrp.production', order_id, 'moves_ready', cr) return res class stock_warehouse(osv.osv): diff --git a/addons/product/product_demo.xml b/addons/product/product_demo.xml index 763c7620b13..093a25b2e23 100644 --- a/addons/product/product_demo.xml +++ b/addons/product/product_demo.xml @@ -225,11 +225,11 @@ FaceTime HD Camera, 1.2 MP Photos - + Bose Mini Bluetooth Speaker - 600.0 - 147.0 + 140.0 + 247.0 consu @@ -239,6 +239,18 @@ FaceTime HD Camera, 1.2 MP Photos + + PC Assemble + Custom (PC on Demand) + + 600.0 + 147.0 + consu + + + Custom computer assembled on order based on customer's requirement. + B3423 + + iPad Mini diff --git a/addons/product/product_image_demo.xml b/addons/product/product_image_demo.xml index a9d8e7b7c9e..697b31394c0 100644 --- a/addons/product/product_image_demo.xml +++ b/addons/product/product_image_demo.xml @@ -23,6 +23,10 @@ + + + + diff --git a/addons/stock/procurement_demo.xml b/addons/stock/procurement_demo.xml index e0cd40ae2eb..26fbc813e0b 100644 --- a/addons/stock/procurement_demo.xml +++ b/addons/stock/procurement_demo.xml @@ -8,12 +8,16 @@ product - + product + + product + + product diff --git a/addons/stock/stock.py b/addons/stock/stock.py index bbfa193b748..70c700199d6 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -2395,7 +2395,6 @@ class stock_move(osv.osv): defaults = { 'product_uom_qty': uom_qty, 'product_uos_qty': uos_qty, - 'state': move.state, 'procure_method': 'make_to_stock', 'restrict_lot_id': restrict_lot_id, 'restrict_partner_id': restrict_partner_id, diff --git a/addons/stock/stock_demo.xml b/addons/stock/stock_demo.xml index 64148c3485e..5bada91afd2 100644 --- a/addons/stock/stock_demo.xml +++ b/addons/stock/stock_demo.xml @@ -60,7 +60,7 @@ - + 8.0 diff --git a/addons/website_sale/data/demo.xml b/addons/website_sale/data/demo.xml index 952497bd547..e72db17389f 100644 --- a/addons/website_sale/data/demo.xml +++ b/addons/website_sale/data/demo.xml @@ -60,7 +60,7 @@ - + 2 @@ -688,7 +688,7 @@ Weight: 1.1 ounces - +