~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to stock_inventory_delete/stock.py

  • Committer: Julio Serna
  • Date: 2012-08-15 00:12:31 UTC
  • mto: This revision was merged to the branch mainline in revision 400.
  • Revision ID: julio@vauxoo.com-20120815001231-qzqdor142ggeajub
[INIT] added module purchase_order_cancel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
###########################################################################
 
3
#    Module Writen to OpenERP, Open Source Management Solution
 
4
#
 
5
#    Copyright (c) 2010 Vauxoo - http://www.vauxoo.com/
 
6
#    All Rights Reserved.
 
7
#    info Vauxoo (info@vauxoo.com)
 
8
############################################################################
 
9
#    Coded by: Luis Torres (luis_t@vauxoo.com)
 
10
############################################################################
 
11
#
 
12
#    This program is free software: you can redistribute it and/or modify
 
13
#    it under the terms of the GNU Affero General Public License as
 
14
#    published by the Free Software Foundation, either version 3 of the
 
15
#    License, or (at your option) any later version.
 
16
#
 
17
#    This program is distributed in the hope that it will be useful,
 
18
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
#    GNU Affero General Public License for more details.
 
21
#
 
22
#    You should have received a copy of the GNU Affero General Public License
 
23
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
24
#
 
25
##############################################################################
 
26
from osv import osv, fields
 
27
from tools.translate import _
 
28
 
 
29
class stock_picking(osv.osv):
 
30
    _inherit = 'stock.inventory'
 
31
    
 
32
    def unlink(self, cr, uid, ids, context=None):
 
33
        stock_inventory = self.read(cr, uid, ids, ['state'], context=context)
 
34
        unlink_ids = []
 
35
        for s in stock_inventory:
 
36
            if s['state'] in ['draft']:
 
37
                unlink_ids.append(s['id'])
 
38
            else:
 
39
                raise osv.except_osv(_('Invalid action !'), _('Stocks can be removed only in draft.'))
 
40
 
 
41
        return osv.osv.unlink(self, cr, uid, unlink_ids, context=context)