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

« back to all changes in this revision

Viewing changes to crm_claim_rma/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:
51
51
        #TODO use custom states to show buttons of this wizard or not instead of raise an error
52
52
        if context is None: context = {}
53
53
        line_obj = self.pool.get('claim.line')
54
 
        if context.get('picking_type') in ['in', 'loss']:
 
54
        if context.get('picking_type') == 'out':
 
55
            move_field = 'move_out_id'
 
56
        else:
55
57
            move_field = 'move_in_id'
56
 
        elif context.get('picking_type') == 'out':
57
 
            move_field = 'move_out_id'
58
58
        good_lines = []
59
59
        line_ids =  line_obj.search(cr, uid, 
60
60
            [('claim_id', '=', context['active_id'])], context=context)
77
77
                warehouse_id, 
78
78
                ['lot_stock_id'],
79
79
                context=context)['lot_stock_id'][0]
80
 
        elif (context.get('picking_type') in ['in', 'loss'] 
81
 
            and context.get('partner_id')):
 
80
        elif context.get('partner_id'):
82
81
            loc_id = self.pool.get('res.partner').read(cr, uid, 
83
82
                context['partner_id'],
84
83
                ['property_stock_customer'],
90
89
        if context is None: context = {}
91
90
        warehouse_obj = self.pool.get('stock.warehouse')
92
91
        warehouse_id = context.get('warehouse_id')
93
 
        if context.get('picking_type') == 'out':
 
92
        loc_id = False
 
93
        if context.get('picking_type') == 'out' and context.get('partner_id'):
94
94
            loc_id = self.pool.get('res.partner').read(cr, uid, 
95
95
                context.get('partner_id'),
96
96
                ['property_stock_customer'],
97
97
                context=context)['property_stock_customer'][0]
98
 
        elif context.get('picking_type') == 'in':
 
98
        elif context.get('picking_type') == 'in' and context.get('partner_id'):
99
99
            loc_id = warehouse_obj.read(cr, uid, 
100
100
                warehouse_id,
101
 
                ['lot_rma_id'],
102
 
                context=context)['lot_rma_id'][0]
103
 
        elif context.get('picking_type') == 'loss':
104
 
            loc_id = warehouse_obj.read(cr, uid,
105
 
                warehouse_id,
106
 
                ['lot_carrier_loss_id'],
107
 
                context=context)['lot_carrier_loss_id'][0]
 
101
                ['lot_stock_id'],
 
102
                context=context)['lot_stock_id'][0]
 
103
            # Add the case of return to supplier !
108
104
        return loc_id
109
105
 
110
106
    _defaults = {
121
117
        picking_obj = self.pool.get('stock.picking')
122
118
        if context is None: context = {}
123
119
        view_obj = self.pool.get('ir.ui.view')
124
 
        if context.get('picking_type') in ['in', 'loss']:
125
 
            p_type = 'in'
126
 
            view_xml_id = 'stock_picking_form'
127
 
            view_name = 'stock.picking.form'
128
 
            write_field = 'move_in_id'
129
 
            if context.get('picking_type') == 'in':
130
 
                note = 'RMA picking in'
131
 
                name = 'Customer picking in'
132
 
            elif context.get('picking_type') == 'loss':
133
 
                name = 'Customer product loss'
134
 
                note = 'RMA product loss'
135
 
        elif context.get('picking_type') == 'out':
 
120
        if context.get('picking_type') == 'out':
136
121
            p_type = 'out'
137
122
            write_field = 'move_out_id'
138
123
            note = 'RMA picking out'
139
124
            name = 'Customer picking out'
140
125
            view_xml_id = 'stock_picking_form'
141
126
            view_name = 'stock.picking.form'
 
127
        else:
 
128
            p_type = 'in'
 
129
            view_xml_id = 'stock_picking_form'
 
130
            view_name = 'stock.picking.form'
 
131
            write_field = 'move_in_id'
 
132
            if context.get('picking_type'):
 
133
                note = 'RMA picking ' + str(context.get('picking_type'))
142
134
        view_id = view_obj.search(cr, uid, [
143
135
                                            ('xml_id', '=', view_xml_id),
144
136
                                            ('model', '=', 'stock.picking'),