1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
23 from osv import fields,osv
28 class stock_location_path(osv.osv):
29 _name = "stock.location.path"
31 'name': fields.char('Operation', size=64),
32 'product_id' : fields.many2one('product.product', 'Products', ondelete='cascade', select=1),
33 'location_from_id' : fields.many2one('stock.location', 'Source Location', ondelete='cascade', select=1),
34 'location_dest_id' : fields.many2one('stock.location', 'Destination Location', ondelete='cascade', select=1),
35 'delay': fields.integer('Delay (days)', help="Number of days to do this transition"),
36 'auto': fields.selection(
37 [('auto','Automatic Move'), ('manual','Manual Operation'),('transparent','Automatic No Step Added')],
39 required=True, select=1,
40 help="This is used to define paths the product has to follow within the location tree.\n" \
41 "The 'Automatic Move' value will create a stock move after the current one that will be "\
42 "validated automatically. With 'Manual Operation', the stock move has to be validated "\
43 "by a worker. With 'Automatic No Step Added', the location is replaced in the original move."
47 'auto': lambda *arg: 'auto',
48 'delay': lambda *arg: 1
52 class product_product(osv.osv):
53 _inherit = 'product.product'
55 'path_ids': fields.one2many('stock.location.path', 'product_id',
57 help="These rules set the right path of the product in the "\
58 "whole location tree.")
62 class stock_location(osv.osv):
63 _inherit = 'stock.location'
64 def chained_location_get(self, cr, uid, location, partner=None, product=None, context={}):
66 for path in product.path_ids:
67 if path.location_from_id.id == location.id:
68 return path.location_dest_id, path.auto, path.delay
69 return super(stock_location, self).chained_location_get(cr, uid, location, partner, product, context)