Skip to content

[18.0][MIG] web_m2x_options: Migration to 18.0#3164

Merged
OCA-git-bot merged 77 commits intoOCA:18.0from
DynAppsNV:18.0-mig-web_m2x_options
May 6, 2025
Merged

[18.0][MIG] web_m2x_options: Migration to 18.0#3164
OCA-git-bot merged 77 commits intoOCA:18.0from
DynAppsNV:18.0-mig-web_m2x_options

Conversation

@denaux
Copy link
Copy Markdown
Contributor

@denaux denaux commented Apr 29, 2025

New PR for OCA module web_m2x_options for v18, based on PR #2961. Said PR has been open for 6+ months with several requested changes still pending. With this PR, I hope to get things moving:

  • Applied changes in accordance with the migration guidelines.
  • Incorporated new commits coming from older versions.
  • Implementing my suggestion to add unregistered methods to O.W.L.'s validation flow to avoid errors in dev mode.
  • Allowing falsy/truthy system parameters in a separate (backportable) commit, as requested here.
  • Fixing all linting warning as requested here.
  • Restoring the default (system parameter) behavior, as requested here and some other comments.
  • Implementing my suggestion to remove the many manual props updates on relational objects to avoid errors in dev mode.
  • Proposing a working migrated version of this module for v18 @bosd (based on your comment here).

Feel free to share suggestions or missing functionality, I commit myself to respond quickly and get this module migrated.

Nicolas JEUDY and others added 30 commits April 29, 2025 09:10
- Add static/description/index.html

fix: use include instead of extend in js function inheritance.

fix: not overwriting the existing object references with the result of the include

fix: update name according to new module name.

fix: error when displaying many2many field without options defined.
[ADD] support 'no_open_edit' on many2one
[FIX] typos
…and make the module installable [MIG] adapt form.js to the new API. [FIX] Fix bug mentioned in pull OCA#262. [MIG] Make the module installable.
…th `options={'open': True}` it always open the first element with this fix it will open the right one
* [FIX][web_m2x_options] Fix Qweb templates.

They were trying to replace non-existing elements, and this was being logged to console:

    Can't find "a.oe_m2o_cm_button" when extending template FieldMany2One
    Can't find "span.badge" when extending template FieldMany2ManyTag

* Raise version correctly.

* [FIX] Make many2many_tags tag deletion work again

* Correct replacement of event

Instead of overwriting all events from upstream widget, better just overwrite the one you need and inherit the rest.
* fix unecessary calls

Do check_access_rights and disable_quick_create calls only once per field.
`web_m2x_options` is supposed to render fields in the context of a form or tree view, where domains can safely be applied because there's a main record that includes a context.

However, when installing along with `web_advanced_search_x2x`, they produce an incompatibility when a x2x field's domain is defined and depends on the current record's context, because a search view has no notion of a *current record*.

The fix is simple: try to do as usual, and if it fails, try without the field's domain.

Without this patch, an exception like this would be raised, i.e. when both addons are installed and you are trying to search project tasks by stage:

``` Error: NameError: name 'project_id' is not defined
http://localhost/web/static/lib/py.js/lib/py.js:370# Traceback:# Changes to be committed:
PY_ensurepy@http://localhost/web/static/lib/py.js/lib/py.js:370:19# modified: static/src/js/form.js
py.evaluate@http://localhost/web/static/lib/py.js/lib/py.js:1340:20#
py.evaluate@http://localhost/web/static/lib/py.js/lib/py.js:1397:35
py.evaluate@http://localhost/web/static/lib/py.js/lib/py.js:1409:34
py.eval@http://localhost/web/static/lib/py.js/lib/py.js:1453:16
eval_domains/<@http://localhost/web/static/src/js/framework/pyeval.js:869:39
_.forEach@http://localhost/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost/web/static/src/js/framework/pyeval.js:860:5
eval_domains/<@http://localhost/web/static/src/js/framework/pyeval.js:873:39
_.forEach@http://localhost/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost/web/static/src/js/framework/pyeval.js:860:5
eval_domains/<@http://localhost/web/static/src/js/framework/pyeval.js:873:39
_.forEach@http://localhost/web/static/lib/underscore/underscore.js:145:9
_.mixin/</_.prototype[name]@http://localhost/web/static/lib/underscore/underscore.js:1484:29
eval_domains@http://localhost/web/static/src/js/framework/pyeval.js:860:5
pyeval@http://localhost/web/static/src/js/framework/pyeval.js:977:16
eval_arg@http://localhost/web/static/src/js/framework/pyeval.js:988:16
ensure_evaluated@http://localhost/web/static/src/js/framework/pyeval.js:1011:21
call@http://localhost/web/static/src/js/framework/data_model.js:56:9
name_search@http://localhost/web/static/src/js/framework/data.js:537:16
get_search_result@http://localhost/web_m2x_options/static/src/js/form.js:130:50
OdooClass.extend/Class.include/</prototype[name]</<@http://localhost/web/static/src/js/framework/class.js:122:35
source@http://localhost/web/static/src/js/views/form_relational_widgets.js:271:17
_search@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:6823:3
$.widget/</proxiedPrototype[prop]</<@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:415:19
search@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:6815:10
$.widget/</proxiedPrototype[prop]</<@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:415:19
$.widget.bridge/$.fn[name]/<@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:508:19
each@http://localhost/web/static/lib/jquery/jquery.js:383:49
each@http://localhost/web/static/lib/jquery/jquery.js:136:24
$.widget.bridge/$.fn[name]@http://localhost/web/static/lib/jquery.ui/jquery-ui.js:494:4
render_editable/<@http://localhost/web/static/src/js/views/form_relational_widgets.js:189:21
dispatch@http://localhost/web/static/lib/jquery/jquery.js:4640:50
add/elemData.handle@http://localhost/web/static/lib/jquery/jquery.js:4309:41
```
web_m2x_options: Fix usage for non-admins

web_m2x_options: Reduce rpc calls

web_m2x_options: Update manifest and readme
Currently translated at 91.7% (11 of 12 strings)

Translation: web-11.0/web-11.0-web_m2x_options
Translate-URL: https://translation.odoo-community.org/projects/web-11-0/web-11-0-web_m2x_options/pt_BR/
The method `_onOpenColorPicker` is defined on `FormFieldMany2ManyTags`, not in `FieldMany2ManyTags`, so it can only be called on its descendants.

Otherwise, clicking on a `many2many_tags` tag when found in a tree view produces an error such as:

    TypeError: self._onOpenColorPicker is not a function

    http://localhost/web_m2x_options/static/src/js/form.js:354
    Rastreo de error:
    _onOpenBadge@http://localhost/web_m2x_options/static/src/js/form.js:354:17
    proxy/<@http://localhost/web/static/src/js/core/mixins.js:279:20
    dispatch@http://localhost/web/static/lib/jquery/jquery.js:4640:50
    add/elemData.handle@http://localhost/web/static/lib/jquery/jquery.js:4309:41

(cherry picked from commit ddbbe81)
Currently translated at 91.7% (11 of 12 strings)

Translation: web-12.0/web-12.0-web_m2x_options
Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_m2x_options/fr/
Currently translated at 100.0% (12 of 12 strings)

Translation: web-12.0/web-12.0-web_m2x_options
Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_m2x_options/fr/
Currently translated at 100.0% (12 of 12 strings)

Translation: web-12.0/web-12.0-web_m2x_options
Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_m2x_options/pt_BR/
Currently translated at 100.0% (12 of 12 strings)

Translation: web-12.0/web-12.0-web_m2x_options
Translate-URL: https://translation.odoo-community.org/projects/web-12-0/web-12-0-web_m2x_options/zh_CN/
@denaux denaux force-pushed the 18.0-mig-web_m2x_options branch from 5735871 to 4f75b3b Compare May 6, 2025 12:33
@denaux
Copy link
Copy Markdown
Contributor Author

denaux commented May 6, 2025

@pedrobaeza @carlos-lopez-tecnativa

Thank you both for your input. I'm outvoted but also convinced of your arguments, so I've removed the create and create_edit options due to Odoo having the native options no_quick_create and no_create_edit. I have also done the same with the open option, as Odoo has the native option no_open.

I've also done some code cleanup.

Feel free to test things through!

Copy link
Copy Markdown
Contributor

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the work

@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

Copy link
Copy Markdown
Contributor

@CRogos CRogos left a comment

Choose a reason for hiding this comment

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

Could you squash some of the commits?
image

@denaux denaux force-pushed the 18.0-mig-web_m2x_options branch from 4f75b3b to ced386a Compare May 6, 2025 14:29
@denaux
Copy link
Copy Markdown
Contributor Author

denaux commented May 6, 2025

@CRogos

Could you squash some of the commits?

Done!

Copy link
Copy Markdown
Contributor

@CRogos CRogos left a comment

Choose a reason for hiding this comment

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

Tested and LGTM,

minor finding on the tests

# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests import common
from odoo.tests import TransactionCase
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use BaseCommon as base test class to reduce overhead from tracking and boost the test suite.

@pedrobaeza pedrobaeza changed the title [MIG] web_m2x_options: Migration to 18.0 [18.0][MIG] web_m2x_options: Migration to 18.0 May 6, 2025
@pedrobaeza
Copy link
Copy Markdown
Member

/ocabot migration web_m2x_options
/ocabot merge nobump

@OCA-git-bot OCA-git-bot added this to the 18.0 milestone May 6, 2025
@OCA-git-bot
Copy link
Copy Markdown
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 18.0-ocabot-merge-pr-3164-by-pedrobaeza-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot mentioned this pull request May 6, 2025
48 tasks
@OCA-git-bot OCA-git-bot merged commit 341c4b6 into OCA:18.0 May 6, 2025
7 checks passed
@OCA-git-bot
Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 1edfecf. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.