~unifield-team/unifield-wm/us-927

« back to all changes in this revision

Viewing changes to msf_outgoing/msf_outgoing.py

  • Committer: matthieu.choplin at msf
  • Date: 2012-08-17 14:50:02 UTC
  • mto: This revision was merged to the branch mainline in revision 1116.
  • Revision ID: matthieu.choplin@geneva.msf.org-20120817145002-kuhewnsw7njvjapd
uf-1346: hide the delete button when the doc are not in draft state and remove the method allow_cancel of picking because the method was already done by PMA. The delete button is now a button of type 'object' for the modified doc.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1142
1142
        '''
1143
1143
        unlink test for draft
1144
1144
        '''
1145
 
        datas = self.read(cr, uid, ids, ['state'], context=context)
 
1145
        datas = self.read(cr, uid, ids, ['state','type','subtype'], context=context)
1146
1146
        if [data for data in datas if data['state'] != 'draft']:
1147
1147
            raise osv.except_osv(_('Warning !'), _('Only draft picking tickets can be deleted.'))
1148
 
        data = self.has_picking_ticket_in_progress(cr, uid, ids, context=context)
1149
 
        if [x for x in data.values() if x]:
1150
 
            raise osv.except_osv(_('Warning !'), _('Some Picking Tickets are in progress. Return products to stock from ppl and shipment and try again.'))
 
1148
        ids_picking_draft = [data['id'] for data in datas if data['subtype'] == 'picking' and data['type'] == 'out' and data['state'] == 'draft']
 
1149
        if ids_picking_draft:
 
1150
            data = self.has_picking_ticket_in_progress(cr, uid, ids, context=context)
 
1151
            if [x for x in data.values() if x]:
 
1152
                raise osv.except_osv(_('Warning !'), _('Some Picking Tickets are in progress. Return products to stock from ppl and shipment and try again.'))
1151
1153
        
1152
1154
        return super(stock_picking, self).unlink(cr, uid, ids, context=context)
1153
1155
   
1266
1268
            # by default, nothing is in progress
1267
1269
            res[obj.id] = False
1268
1270
            # treat only draft picking
1269
 
            assert obj.subtype == 'picking' and obj.state == 'draft', 'the validate function should only be called on draft picking ticket objects'
 
1271
            assert obj.subtype in 'picking' and obj.state == 'draft', 'the validate function should only be called on draft picking ticket objects'
1270
1272
            for picking in obj.backorder_ids:
1271
1273
                # take care, is_completed returns a dictionary
1272
1274
                if not picking.is_completed()[picking.id]: