콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
5525 화면

 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
아바타
취소
베스트 답변

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

아바타
취소

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