~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to msf_cross_docking/stock_location.py

[MOVE] funding_pool module to analytic_distribution module

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    Copyright (C) 2012 MSF, TeMPO Consulting, Smile
5
 
#
6
 
#    This program is free software: you can redistribute it and/or modify
7
 
#    it under the terms of the GNU Affero General Public License as
8
 
#    published by the Free Software Foundation, either version 3 of the
9
 
#    License, or (at your option) any later version.
10
 
#
11
 
#    This program is distributed in the hope that it will be useful,
12
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
#    GNU Affero General Public License for more details.
15
 
#
16
 
#    You should have received a copy of the GNU Affero General Public License
17
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
#
19
 
##############################################################################
20
 
 
21
 
from osv import osv, fields
22
 
from tools.translate import _
23
 
 
24
 
class stock_location(osv.osv):
25
 
    '''
26
 
    override stock location to add:
27
 
    - cross_docking_location_ok (checkbox - boolean)
28
 
    '''
29
 
    _inherit = 'stock.location'
30
 
    
31
 
    _columns = {
32
 
        'cross_docking_location_ok': fields.boolean(string='Cross Docking Location', readonly=True, help="There is only one Cross Docking Location"),
33
 
    }
34
 
    
35
 
    def get_cross_docking_location(self, cr, uid, context=None):
36
 
        ids = self.search(cr, uid, [('cross_docking_location_ok', '=', True)])
37
 
        if not ids:
38
 
            raise osv.except_osv(_('Error'), _('You must have a "Cross Docking Location".'))
39
 
        return ids[0]
40
 
 
41
 
    def unlink(self, cr, uid, ids, context=None):
42
 
        if isinstance(ids, (int, long)):
43
 
            ids = [ids]
44
 
        cross_docking_location = self.search(cr, uid, [('cross_docking_location_ok', '=', True), ('id', 'in', ids)], context=context)
45
 
        if cross_docking_location:
46
 
            raise osv.except_osv(_('Warning !'), _('You cannot delete the cross docking location.'))
47
 
        return super(stock_location, self).unlink(cr, uid, ids, context)
48
 
 
49
 
stock_location()