~unifield-team/unifield-wm/us-826

« back to all changes in this revision

Viewing changes to stock_move_tracking/stock.py

  • Committer: jf
  • Date: 2011-03-23 13:23:55 UTC
  • Revision ID: jf@tempo4-20110323132355-agyf1soy7m5ewatr
Initial Import

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
#    OpenERP, Open Source Management Solution
5
 
#    Copyright (C) 2011 TeMPO Consulting, MSF 
6
 
#
7
 
#    This program is free software: you can redistribute it and/or modify
8
 
#    it under the terms of the GNU Affero General Public License as
9
 
#    published by the Free Software Foundation, either version 3 of the
10
 
#    License, or (at your option) any later version.
11
 
#
12
 
#    This program is distributed in the hope that it will be useful,
13
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
#    GNU Affero General Public License for more details.
16
 
#
17
 
#    You should have received a copy of the GNU Affero General Public License
18
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 
#
20
 
##############################################################################
21
 
 
22
 
from osv import osv, fields
23
 
 
24
 
class stock_move(osv.osv):
25
 
    _name = 'stock.move'
26
 
    _inherit = 'stock.move'
27
 
    
28
 
    def _get_picking_ids(self, cr, uid, ids, context={}):
29
 
        res = []
30
 
        picking_ids = self.pool.get('stock.picking').browse(cr, uid, ids, context=context)
31
 
        for pick in picking_ids:
32
 
            res += self.pool.get('stock.move').search(cr, uid, [('picking_id', '=', pick.id)])
33
 
 
34
 
        return res
35
 
    
36
 
    def _get_lot_ids(self, cr, uid, ids, context={}):
37
 
        res = []
38
 
        lot_ids = self.pool.get('stock.production.lot').browse(cr, uid, ids, context=context)
39
 
        for lot in lot_ids:
40
 
            res += self.pool.get('stock.move').search(cr, uid, [('prodlot_id', '=', lot.id)])
41
 
        
42
 
        return res
43
 
    
44
 
    _columns = {
45
 
        'type': fields.related('picking_id', 'type', string='Type', type='selection', 
46
 
                               selection=[('out', 'Sending Goods'), ('in', 'Getting Goods'), ('internal', 'Internal')], readonly=True, 
47
 
                               store={
48
 
                                'stock.picking': (_get_picking_ids, ['type'], 20),
49
 
                                'stock.move': (lambda self, cr, uid, ids, c={}: ids, ['picking_id'], 20),
50
 
                                }
51
 
                               
52
 
                               ),
53
 
        'expired_date': fields.related('prodlot_id', 'life_date', string='Expired Date', type='datetime', readonly=True, 
54
 
                                        store={
55
 
                                            'stock.production.lot': (_get_lot_ids, ['life_date'], 20),
56
 
                                            'stock.move': (lambda self, cr, uid, ids, c={}: ids, ['prodlot_id'], 20), 
57
 
                                            }
58
 
                                        ),
59
 
    }
60
 
    
61
 
stock_move()
62
 
 
63
 
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: