Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
4107 Weergaven

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
Annuleer
Beste antwoord

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
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
0
mrt. 25
1979
4
apr. 24
175137
0
dec. 23
2689
5
jul. 25
230776
1
dec. 22
3856