~camptocamp/openerp-rma/7.0-crm_claim_rma-fix-lp1317045_rde

« back to all changes in this revision

Viewing changes to crm_rma_advance_location/wizard/claim_make_picking.py

  • Committer: Joel Grand-Guillaume
  • Date: 2013-11-14 10:07:54 UTC
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: joel.grandguillaume@camptocamp.com-20131114100754-9vb3p3q2i8m2k9ya
[IMP] Split the mass return in a new module
[IMP] Split the new location added on WH in a new module for advance location management
[IMP] Clean the wizards code in crm_claim_rma
[IMP]move wizard in the new module and adapt the view and buttons

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#########################################################################
 
3
#                                                                       #
 
4
#                                                                       #
 
5
#########################################################################
 
6
#                                                                       #
 
7
# crm_claim_rma for OpenERP                                             #
 
8
# Copyright (C) 2009-2012  Akretion, Emmanuel Samyn,                    #
 
9
#       Benoît GUILLOT <benoit.guillot@akretion.com>                    #
 
10
#This program is free software: you can redistribute it and/or modify   #
 
11
#it under the terms of the GNU General Public License as published by   #
 
12
#the Free Software Foundation, either version 3 of the License, or      #
 
13
#(at your option) any later version.                                    #
 
14
#                                                                       #
 
15
#This program is distributed in the hope that it will be useful,        #
 
16
#but WITHOUT ANY WARRANTY; without even the implied warranty of         #
 
17
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
 
18
#GNU General Public License for more details.                           #
 
19
#                                                                       #
 
20
#You should have received a copy of the GNU General Public License      #
 
21
#along with this program.  If not, see <http://www.gnu.org/licenses/>.  #
 
22
#########################################################################
 
23
from openerp.osv import fields, orm, osv
 
24
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
 
25
from openerp import netsvc
 
26
from openerp.tools.translate import _
 
27
import time
 
28
 
 
29
 
 
30
class claim_make_picking(orm.TransientModel):
 
31
 
 
32
    _inherit = 'claim_make_picking.wizard'
 
33
 
 
34
    # Get default destination location
 
35
    def _get_dest_loc(self, cr, uid, context):
 
36
        res = super(claim_make_picking, self)._get_dest_loc(cr, uid, 
 
37
            context=context)
 
38
        if context is None: context = {}
 
39
        warehouse_obj = self.pool.get('stock.warehouse')
 
40
        warehouse_id = context.get('warehouse_id')
 
41
        if context.get('picking_type') == 'in':
 
42
            loc_id = warehouse_obj.read(cr, uid, 
 
43
                warehouse_id,
 
44
                ['lot_rma_id'],
 
45
                context=context)['lot_rma_id'][0]
 
46
        elif context.get('picking_type') == 'loss':
 
47
            loc_id = warehouse_obj.read(cr, uid,
 
48
                warehouse_id,
 
49
                ['lot_carrier_loss_id'],
 
50
                context=context)['lot_carrier_loss_id'][0]
 
51
        return loc_id
 
52
 
 
53
    _defaults = {
 
54
        'claim_line_dest_location': _get_dest_loc,
 
55
    }
 
56