This question has been flagged
1 Reply
8899 Views

I try to add a error box on my function button but I do not know how to do it..

I try this :

def testError(self, cr, uid, ids, context=None):
    for line in self.browse(cr, uid, ids, context=context):
        if line.invoiced:
            raise osv.except_osv(_('Invalid Action!'), _('Test.'))
    return self.write(cr, uid, ids, {'state': 'draft'})
Avatar
Discard
Best Answer

Try this. This will show a popup message.

def testError(self, cr, uid, ids, context=None):
    for line in self.browse(cr, uid, ids, context=context):
        if line.invoiced:
            warning = { 'title': 'Warning!', 'message' : 'Invalid action!'}
            return {'warning': warning}
    return self.write(cr, uid, ids, {'state': 'draft'})
Avatar
Discard