Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
3 Antwoorden
4036 Weergaven

I work to add some warning messages (non blocking) in my custom. Any one tell me how can i display a warning message.


Thanks,



Avatar
Annuleer
Beste antwoord

Hello Manoj,

You can try this

return {
'warning': {
'title': 'Warning!',
'message': 'Your warning text here.'}
}

Regards

Avatar
Annuleer
Beste antwoord

Hi, I have the same problem, and I used the following format in my code, but it does not display any message:

I want to display a warning message on a custom button (btc_approved) in sale.order.

I don't know what the issue is!

I understand this method is typically used under the onchange decorator, but I don’t have a field to use with onchange. Is there any alternative solution?

Here is my method:

def btc_approved(self):
for record in self:
user = record.user_id
if record.b2c_status != 'ready':
raise ValidationError(_("Only B2C Sale Orders with Ready can be Approved"))
elif record.b2c_sales == False:
raise ValidationError(_("Only B2C Sale Orders can be Approved"))
else:
if user.has_group('vatanzarin_security.visitor_group') and record.b2c_status == 'ready':
partner = record.partner_id
if partner.sale_warn and partner.sale_warn_msg != 'no_message':
return {
'warning': {
'title': _("There is a warning note for %s") % partner.name,
'message': partner.sale_warn_msg,
'type': 'notification',
}
}
record.b2c_status = 'approved'
record.financial_status = 'approved'
record.sudo().trigger_picking_atv(True)
Avatar
Annuleer
Beste antwoord

Hi

You can use ValidationError or Usererrors  to display warning messages



from odoo.exceptions import ValidationError, UserError


def action_confirm(self):
if (apply the condition):
raise UserError(_('Warning Message'))


<button string="Update" name="action_update"
       id="action_update"
       class="btn-success" type="object"
       confirm="Message?"
     />




Regards

Avatar
Annuleer
Auteur

Thanks for the answer Bella James,
But this will block the flow, i want not to stop the flow of code

Check the Updated answer

Gerelateerde posts Antwoorden Weergaven Activiteit
1
okt. 22
2497
2
aug. 24
9247
0
apr. 22
2215
1
jun. 25
1125
3
jul. 25
2862