[imp] set field tracking serial to production lot
[odoo/odoo.git] / addons / stock / wizard / stock_traceability.py
1 # -*- coding: utf-8 -*-
2 ##############################################################################
3 #
4 #    OpenERP, Open Source Management Solution
5 #    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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 fields, osv
23 from tools.translate import _
24
25 class action_traceability(osv.osv_memory):
26     """
27     This class defines a function action_traceability for wizard
28
29     """
30     _name = "action.traceability"
31     _description = "Action traceability "
32      
33     def action_traceability(self, cr, uid, ids, context=None):
34         """ It traces the information of a product
35         @param self: The object pointer.
36         @param cr: A database cursor
37         @param uid: ID of the user currently logged in
38         @param ids: List of IDs selected
39         @param context: A standard dictionary
40         @return: A dictionary of values
41         """
42         lot_id = ids
43         if context is None:
44             context = {}
45         type1 = context['type'] or 'move_history_ids2'
46         field = context['field'] or 'tracking_id'
47         obj = self.pool.get('stock.move')
48         ids = obj.search(cr, uid, [(field, 'in',lot_id)])
49         cr.execute('select id from ir_ui_view where model=%s and field_parent=%s and type=%s', ('stock.move', type1, 'tree'))
50         view_id = cr.fetchone()[0]
51         value = {
52             'domain': "[('id','in',["+','.join(map(str, ids))+"])]",
53             'name': ((type1=='move_history_ids2') and _('Upstream Traceability')) or _('Downstream Traceability'),
54             'view_type': 'tree',
55             'view_mode': 'tree',
56             'res_model': 'stock.move',
57             'field_parent': type1,
58             'view_id': (view_id,'View'),
59             'type': 'ir.actions.act_window',
60             'nodestroy':True,
61         }
62         return value
63
64 action_traceability()
65
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
67