diff --git a/addons/procurement/procurement.py b/addons/procurement/procurement.py index 359586fae7e..3ac5ac2632f 100644 --- a/addons/procurement/procurement.py +++ b/addons/procurement/procurement.py @@ -62,11 +62,11 @@ mrp_property() class StockMove(osv.osv): _inherit = 'stock.move' - + _columns= { 'procurements': fields.one2many('procurement.order', 'move_id', 'Procurements'), } - + def copy(self, cr, uid, id, default=None, context=None): default = default or {} default['procurements'] = [] @@ -134,7 +134,7 @@ class procurement_order(osv.osv): if s['state'] in ['draft','cancel']: unlink_ids.append(s['id']) else: - raise osv.except_osv(_('Invalid action !'), + raise osv.except_osv(_('Invalid action !'), _('Cannot delete Procurement Order(s) which are in %s State!') % \ s['state']) return osv.osv.unlink(self, cr, uid, unlink_ids, context=context) @@ -169,7 +169,12 @@ class procurement_order(osv.osv): """ Checks if move is done or not. @return: True or False. """ - return all(procurement.move_id.state == 'done' for procurement in self.browse(cr, uid, ids)) + res = True + for proc in self.browse(cr, uid, ids, context): + if proc.move_id: + if not proc.move_id.state=='done': + res = False + return res # # This method may be overrided by objects that override procurement.order @@ -283,7 +288,7 @@ class procurement_order(osv.osv): if procurement.product_id.product_tmpl_id.supply_method <> 'buy': return False if not procurement.product_id.seller_ids: - cr.execute('update procurement_order set message=%s where id=%s', + cr.execute('update procurement_order set message=%s where id=%s', (_('No supplier defined for this product !'), procurement.id)) return False partner = procurement.product_id.seller_id #Taken Main Supplier of Product of Procurement. @@ -293,7 +298,7 @@ class procurement_order(osv.osv): return False address_id = partner_obj.address_get(cr, uid, [partner.id], ['delivery'])['delivery'] if not address_id: - cr.execute('update procurement_order set message=%s where id=%s', + cr.execute('update procurement_order set message=%s where id=%s', (_('No address defined for the supplier'), procurement.id)) return False return True @@ -314,7 +319,7 @@ class procurement_order(osv.osv): move_obj = self.pool.get('stock.move') for procurement in self.browse(cr, uid, ids): if procurement.product_qty <= 0.00: - raise osv.except_osv(_('Data Insufficient !'), + raise osv.except_osv(_('Data Insufficient !'), _('Please check the Quantity in Procurement Order(s), it should not be less than 1!')) if procurement.product_id.type in ('product', 'consu'): if not procurement.move_id: @@ -342,7 +347,7 @@ class procurement_order(osv.osv): """ Changes procurement state to Running and writes message. @return: True """ - self.write(cr, uid, ids, {'state': 'running', + self.write(cr, uid, ids, {'state': 'running', 'message': _('from stock: products assigned.')}) return True @@ -365,8 +370,8 @@ class procurement_order(osv.osv): ok = ok and self.pool.get('stock.move').action_assign(cr, uid, [id]) cr.execute('select count(id) from stock_warehouse_orderpoint where product_id=%s', (procurement.product_id.id,)) if not cr.fetchone()[0]: - cr.execute('update procurement_order set message=%s where id=%s', - (_('Not enough stock and no minimum orderpoint rule defined.'), + cr.execute('update procurement_order set message=%s where id=%s', + (_('Not enough stock and no minimum orderpoint rule defined.'), procurement.id)) message = _("Procurement '%s' is in exception: not enough stock.") % \ (procurement.name,) @@ -479,7 +484,7 @@ class StockPicking(osv.osv): wf_service.trg_validate(user, 'procurement.order', procurement.id, 'button_check', cursor) return res - + StockPicking() class stock_warehouse_orderpoint(osv.osv): @@ -517,7 +522,7 @@ class stock_warehouse_orderpoint(osv.osv): 'company_id': lambda self, cr, uid, c: self.pool.get('res.company')._company_default_get(cr, uid, 'stock.warehouse.orderpoint', context=c) } _sql_constraints = [ - ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', + ('qty_multiple_check', 'CHECK( qty_multiple > 0 )', _('Qty Multiple must be greater than zero.')), ] @@ -531,7 +536,7 @@ class stock_warehouse_orderpoint(osv.osv): v = {'location_id': w.lot_stock_id.id} return {'value': v} return {} - + def onchange_product_id(self, cr, uid, ids, product_id, context={}): """ Finds UoM for changed product. @param product_id: Changed id of product. @@ -542,7 +547,7 @@ class stock_warehouse_orderpoint(osv.osv): v = {'product_uom': prod.uom_id.id} return {'value': v} return {} - + def copy(self, cr, uid, id, default=None,context={}): if not default: default = {} @@ -550,6 +555,6 @@ class stock_warehouse_orderpoint(osv.osv): 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.orderpoint') or '', }) return super(stock_warehouse_orderpoint, self).copy(cr, uid, id, default, context) - + stock_warehouse_orderpoint() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: