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

« back to all changes in this revision

Viewing changes to specific_rules/wizard/stock_partial_picking.py

  • Committer: chloups208
  • Date: 2011-08-25 12:15:38 UTC
  • mto: This revision was merged to the branch mainline in revision 264.
  • Revision ID: chloups208@chloups208-laptop-20110825121538-bsiqzhugwziwwtqr
[UF-372]warehouse wizards

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
# -*- coding: utf-8 -*-
 
3
##############################################################################
 
4
#
 
5
#    OpenERP, Open Source Management Solution
 
6
#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
 
7
#
 
8
#    This program is free software: you can redistribute it and/or modify
 
9
#    it under the terms of the GNU Affero General Public License as
 
10
#    published by the Free Software Foundation, either version 3 of the
 
11
#    License, or (at your option) any later version.
 
12
#
 
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 Affero General Public License for more details.
 
17
#
 
18
#    You should have received a copy of the GNU Affero General Public License
 
19
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
20
#
 
21
##############################################################################
 
22
 
 
23
from osv import fields, osv
 
24
from tools.translate import _
 
25
import time
 
26
 
 
27
class stock_partial_picking(osv.osv_memory):
 
28
    '''
 
29
    add message
 
30
    '''
 
31
    _inherit = "stock.partial.picking"
 
32
 
 
33
    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
 
34
        '''
 
35
        add message
 
36
        '''
 
37
        if context is None:
 
38
            context = {}
 
39
        
 
40
        result = super(stock_partial_picking, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu)
 
41
 
 
42
        pick_obj = self.pool.get('stock.picking')
 
43
        picking_ids = context.get('active_ids', False)
 
44
        message_in = '<label string="You receive %s products, please refer to the appropriate procedure." colspan="4" />'
 
45
        message_out = '<label string="You ship %s products, please refer to the appropriate procedure and ensure that the mean of transport is appropriate." colspan="4" />'
 
46
 
 
47
        if not picking_ids:
 
48
            # not called through an action (e.g. buildbot), return the default.
 
49
            return result
 
50
        
 
51
        type = False
 
52
        contains_kc = False
 
53
        contains_dg = False
 
54
        
 
55
        for pick in pick_obj.browse(cr, uid, picking_ids, context=context):
 
56
            type = pick.type
 
57
            for m in pick.move_lines:
 
58
                if m.product_id.heat_sensitive_item:
 
59
                    contains_kc = True
 
60
                if m.product_id.dangerous_goods:
 
61
                    contains_dg = True
 
62
            
 
63
        if contains_kc and contains_dg:
 
64
            fill = 'heat sensitive and dangerous goods'
 
65
        elif contains_kc:
 
66
            fill = 'heat sensitive'
 
67
        elif contains_dg:
 
68
            fill = 'dangerous goods'
 
69
        else:
 
70
            fill = ''
 
71
            
 
72
        message = message_out
 
73
        if type == 'in':
 
74
            message = message_in
 
75
        
 
76
        if fill:
 
77
            message = message%fill
 
78
        else:
 
79
            message = ''
 
80
 
 
81
        # add field in arch
 
82
        arch = result['arch']
 
83
        l = arch.split('<field name="date" invisible="1"/>')
 
84
        arch = l[0] + '<field name="date" invisible="1"/>' + message + l[1]
 
85
        result['arch'] = arch
 
86
 
 
87
        return result
 
88
 
 
89
stock_partial_picking()