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

How to set dynamic message for confirm button

Currently, to add a confirmation, I will enter the message in the confirm attr of the button, so what if I want to display the confirmation through the function, so that I can vary the message how?

Avatar
Annuleer
Beste antwoord

Hi,

If you are trying to make the display notification conditionally you can follow the below code:example
    def action_confirm_button(self):
            flag = 0
           if your_conditio
                    flag = 1
            return {
                'type': 'ir.actions.client',
                'tag': 'display_notification',
                'params': {
                    'message': "first message" if flag else
                    "second message",
                    'type': 'success' if flag else 'danger',
                    'sticky': False,
                }
            }
       Or if you want to show different text in different times,You need to create a char field in your module and store the value in char fieldand the call the field value in messageeg:def action_confirm_button(self):
            return {
                'type': 'ir.actions.client',
                'tag': 'display_notification',
                'params': {
                    'message': self.field_name,
                    'type': 'success',
                    'sticky': False,
                }
            }


Hope it helps

Avatar
Annuleer
Gerelateerde posts Antwoorden Weergaven Activiteit
3
aug. 25
2322
1
mei 25
2546
1
apr. 25
3515
1
apr. 25
4344
1
apr. 25
1821