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

« back to all changes in this revision

Viewing changes to delivery_mechanism/wizard/enter_reason.py

  • Committer: jf
  • Date: 2014-05-28 13:16:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2187.
  • Revision ID: jfb@tempo-consulting.fr-20140528131631-13qcl8f5h390rmtu
UFTP-244 [FIX] In sync context, do not auto create the link between account.account and account.destination.link for default destination
this link is created by a dedicated sync rule

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
            ids = [ids]
45
45
        # objects
46
46
        picking_obj = self.pool.get('stock.picking')
 
47
        purchase_obj = self.pool.get('purchase.order')
 
48
        pol_obj = self.pool.get('purchase.order.line')
47
49
        # workflow
48
50
        wf_service = netsvc.LocalService("workflow")
49
51
        # depending on the button clicked the behavior is different
61
63
        values = {'change_reason': change_reason}
62
64
        # update the object
63
65
        for obj in picking_obj.browse(cr, uid, picking_ids, context=context):
 
66
            # purchase order line to re-source
 
67
            pol_ids = []
64
68
            # set the reason
65
69
            obj.write({'change_reason': change_reason}, context=context)
66
 
            # cancel the IN
67
 
            wf_service.trg_validate(uid, 'stock.picking', obj.id, 'button_cancel', cr)
 
70
 
 
71
            for move in obj.move_lines:
 
72
                pol_ids.append(move.purchase_line_id.id)
 
73
 
68
74
            # if full cancel (no resource), we updated corresponding out and correct po state
69
75
            if cancel_type == 'update_out':
70
76
                picking_obj.cancel_and_update_out(cr, uid, [obj.id], context=context)
71
 
                
 
77
            else:
 
78
                pol_obj.write(cr, uid, pol_ids, {'has_to_be_resourced': True}, context=context)
 
79
                pol_obj.cancel_sol(cr, uid, pol_ids, context=context)
 
80
            
 
81
            # cancel the IN
 
82
            wf_service.trg_validate(uid, 'stock.picking', obj.id, 'button_cancel', cr)
 
83
 
 
84
            # correct the corresponding po manually if exists - should be in shipping exception
 
85
            if obj.purchase_id:
 
86
                wf_service.trg_validate(uid, 'purchase.order', obj.purchase_id.id, 'picking_ok', cr)
 
87
                purchase_obj.log(cr, uid, obj.purchase_id.id, _('The Purchase Order %s is %s%% received')%(obj.purchase_id.name, round(obj.purchase_id.shipped_rate,2)))
 
88
 
72
89
        return {'type': 'ir.actions.act_window_close'}
73
90
    
74
91
enter_reason()