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

I have a selection field


award = fields.Selection([
('awarded'
, 'Adjudicado'),
('not_awarded', 'No Adjudicado'),
],string="Adjudicacion", required="True")

And I have this function


def button_confirm(self):
res = super(PurchaseOrder,self).button_confirm()
if
res.award == res.not_awarded:
raise ValidationError("No puedes confirmar este pedido")

What I want to do is that when the user makes a budget request in the purchase order, if the user has "not_awarded" selected and then confirms the order, I throw an error that he has to have "awarded" selected


In the end I have this error.

AttributeError: 'bool' object has no attribute 'award'


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

Try the below code:

def button_confirm(self):
res = super(PurchaseOrder, self).button_confirm()
for order in self:
if order.award == "not_awarded":
raise ValidationError("No puedes confirmar este pedido")
Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
0
thg 3 25
1550
4
thg 4 24
174427
0
thg 12 23
2306
5
thg 7 25
228678
1
thg 12 22
3450