From 655570fe23f6ac4eaea07dbf86721ae7e00ea12d Mon Sep 17 00:00:00 2001 From: Josse Colpaert Date: Fri, 22 Aug 2014 17:28:04 +0200 Subject: [PATCH] [IMP] Domain on model instead of view + no production order without consume lines --- addons/mrp/mrp.py | 7 +++++-- addons/mrp/mrp_view.xml | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/addons/mrp/mrp.py b/addons/mrp/mrp.py index a8c39c7a09c..356326d0738 100644 --- a/addons/mrp/mrp.py +++ b/addons/mrp/mrp.py @@ -198,9 +198,9 @@ class mrp_bom(osv.osv): 'type': fields.selection([('normal', 'Normal'), ('phantom', 'Set')], 'BoM Type', required=True, help= "Set: When processing a sales order for this product, the delivery order will contain the raw materials, instead of the finished product."), 'position': fields.char('Internal Reference', help="Reference to a position in an external plan."), - 'product_tmpl_id': fields.many2one('product.template', 'Product', required=True), + 'product_tmpl_id': fields.many2one('product.template', 'Product', domain="[('type', '!=', 'service')]", required=True), 'product_id': fields.many2one('product.product', 'Product Variant', - domain="[('product_tmpl_id','=',product_tmpl_id)]", + domain="['&', ('product_tmpl_id','=',product_tmpl_id), ('type','!=', 'service')]", help="If a product variant is defined the BOM is available only for this product."), 'bom_line_ids': fields.one2many('mrp.bom.line', 'bom_id', 'BoM Lines', copy=True), 'product_qty': fields.float('Product Quantity', required=True, digits_compute=dp.get_precision('Product Unit of Measure')), @@ -1155,6 +1155,9 @@ 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 diff --git a/addons/mrp/mrp_view.xml b/addons/mrp/mrp_view.xml index 81c78858052..7659dc1981a 100644 --- a/addons/mrp/mrp_view.xml +++ b/addons/mrp/mrp_view.xml @@ -347,8 +347,8 @@
- - + +