Skip to content

Commit

Permalink
cms_status_message: add method to clear status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JuMiSanAr committed Jan 19, 2024
1 parent 631964e commit b21313f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cms_form/models/cms_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,6 @@ def form_process_POST(self, render_values):

def add_status_message(self, msg, **kw):
self.env["ir.http"].add_status_message(msg, request=self.o_request, **kw)

def clear_status_messages(self):
self.env["ir.http"].clear_status_messages()
14 changes: 14 additions & 0 deletions cms_status_message/models/ir_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,17 @@ def get_status_message(self, session=None):
if session:
return session.pop("status_message", [])
return []

@api.model
def clear_status_messages(self, session=None):
"""Clear status messages from current session.
:param session: odoo http session.
By default is taken from the current request.
:rtype: list.
"""
session = session or http.request.session
if session:
session["status_message"] = []
return session["status_message"]

0 comments on commit b21313f

Please sign in to comment.