Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] report: open chat window post upgrade #218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

diagnoza
Copy link
Contributor

Chat window with the report will be opened by default after the upgrade, only for the admin user.

image

@diagnoza diagnoza requested review from a team and UemuS February 27, 2025 22:28
@robodoo
Copy link
Contributor

robodoo commented Feb 27, 2025

Pull request status dashboard

@@ -286,6 +286,21 @@ def ref(xid):
except Exception:
_logger.warning("Cannot announce message", exc_info=True)

# Chat window with the report will be open post-upgrade for the admin
if version_gte("9.0"):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can get rid of one level of ifs in favor of a dictionary with versions, but I thought it's going to be less readable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of this because we do not support upgrading to 9.0 already :)

[("partner_id", "=", user.partner_id.id), ("channel_id", "=", recipient.id)]
)[0].with_context(ctx).fold_state = "open"
except Exception:
_logger.warning("Cannot open chat window", exc_info=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to log anything, in any case if we do logging exception info is better done with _logger.exception ;)

Suggested change
_logger.warning("Cannot open chat window", exc_info=True)
pass

Maybe use contextlib.suppress and be more specific: what kind of exception we get here? and why?

@diagnoza diagnoza force-pushed the master-open_chat-owi branch from ecf96b7 to 4926bd1 Compare February 28, 2025 12:57
@KangOl
Copy link
Contributor

KangOl commented Feb 28, 2025

upgradeci retry with always only hr in all versions

@diagnoza diagnoza force-pushed the master-open_chat-owi branch from 4926bd1 to 5284593 Compare February 28, 2025 13:16
Comment on lines 292 to 297
try:
registry[channel_member_model].search(
[("partner_id", "=", user.partner_id.id), ("channel_id", "=", recipient.id)]
)[0].with_context(ctx).fold_state = "open"
except Exception:
_logger.exception("Could not open chat window with upgrade report.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1/ extract the domain in a variable
2/ avoid exception by not using [0]

Suggested change
try:
registry[channel_member_model].search(
[("partner_id", "=", user.partner_id.id), ("channel_id", "=", recipient.id)]
)[0].with_context(ctx).fold_state = "open"
except Exception:
_logger.exception("Could not open chat window with upgrade report.")
domain = [("partner_id", "=", user.partner_id.id), ("channel_id", "=", recipient.id)]
registry[channel_member_model].search(domain)[:1].with_context(ctx).fold_state = "open"

@diagnoza diagnoza force-pushed the master-open_chat-owi branch from 5284593 to f3e72ee Compare March 10, 2025 12:19
@diagnoza diagnoza requested a review from KangOl March 10, 2025 12:21
@@ -286,6 +286,12 @@ def ref(xid):
except Exception:
_logger.warning("Cannot announce message", exc_info=True)

# Chat window with the report will be open post-upgrade for the admin user
if not version_gte("saas~18.2"):
channel_member_model = "discuss.channel.member" if version_gte("saas~16.3") else "mail.channel.member"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
channel_member_model = "discuss.channel.member" if version_gte("saas~16.3") else "mail.channel.member"
channel_member_model = "discuss.channel.member" if version_gte("saas~16.3") else "mail.channel.member" if version_gte("16.0") else "mail.channel.partner"

@@ -286,6 +286,12 @@ def ref(xid):
except Exception:
_logger.warning("Cannot announce message", exc_info=True)

# Chat window with the report will be open post-upgrade for the admin user
if not version_gte("saas~18.2"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fold_state appears in v9

Suggested change
if not version_gte("saas~18.2"):
if version_between("9.0", "saas~18.2"):

Chat window with the report will be opened by default after the upgrade,
only for the admin user.
@diagnoza diagnoza force-pushed the master-open_chat-owi branch from f3e72ee to 815bece Compare March 18, 2025 10:14
@diagnoza diagnoza requested review from KangOl and aj-fuentes March 18, 2025 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants