1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2012 MSF, TeMPO Consulting
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.
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.
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/>.
19
##############################################################################
21
from osv import osv, fields
22
from tools.translate import _
25
class stock_location(osv.osv):
27
override stock location to add:
28
- cross_docking_location_ok (checkbox - boolean)
30
_inherit = 'stock.location'
33
'cross_docking_location_ok': fields.boolean(string='Cross Docking Location', readonly=True, help="There is only one Cross Docking Location"),
36
def get_cross_docking_location(self, cr, uid, context=None):
37
ids = self.search(cr, uid, [('cross_docking_location_ok', '=', True)])
39
raise osv.except_osv(_('Error'), _('You must have a "Cross Docking Location".'))
42
def unlink(self, cr, uid, ids, context=None):
43
if isinstance(ids, (int, long)):
45
cross_docking_location = self.search(cr, uid, [('cross_docking_location_ok', '=', True), ('id', 'in', ids)], context=context)
46
if cross_docking_location:
47
raise osv.except_osv(_('Warning !'), _('You cannot delete the cross docking location.'))
48
return super(stock_location, self).unlink(cr, uid, ids, context)