1 # -*- coding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
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.
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.
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/>.
20 ##############################################################################
29 def action_traceability(type='move_history_ids', field='tracking_id'):
30 def open_tab(self, cr, uid, data, context):
31 obj = pooler.get_pool(cr.dbname).get('stock.move')
32 ids = obj.search(cr, uid, [(field, 'in', data['ids'])])
33 cr.execute('select id from ir_ui_view where model=%s and field_parent=%s and type=%s', ('stock.move', type, 'tree'))
34 view_id = cr.fetchone()[0]
36 'domain': "[('id','in',["+','.join(map(str, ids))+"])]",
37 'name': ((type=='move_history_ids') and 'Upstream Traceability') or 'Downstream Traceability',
39 'res_model': 'stock.move',
41 'view_id': (view_id,'View'),
42 'type': 'ir.actions.act_window'
47 class wiz_journal(wizard.interface):
51 'result': {'type': 'action', 'action': action_traceability('move_history_ids2'), 'state':'end'}
54 wiz_journal('stock.traceability.downstream')
56 class wiz_journal2(wizard.interface):
60 'result': {'type': 'action', 'action': action_traceability(), 'state':'end'}
63 wiz_journal2('stock.traceability.upstream')
65 class wiz_journal3(wizard.interface):
69 'result': {'type': 'action', 'action': action_traceability(field='prodlot_id'), 'state':'end'}
72 wiz_journal3('stock.traceability.lot.upstream')
74 class wiz_journal4(wizard.interface):
78 'result': {'type': 'action', 'action': action_traceability('move_history_ids2', 'prodlot_id'), 'state':'end'}
81 wiz_journal4('stock.traceability.lot.downstream')
84 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: