1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# Copyright (C) 2011 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 _
24
class stock_location(osv.osv):
26
override stock location to add:
27
- quarantine location (checkbox - boolean)
28
- destruction location (checkbox - boolean)
29
- location category (selection)
31
_inherit = 'stock.location'
33
def remove_flag(self, flag, list):
35
if we do not remove the flag, we fall into an infinite loop
48
def search_check_quarantine(self, cr, uid, obj, name, args, context=None):
50
modify the query to take the type of stock move into account
52
if type is 'out', quarantine_location must be False
54
move_obj = self.pool.get('stock.move')
55
move_id = context.get('move_id', False)
57
# remove flag avoid infinite loop
58
self.remove_flag('check_quarantine', args)
64
move = move_obj.browse(cr, uid, move_id, context=context)
66
if move.type == 'out':
67
# out -> not from quarantine
68
args.append(('quarantine_location', '=', False))
72
def _get_false(self, cr, uid, ids, field_name, arg, context=None):
74
return false for each id
76
if isinstance(ids,(long, int)):
84
_columns = {'quarantine_location': fields.boolean(string='Quarantine Location'),
85
'destruction_location': fields.boolean(string='Destruction Loction'),
86
'location_category': fields.selection([('stock', 'Stock'),
87
('consumption_unit', 'Consumption Unit'),
88
('transition', 'Transition'),
89
('other', 'Other'),], string='Location Category', required=True),
90
# could be used after discussion with Magali
91
#'check_quarantine': fields.function(_get_false, fnct_search=search_check_quarantine, string='Check Quarantine', type="boolean", readonly=True, method=True),
94
'location_category': 'stock',
100
class procurement_order(osv.osv):
101
_inherit = 'procurement.order'
103
def _do_create_proc_hook(self, cr, uid, ids, context=None, *args, **kwargs):
105
hook to update defaults data
108
values = super(procurement_order, self)._do_create_proc_hook(cr, uid, ids, context=context, *args, **kwargs)
109
# as location, we take the input of the warehouse
110
op = kwargs.get('op', False)
111
assert op, 'missing op'
112
# update location value
113
values.update(location_id=op.warehouse_id.lot_input_id.id)