1
# -*- coding: utf-8 -*-
2
##############################################################################
4
# OpenERP, Open Source Management Solution
5
# Copyright (C) 2004-2011 Pexego (<www.pexego.es>). All Rights Reserved
6
# $Omar Castiñeira Saavedra$
8
# This program is free software: you can redistribute it and/or modify
9
# it under the terms of the GNU General Public License as published by
10
# the Free Software Foundation, either version 3 of the License, or
11
# (at your option) any later version.
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
# GNU General Public License for more details.
18
# You should have received a copy of the GNU General Public License
19
# along with this program. If not, see <http://www.gnu.org/licenses/>.
21
##############################################################################
24
from tools.translate import _
26
class action_traceability(osv.osv_memory):
28
This class defines a function action_traceability for wizard
31
_inherit = "action.traceability"
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
45
type1 = context['type'] or 'move_history_ids2'
46
field = context['field'] or 'tracking_id'
47
if field == 'prodlot_id':
48
model = "valid.stock.moves"
52
obj = self.pool.get(model)
53
ids = obj.search(cr, uid, [(field, 'in',lot_id)])
54
cr.execute("""select valid_stock_moves.id from valid_stock_moves inner join stock_production_lot
55
on valid_stock_moves.prodlot_id = stock_production_lot.id where valid_stock_moves.id in %s and
56
(valid_stock_moves.id not in (select child_id from stock_move_history_ids) or
57
(is_mix = True and prodlot_id not in (select distinct prodlot_id from valid_stock_moves AS sm
58
inner join stock_move_history_ids on sm.id = parent_id
59
where child_id in (valid_stock_moves.id))) or production_id is not null)""", (tuple(ids),))
62
for (parent_id,) in cr.fetchall():
65
cr.execute('select id from ir_ui_view where model=%s and field_parent=%s and type=%s', (model, type1, 'tree'))
66
view_id = cr.fetchone()[0]
68
'domain': "[('id','in',["+','.join(map(str, ids))+"])]",
69
'name': ((type1=='move_history_ids2') and _('Upstream Traceability')) or _('Downstream Traceability'),
73
'field_parent': type1,
74
'view_id': (view_id,'View'),
75
'type': 'ir.actions.act_window',
b'\\ No newline at end of file'