[IMP]stock:put attrs in tree view
[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
24 class action_traceability(osv.osv_memory):
25     """
26     This class defines a function action_traceability for wizard
27
28     """
29     _name = "action.traceability"
30     _description = "Action traceability "
31      
32     def action_traceability(self, cr, uid, ids, context=None):
33         """ It traces the information of a product
34         @param self: The object pointer.
35         @param cr: A database cursor
36         @param uid: ID of the user currently logged in
37         @param ids: List of IDs selected
38         @param context: A standard dictionary
39         @return: A dictionary of values
40         """
41         lot_id = ids
42         if context is None:
43             context = {}
44         type1 = context['type'] or 'move_history_ids2'
45         field = context['field'] or 'tracking_id'
46         obj = self.pool.get('stock.move')
47         ids = obj.search(cr, uid, [(field, 'in',lot_id)])
48         cr.execute('select id from ir_ui_view where model=%s and field_parent=%s and type=%s', ('stock.move', type1, 'tree'))
49         view_id = cr.fetchone()[0]
50         value = {
51             'domain': "[('id','in',["+','.join(map(str, ids))+"])]",
52             'name': ((type1=='move_history_ids2') and 'Upstream Traceability') or 'Downstream Traceability',
53             'view_type': 'tree',
54             'res_model': 'stock.move',
55             'field_parent': type1,
56             'view_id': (view_id,'View'),
57             'type': 'ir.actions.act_window',
58             'nodestroy':True,
59         }
60         return value
61
62 action_traceability()
63
64 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
65