コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
3837 ビュー

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'


アバター
破棄
最善の回答

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")
アバター
破棄
関連投稿 返信 ビュー 活動
0
3月 25
1529
4
4月 24
174409
0
12月 23
2296
5
7月 25
228605
1
12月 22
3439