(self, cr, uid, ids, context=None)
return super(account_invoice, self).unlink(cr, uid, ids, context=context)
Overwrite unlink method of account invoice to send a trigger to the sale workflow upon invoice deletion
Overwrite unlink method of account invoice to send a trigger to the sale workflow upon invoice deletion
Overwrite unlink method of account invoice to send a trigger to the sale workflow upon invoice deletion
def unlink(self, cr, uid, ids, context=None):
        """ Overwrite unlink method of account invoice to send a trigger to the sale workflow upon invoice deletion """
        invoice_ids = self.search(cr, uid, [('id', 'in', ids), ('state', 'in', ['draft', 'cancel'])], context=context)
        #if we can't cancel all invoices, do nothing
        if len(invoice_ids) == len(ids):
            #Cancel invoice(s) first before deleting them so that if any sale order is associated with them
            #it will trigger the workflow to put the sale order in an 'invoice exception' state
            for id in ids:
                workflow.trg_validate(uid, 'account.invoice', id, 'invoice_cancel', cr)
        return super(account_invoice, self).unlink(cr, uid, ids, context=context)
def unlink ( self , cr , uid , ids , context = None ) : invoice_ids = self . search ( cr , uid , [ ( 'id' , 'in' , ids ) , ( 'state' , 'in' , [ 'draft' , 'cancel' ] ) ] , context = context ) #if we can't cancel all invoices, do nothing if len ( invoice_ids ) == len ( ids ) : #Cancel invoice(s) first before deleting them so that if any sale order is associated with them #it will trigger the workflow to put the sale order in an 'invoice exception' state for id in ids : workflow . trg_validate ( uid , 'account.invoice' , id , 'invoice_cancel' , cr ) return super ( account_invoice , self ) . unlink ( cr , uid , ids , context = context )