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

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


Thanks,



아바타
취소
베스트 답변

Hello Manoj,

You can try this

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

Regards

아바타
취소
베스트 답변

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

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

아바타
취소
작성자

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

관련 게시물 답글 화면 활동
1
10월 22
2807
2
8월 24
11322
0
4월 22
2468
1
6월 25
1904
3
7월 25
3502