This question has been flagged
1 Reply
5026 Views

 def alert_msg(self,msg):

        return {'warning': {

                'title': _('Alert'),

                'message': _(msg),

                }

            }


def fn_val_annual(self,cr,uid,p_from_date,p_to_date,context=None):

        _l_error= 'No' 

        _l_day =  str(datetime.strptime(p_from_date, '%Y-%m-%d').strftime('%A'))

        if _l_day=='Friday' or _l_day=='Saturday':

            msg = "Annual leave start from Fri/sat"

            self.alert_msg(msg)

          

I am trying to call alert_msg function in fn_val_annual function but its not giving any warning for this particular condition.
Anyone help urgent.
Thanks
Avatar
Discard
Best Answer

Assuming that the function fn_val_annual is used as an onchange function you need to change the last line, like:

return self.alert_msg(msg)

You wouldn't be able to do that on the create or write or any other model method other than those that get called from an onchange, for the rest of the methods you will need to use Exceptions but those will do a rollback of the current transactions on the bd, so you better add some checks using onchange on the form field to validate the data before you save it

Avatar
Discard

please confirm where are you trying to use that function to get the warning