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

is there a way to add an event handler which handles an onchange event on input text. I need to put constraint on the invoice line where the user shouldn't fill a quantity greater than the value in the text box.

10x

<field name="quantity" event="onchange(this)"/>

onchange(){
console.log..
}
Ảnh đại diện
Huỷ bỏ

Hi Salim,

You can achieve the same from python code as follows. If you already knows it and looking for js please neglect it.

@api.constrains('field_id_of_quantity')

def check_quantity(self):

if self.field_id_of_quantity > self.check_field:

raise ValidationError(_('Quantity must not be greater'))

Tác giả

Dear Niyas, thank you and the api.constrains works, but in my case I prefer to validate the quantity in place because the @contrains will do it after clicking button action of the Wizard. Note that the @api.onchange failed to read the original data of the Wizard (I have a tree: product lines), that's why I'm looking for other solution.

Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 7 22
12291
0
thg 8 20
3058
0
thg 1 20
3782
1
thg 8 19
4284
0
thg 2 18
3356