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] util.remove_view : remove redundant t-calls #116

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

kmod-odoo
Copy link

While removing the view, removing the content having t-call in other views which  are calling to have the content of it.

As there are many specific fixes available for this [16776,15322,14413,13404,13325,12205,12335 etc..], it's better to handle  it in remove_view.

Before fix:

  • t-call with the same xml_id will remain in other views that are using it. So during access of that view, the system is raising an error "view not found."
<t name="Payment" t-name="website_sale.payment">
    <t t-call="website_sale.cart_summary"/>
</t>

After fix:

  • t-call will be removed, so no error will be raised.
<t name="Payment" t-name="website_sale.payment">
</t>

Traceback:

Error while render the template
ValueError: View 'website_sale.cart_summary' in website 1 not found
Template: website_sale.payment
Path: /t/t/div/div[1]/div/div[4]/div[1]/t
Node: <t t-call="website_sale.address_on_payment"/>

@robodoo
Copy link
Contributor

robodoo commented Jul 19, 2024

Pull request status dashboard

@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from f3943de to 13fa9cb Compare July 19, 2024 12:47
@kmod-odoo kmod-odoo requested review from a team and jjmaksoud July 19, 2024 13:20
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch 2 times, most recently from 761da84 to 67feba3 Compare July 24, 2024 13:38
Copy link
Contributor

@diagnoza diagnoza left a comment

Choose a reason for hiding this comment

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

Please address pre-commit

src/util/records.py Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from 67feba3 to 3e4f381 Compare July 24, 2024 14:08
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from 3e4f381 to 77b0f22 Compare July 25, 2024 12:15
@kmod-odoo
Copy link
Author

Thank you for your valuable input @diagnoza, @aj-fuentes and @KangOl.
Changes have been done. Could you please confirm the changes?

src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch 2 times, most recently from eebe33a to d746716 Compare July 30, 2024 07:26
Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

In principle I'm OK with this. I will check with @KangOl once he's back if we should also do something similar for xmlid renames.

src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch 3 times, most recently from 6036e6b to 20793ea Compare August 5, 2024 11:37
@KangOl
Copy link
Contributor

KangOl commented Aug 5, 2024

Note that t-call will also search for views whose key match.
So we should also search for the key of the delete view (even if it hasn't any xmlid).

@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch 2 times, most recently from 5d985e6 to 0f26f72 Compare August 8, 2024 09:32
@kmod-odoo
Copy link
Author

Note that t-call will also search for views whose key match. So we should also search for the key of the delete view (even if it hasn't any xmlid).

Hello @KangOl,
Changes were made. Could you please confirm them?

@KangOl
Copy link
Contributor

KangOl commented Aug 8, 2024

upgradeci retry with always hr

@kmod-odoo
Copy link
Author

upgradeci retry with always hr

Hello @KangOl,
matt is still failing due to accounting and other issues unrelated to this patch. Should I take any further action?

@kmod-odoo
Copy link
Author

Hello @KangOl,
Just a gentle reminder to review this PR

@KangOl
Copy link
Contributor

KangOl commented Aug 21, 2024

The key can be different from the xmlid. You need to handle the both.

@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from 624e52c to eb9b3de Compare September 4, 2024 12:13
@kmod-odoo
Copy link
Author

Hello @KangOl,
Changes were made. Could you please confirm them?

@kmod-odoo
Copy link
Author

Hello @KangOl,
Just a gentle reminder to review this PR

@kmod-odoo
Copy link
Author

Gentle reminder @KangOl

@kmod-odoo
Copy link
Author

kmod-odoo commented Oct 10, 2024

Hello @KangOl
Just a friendly reminder to review this PR
cc: @aj-fuentes

src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from eb9b3de to 6afb5a5 Compare October 14, 2024 12:20
@kmod-odoo
Copy link
Author

Hello @aj-fuentes, suggested changes done could you please have a look? thanks :)

Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

Some small comments

src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
src/util/records.py Outdated Show resolved Hide resolved
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from 6afb5a5 to b9f0a16 Compare October 15, 2024 11:17
@kmod-odoo
Copy link
Author

Thank you for your valuable input @aj-fuentes.
Changes have been done. Could you please confirm the changes?

Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

LGTM

cc: @KangOl

@kmod-odoo
Copy link
Author

Hello @KangOl,
Just a gentle reminder to review this PR

@kmod-odoo
Copy link
Author

@KangOl Waiting for your final review as @aj-fuentes has approved this PR. Thanks!

@KangOl
Copy link
Contributor

KangOl commented Oct 28, 2024

I would also adapt util.rename_xmlid to alter the t-call (we already change the key of the views).

while removing the view, removing the content having t-call in other views which 
are calling to have the content of it.
As there are many specific fixes available for this, it's better to handle 
it in remove_view.

Before fix:
t-call with the same xml_id will remain in other views that are using it.
So during access of that view, the system is raising an error "view not found."
```
<t name="Payment" t-name="website_sale.payment">
    <t t-call="website_sale.cart_summary"/>
</t>
```

After fix:
t-call will be removed, so no error will be raised.
```
<t name="Payment" t-name="website_sale.payment">
</t>
```

Traceback:
```
Error while render the template
ValueError: View 'website_sale.cart_summary' in website 1 not found
Template: website_sale.payment
Path: /t/t/div/div[1]/div/div[4]/div[1]/t
Node: <t t-call="website_sale.address_on_payment"/>
```
Testcases for remove_view and rename_xmlid
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from b9f0a16 to 4daaa9a Compare December 2, 2024 11:12
@kmod-odoo
Copy link
Author

Hello @KangOl @aj-fuentes
I have adapted the rename_xmlid method to handle t-call, t-value and t-name updates and added tests for it; could you please have a look?
Thanks :)

src/util/records.py Outdated Show resolved Hide resolved
When renaming a view, we should also update its references in other views where
it is used in t-call, t-value and t-name attributes. This ensures consistency and
prevents broken references in dependent views.
@kmod-odoo kmod-odoo force-pushed the master-improve_remove_view-kmod branch from 4daaa9a to 9b1dbb4 Compare December 3, 2024 06:02
@kmod-odoo
Copy link
Author

Hello @KangOl
Just a gentle reminder to review this PR

@kmod-odoo
Copy link
Author

Hello @KangOl
Just a friendly reminder to review this PR

cc: @aj-fuentes

@kmod-odoo
Copy link
Author

Hello @KangOl
A gentle reminder, Could you please review this PR?

cc: @aj-fuentes

@kmod-odoo
Copy link
Author

Hello @KangOl,
Just a friendly follow-up could you kindly review this PR?

cc: @aj-fuentes

@kmod-odoo
Copy link
Author

Hello @KangOl
A gentle reminder, Could you please review this PR?

cc: @aj-fuentes

Copy link
Contributor

@aj-fuentes aj-fuentes left a comment

Choose a reason for hiding this comment

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

Generally speaking it LGTM, one small doubt.

@@ -786,6 +796,34 @@ def rename_xmlid(cr, old, new, noupdate=None, on_collision="fail"):
# Don't change the view keys inconditionally to avoid changing unrelated views.
cr.execute("UPDATE ir_ui_view SET key = %s WHERE key = %s", [new, old])

# Adapting t-call, t-value and t-name references in views
search_pattern = r"""\yt-(call|name|value)=(["']){}\2""".format(old)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why would we update t-name or t-value. Do we have examples?

Copy link
Author

@kmod-odoo kmod-odoo Jan 17, 2025

Choose a reason for hiding this comment

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

For t-name If a cowed view of a renamed view exists, it will have the old t-name, so we can replace it with the new one. For t-value, I noticed some code using is_view_active(view_name), so I initially thought it would be beneficial to include both.
image
However, since there aren't many examples of t-value usage, it can be removed. We can just proceed with t-name and t-call change.

Copy link
Contributor

Choose a reason for hiding this comment

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

The usage of is_view_active can be used in other context (t-if, t-elif) and should be handled explicitly with another search/replace.

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.

5 participants