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

Hello, I am developing a module in Odoo 8 and I want to display a message when a value field changes. In this case, I want to display a warning message when the pricelist associated with a sale order changes. This is my code:

class sale_order(models.Model):
    _inherit = 'sale.order'

    @api.onchange('pricelist_id')
    def test_change(self):
        return {
        'warning': {
            'title': "test",
            'message': "testing",
            }
        }

I can install the module correctly, but when I change the pricelist selection in sale.order.form, there isn't any warning message. Why?

Thanks!

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I found the solution. The method not works because there is a on_change attribute in the view.xml which calls another method. I override the view, quit the on_change attribute, and then the @api.onchange('pricelist_id') works properly.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
4
thg 12 19
14729
1
thg 3 15
4455
0
thg 4 24
1982
4
thg 11 23
6095
1
thg 10 23
2117