~unifield-team/unifield-wm/us-903

« back to all changes in this revision

Viewing changes to msf_cross_docking/purchase.py

  • Committer: matthieu.choplin at msf
  • Date: 2012-03-09 13:09:06 UTC
  • mto: This revision was merged to the branch mainline in revision 744.
  • Revision ID: matthieu.choplin@geneva.msf.org-20120309130906-xs0cofbfqx85qboi
uf-842 new folder created for initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
##############################################################################
 
3
#
 
4
#    OpenERP, Open Source Management Solution
 
5
#    Copyright (C) 2011 TeMPO Consulting, MSF
 
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 osv
 
23
from osv import fields
 
24
from tools.translate import _
 
25
 
 
26
class purchase_order(osv.osv):
 
27
    _name = 'purchase.order'
 
28
    _inherit = 'purchase.order'
 
29
 
 
30
    _columns = {
 
31
        'cross_docking_ok': fields.boolean('Cross docking?'),
 
32
        'stock_location_id': fields.many2one('stock.location','Location'),
 
33
    }
 
34
    
 
35
    def onchange_cross_docking_ok(self, cr, uid, ids, cross_docking_ok, context=None):
 
36
        """ Finds location id for changed cross_docking_ok.
 
37
        @param cross_docking_ok: Changed value of cross_docking_ok.
 
38
        @return: Dictionary of values.
 
39
        """
 
40
        if cross_docking_ok:
 
41
            w = self.pool.get('stock.location').search(cr, uid, [('name', '=', 'Cross docking')], context=context)
 
42
            v = {'stock_location_id': w}
 
43
        elif cross_docking_ok == False:
 
44
            v = {'stock_location_id': False}
 
45
        return {'value': v}
 
46
        return {}
 
47
    
 
48
    def test_cross_docking_ok(self, cr, uid, ids):
 
49
        """ Tests whether cross docking is True or False.
 
50
        @return: True or False
 
51
        """
 
52
        for order in self.browse(cr, uid, ids):
 
53
            return order.cross_docking_ok
 
54
 
 
55
#    def _hook_action_picking_create_stock_picking(self, cr, uid, ids, context=None, *args, **kwargs):
 
56
#        '''
 
57
#        modify data for stock move creation
 
58
#        - location_dest_id is set to Cross docking
 
59
#        '''
 
60
#        if context is None:
 
61
#            context = {}
 
62
#        move_values = super(purchase_order, self)._hook_action_picking_create_stock_picking(cr, uid, ids, context=context, *args, **kwargs)
 
63
#        w = self.pool.get('stock.location').search(cr, uid, [('name', '=', 'Cross docking')], context=context)
 
64
#        move_values.update({'location_dest_id': w,})
 
65
#        return move_values
 
66
 
 
67
 
 
68
#    def action_picking_create(self, cr, uid, ids, context=None):
 
69
#        '''
 
70
#        Checks if the the option Cross Docking has been chosen
 
71
#        '''
 
72
#        if context is None:
 
73
#            context = {}
 
74
#        if isinstance(ids, (int, long)):
 
75
#            ids = [ids]
 
76
#        
 
77
#        for order in self.browse(cr, uid, ids, context=context):
 
78
#            if order.cross_docking_ok:
 
79
#                self.
 
80
#            
 
81
#        return super(purchase_order, self).action_picking_create(cr, uid, ids, context=context)
 
82
purchase_order()
 
 
b'\\ No newline at end of file'