Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
10574 Lượt xem

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'})
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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'})
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hii,

 i dont know which odoo version you will use here is example to show error pop up box in odoo verison 8

from openerp.osv import osv

from openerp.tools.translate import _


class YourModel(osv.osv):

    _name = 'your.model'  # Replace with your actual model


    def test_error(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!'), _('This document is already invoiced.'))

        return self.write(cr, uid, ids, {'state': 'draft'})

i hope it is use full

Ảnh đại diện
Huỷ bỏ

Why are you answering questions from 11 years ago? I doubt that hellequin is still waiting for another answer.

any problem if i give the answer

Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 15
4476
0
thg 3 15
3644
1
thg 3 15
4069
1
thg 4 23
3875
0
thg 3 15
5033