-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[16.0][MIG]: web_edit_user_filter: Migration to 16.0 #3007
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
base: 16.0
Are you sure you want to change the base?
Conversation
bb1ccf2 to
8643376
Compare
Verified Scenarios:
Unverified Scenarios:
|
| for i, res_filter in enumerate(res): | ||
| # Add the field 'facet' to the result | ||
| res[i]["facet"] = filters.filtered(lambda f: f.id == res_filter["id"]).facet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion:
| for i, res_filter in enumerate(res): | |
| # Add the field 'facet' to the result | |
| res[i]["facet"] = filters.filtered(lambda f: f.id == res_filter["id"]).facet | |
| for res_filter in res: | |
| # Add the field 'facet' to the result | |
| res_filter["facet"] = filters.filtered(lambda f: f.id == res_filter["id"]).facet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
web_edit_user_filter/__manifest__.py
Outdated
| "web_edit_user_filter/static/src/xml/backend.xml", | ||
| "web_edit_user_filter/static/src/xml/search_extended.xml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chore: for consistence,
| "web_edit_user_filter/static/src/xml/backend.xml", | |
| "web_edit_user_filter/static/src/xml/search_extended.xml", | |
| "web_edit_user_filter/static/src/xml/*.xml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| var searchItems = this.env.searchModel.getSearchItems( | ||
| (s) => s.type === "favorite" | ||
| ); | ||
| const favorites = searchItems.filter( | ||
| (f) => f.description === this.state.description | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion:
| var searchItems = this.env.searchModel.getSearchItems( | |
| (s) => s.type === "favorite" | |
| ); | |
| const favorites = searchItems.filter( | |
| (f) => f.description === this.state.description | |
| ); | |
| var searchItems = this.env.searchModel.getSearchItems( | |
| (s) => s.type === "favorite" && s.description === this.state.description | |
| ); |
(there are a few similar simplifications that could be made around the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified as suggested. Identified in few other places and modified it. However, could not modify in places like here and popover is not visible when modifying it.
From testing on v14, In fact, in v14, contacts view:
I'd even go as far as suggesting removing that code path entirely, and adding to the Roadmap that the module is not currently compatible with custom filters. I don't think it's within the scope of the migration to fix that problem, necessarily. Though of course the last word is up to a maintainer. |
8643376 to
f01d632
Compare
|
Tried to use custom groups and filters as mentioned and it works in v16 and it is able to unpack the filters/groupBy which are selected from Add custom filter/group For eg: (Both "Application" and "Created By" custom groups under App module)
However, for this case as well it did not go inside tentative filter related branch code, so removed for now from the PR. In order to include as part of ROADMAP, I am not sure what to be mentioned as above custom related filters/groupBy works in v16(though it does not work in v14). As part of latest patchset, corrected issue with displaying facet values and unpacking facets that related to type "field". |
I had not tested on v16, if it works correctly then great, no need to mention anything on the roadmap. Thank you |
HekkiMelody
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review, LGTM, just some minor non-blocking code cleanup possible
| var currentFacet = this.env.searchModel.getSearchItems( | ||
| (f) => f.type === facet_type && f.groupId == facetId | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment (non-blocking): I think in this case using searchItems.filter was better, because you're filtering a subset of the searchItems you had already filtered beforehand, instead of searching from every filter in the model.
On the other hand, if searchItems is already filtered by facet_type and you use .filter here, you can drop the f.type === facet_type condition because it was already checked earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested
f01d632 to
9b842b6
Compare
|
Identified an item for ROADMAP and included it on the ROADMAP file. |
AnizR
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM and it works as described.
Thanks!
SAnnabelle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an error on the filters that already existed before the module was installed.
UncaughtClientError > SyntaxError Erreur Javascript non interceptée > "undefined" is not valid JSON SyntaxError: "undefined" is not valid JSON at JSON.parse (<anonymous>) at SearchBar._unpackFilter (https://odoo/web/assets/1941417-e5f98c9/web.assets_backend.min.js:18312:577) at HTMLAnchorElement.<anonymous> (https://odoo/web/assets/1941417-e5f98c9/web.assets_backend.min.js:18311:822) at HTMLAnchorElement.dispatch (https://odoo/web/assets/1941416-2c43b8a/web.assets_common.min.js:2469:447) at elemData.handle (https://odoo/web/assets/1941416-2c43b8a/web.assets_common.min.js:2455:166)
| ); | ||
|
|
||
| var selectedFacet = searchItems.filter( | ||
| (f) => f.groupId == facetId && f.isActive === true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| (f) => f.groupId == facetId && f.isActive === true | |
| (f) => f.groupId == facetId && f.isActive === true && (f.type !== 'favorite' || f.facet !== undefined) |
I would recommend adding this.
Otherwise, as @SAnnabelle pointed out, we will have an error when editing a favorite filter that was created before installing this module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree to implement the suggestion, but when I tried to reproduce the issue locally, it could not reproduce it.
I tried editing favorites thinking latest code base would introduced such errors, but while testing on latest code base I could not reproduce it.
@SAnnabelle , could you please let me know how can I reproduce it? So, I can push the required changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To reproduce the error, I did this:
- Create a favorite filter
- Install the module 'web_edit_user_filter'
- Try to edit the favorite filter that I created
- Error is thrown
The problem is that facet wasn't set when creating my filter since the module wasn't yet installed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for detailed response. I am able to reproduce it. With provided suggestion, user won't be able to see edit button for favorites whose facet is not available.
I have commented reason for the condition added. Should we notify the user that it can't be unpacked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, not displaying the edit button is enough IMO
9bcc8da to
465ba8e
Compare
[FIX] Readme [FIX] Lint [ADD] Tests [IMP] UI/UX [IMP] Hide popover when other is opened [IMP] Add item to roadmap
Added translation using Weblate (Chinese (Simplified)) Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/zh_CN/ Added translation using Weblate (Croatian) Translated using Weblate (Croatian) Currently translated at 66.7% (2 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/hr/ Added translation using Weblate (Portuguese) Translated using Weblate (Portuguese) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/pt/
has to explicit check for type of value !== null as the typeof null is object https://i.stack.imgur.com/FzI1R.png
Added translation using Weblate (Danish) Translated using Weblate (Danish) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/da/
Added translation using Weblate (Spanish) Translated using Weblate (Spanish) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/es/ Added translation using Weblate (French) Translated using Weblate (French) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/fr/ Added translation using Weblate (Catalan) Translated using Weblate (Catalan) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/ca/
Added translation using Weblate (Portuguese (Brazil)) Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (3 of 3 strings) Translation: web-12.0/web-12.0-web_edit_user_filter Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_edit_user_filter/pt_BR/
When clicking to edit a filter in search view, the _process_filters function will receive the faceID argument as a string, which will be compared to facet.groupId that is an Integer. Therefore we should use == operator when comparing this value to allow type coercion from JS.
465ba8e to
84fc6ee
Compare
|
Updated commit to handle error seen below when clicked on "Add to My Dashboard" under "Favorites" UncaughtPromiseError > TypeError |
|
This PR has the |
|
Hey @anusriNPS thank you for your contribution! @SAnnabelle could you please check again if everything works as expected? |
Migrating web_edit_user_filter to 16.0