1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2012 MSF, TeMPO Consulting, Smile
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 _
24
class stock_location(osv.osv):
26
override stock location to add:
27
- cross_docking_location_ok (checkbox - boolean)
29
_inherit = 'stock.location'
32
'cross_docking_location_ok': fields.boolean(string='Cross Docking Location', readonly=True, help="There is only one Cross Docking Location"),
35
def get_cross_docking_location(self, cr, uid, context=None):
36
ids = self.search(cr, uid, [('cross_docking_location_ok', '=', True)])
38
raise osv.except_osv(_('Error'), _('You must have a "Cross Docking Location".'))
41
def unlink(self, cr, uid, ids, context=None):
42
if isinstance(ids, (int, long)):
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)