Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
3843 Zobrazení

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'


Avatar
Zrušit
Nejlepší odpověď

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")
Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
bře 25
1531
4
dub 24
174412
0
pro 23
2296
5
čvc 25
228619
1
pro 22
3443