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

[4258][FIX] template_content_swapper #5

Merged
merged 6 commits into from
Aug 14, 2024

Conversation

AungKoKoLin1997
Copy link
Contributor

@@ -16,7 +16,8 @@ def _render_template(self, template, values=None):
result_str = str(result)
lang_code = "en_US"
request = values.get("request")
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
request = values.get("request")

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 15.0-imp-template_content_swapper branch from fd138f5 to 37f7227 Compare August 13, 2024 02:15
Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

The scope of _render_template() is not clear to me when mega menu is involved. Is it processed on the mega menu only? If that is the case, is it still relevant for content swapping at all?

@AungKoKoLin1997
Copy link
Contributor Author

The scope of _render_template() is not clear to me when mega menu is involved. Is it processed on the mega menu only? If that is the case, is it still relevant for content swapping at all?

@yostashiro Our scope for content swapping is for all views and reports. So, _render_template() is called every time the view is rendered.

@AungKoKoLin1997
Copy link
Contributor Author

AungKoKoLin1997 commented Aug 13, 2024

I checked the log when I created the mega menu. It seems like the _render_templated is called twice and first one is in cache and there is no values. The first view is s_mega_menu_odoo_menu and second view is home page view id.

2024-08-13 05:48:15,545 599764 INFO 5stx3 root: ir.ui.view(1351,) 
2024-08-13 05:48:15,545 599764 INFO 5stx3 root: None 
2024-08-13 05:48:15,550 599764 INFO 5stx3 odoo.modules.registry: At least one model cache has been invalidated, signaling through the database. 
2024-08-13 05:48:15,554 599764 INFO 5stx3 werkzeug: 58.11.156.73 - - [13/Aug/2024 05:48:15] "POST /web/dataset/call_kw/website.menu/save HTTP/1.0" 200 - 95 0.031 0.111
2024-08-13 05:48:16,896 599764 INFO 5stx3 root: ir.ui.view(1141,) 
2024-08-13 05:48:16,896 599764 INFO 5stx3 root: {'deletable': True, 'main_object': website.page(4,), 'response_template': 1141, 'request': <odoo.http.HttpRequest object at 0x7f26ba76a070>, 'backend_menu_id': 265}

@yostashiro
Copy link
Member

@AungKoKoLin1997 My question was more from the business perspective. Mega menu is totally customizable IIUC, and if that is the case, would there be any point doing the content swapping at all? If there was no point, I thought one way of handling this case was to just return result if there there was no value. Not saying that this should be the conclusion.

@AungKoKoLin1997
Copy link
Contributor Author

If there was no point, I thought one way of handling this case was to just return result if there there was no value.

@yostashiro I got the point. When I quick check for other options in website and I see mega menu is only the case. So, I will take your suggestion.

@AungKoKoLin1997 AungKoKoLin1997 force-pushed the 15.0-imp-template_content_swapper branch from 2c93e2e to 05284ed Compare August 13, 2024 07:55
Comment on lines 21 to 24
elif re.search(r'data-oe-lang="([^"]+)"', result_str):
# For reports
lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str)
if lang_match:
lang_code = lang_match.group(1)
lang_code = lang_match.group(1)
Copy link
Member

Choose a reason for hiding this comment

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

        lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str)
        if lang_match:
            # For reports
            lang_code = lang_match.group(1)

Comment on lines 21 to 24
lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str)
if lang_match:
# For reports
lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str)
if lang_match:
lang_code = lang_match.group(1)
lang_code = lang_match.group(1)
Copy link
Member

Choose a reason for hiding this comment

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

Sorry to correct many times...

        else:
            lang_match = re.search(r'data-oe-lang="([^"]+)"', result_str)
            if lang_match:
                # For reports
                lang_code = lang_match.group(1)

Copy link
Member

@yostashiro yostashiro left a comment

Choose a reason for hiding this comment

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

Code review.

Copy link
Contributor

@kanda999 kanda999 left a comment

Choose a reason for hiding this comment

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

Functioanl and Code review.

Could you please update the OCA PR.

@kanda999 kanda999 merged commit 130aa54 into 15.0 Aug 14, 2024
2 checks passed
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.

3 participants