~julius-network-solutions/openobject-addons/trunk-bug-wiki-image

« back to all changes in this revision

Viewing changes to stock_location/stock.py

  • Committer: Fabien Pinckaers
  • Date: 2008-09-07 23:24:39 UTC
  • Revision ID: fp@tinyerp.com-20080907232439-bod5fedw3o7w7u47
Improved:
        Sales Management
        Project Manegement
        Stock Management
        Accounting

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
5
#                    Fabien Pinckaers <fp@tiny.Be>
 
6
#
 
7
# WARNING: This program as such is intended to be used by professional
 
8
# programmers who take the whole responsability of assessing all potential
 
9
# consequences resulting from its eventual inadequacies and bugs
 
10
# End users who are looking for a ready-to-use solution with commercial
 
11
# garantees and support are strongly adviced to contract a Free Software
 
12
# Service Company
 
13
#
 
14
# This program is Free Software; you can redistribute it and/or
 
15
# modify it under the terms of the GNU General Public License
 
16
# as published by the Free Software Foundation; either version 2
 
17
# of the License, or (at your option) any later version.
 
18
#
 
19
# This program is distributed in the hope that it will be useful,
 
20
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
21
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
22
# GNU General Public License for more details.
 
23
#
 
24
# You should have received a copy of the GNU General Public License
 
25
# along with this program; if not, write to the Free Software
 
26
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
27
#
 
28
##############################################################################
 
29
 
 
30
from osv import fields,osv
 
31
import tools
 
32
import ir
 
33
import pooler
 
34
 
 
35
class stock_location_path(osv.osv):
 
36
    _name = "stock.location.path"
 
37
    _columns = {
 
38
        'name': fields.char('Operation', size=64),
 
39
        'product_id' : fields.many2one('product.product', 'Products', ondelete='cascade', select=1),
 
40
        'location_from_id' : fields.many2one('stock.location', 'Source Location', ondelete='cascade', select=1),
 
41
        'location_dest_id' : fields.many2one('stock.location', 'Destination Location', ondelete='cascade', select=1),
 
42
        'delay': fields.integer('Delay (days)', help="Number of days to do this transition"),
 
43
        'auto': fields.selection(
 
44
            [('auto','Automatic Move'), ('manual','Manual Operation'),('transparent','Automatic No Step Added')],
 
45
            'Automatic Move',
 
46
            required=True, select=1,
 
47
            help="This is used to define paths the product has to follow within the location tree.\n" \
 
48
                "The 'Automatic Move' value will create a stock move after the current one that will be "\
 
49
                "validated automatically. With 'Manual Operation', the stock move has to be validated "\
 
50
                "by a worker. With 'Automatic No Step Added', the location is replaced in the original move."
 
51
            ),
 
52
    }
 
53
    _defaults = {
 
54
        'auto': lambda *arg: 'auto',
 
55
        'delay': lambda *arg: 1
 
56
    }
 
57
stock_location_path()
 
58
 
 
59
class product_product(osv.osv):
 
60
    _inherit = 'product.product'
 
61
    _columns = {
 
62
        'path_ids': fields.one2many('stock.location.path', 'product_id',
 
63
            'Location Paths',
 
64
            help="These rules set the right path of the product in the "\
 
65
            "whole location tree.")
 
66
    }
 
67
product_product()
 
68
 
 
69
class stock_location(osv.osv):
 
70
    _inherit = 'stock.location'
 
71
    def chained_location_get(self, cr, uid, location, partner=None, product=None, context={}):
 
72
        if product:
 
73
            for path in product.path_ids:
 
74
                if path.location_from_id.id == location.id:
 
75
                    return path.location_dest_id, path.auto, path.delay
 
76
        return super(stock_location, self).chained_location_get(cr, uid, location, partner, product, contex)
 
77
stock_location()