Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
3315 Переглядів

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")
Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
0
бер. 25
763
4
квіт. 24
173146
0
груд. 23
1644
5
лют. 25
225006
1
груд. 22
2620