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 21f84b6
Show file tree
Hide file tree
Showing 2 changed files with 16 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()

Check warning on line 238 in cms_form/models/cms_form.py

View check run for this annotation

Codecov / codecov/patch

cms_form/models/cms_form.py#L238

Added line #L238 was not covered by tests
13 changes: 13 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,16 @@ 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.
"""
session = session or http.request.session

Check warning on line 116 in cms_status_message/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

cms_status_message/models/ir_http.py#L116

Added line #L116 was not covered by tests
if session:
session["status_message"] = []

Check warning on line 118 in cms_status_message/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

cms_status_message/models/ir_http.py#L118

Added line #L118 was not covered by tests
if hasattr(session, "touch"):
session.touch()

Check warning on line 120 in cms_status_message/models/ir_http.py

View check run for this annotation

Codecov / codecov/patch

cms_status_message/models/ir_http.py#L120

Added line #L120 was not covered by tests

0 comments on commit 21f84b6

Please sign in to comment.