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

[14.0][IMP] web_m2x_options: add 'ignore_m2x_options' option #3067

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion web_m2x_options/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ web_m2x_options
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:1f28c92cd5c1a43185c582e5aa670e47dc78efced048df3c27bf0e77a0b1ad0d
!! source digest: sha256:175ee076d100de2101690e681f8a5bbf768c8cb478a054af3d31f78b1ed4a4a5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down Expand Up @@ -92,6 +92,10 @@ in the field's options dict

Deactivates the color picker on many2many_tags buttons to do nothing (ignored if open is set)

``ignore_m2x_options`` *boolean* (Default: ``False``)

The field will be processed without following the implementation of this module.

ir.config_parameter options
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -189,6 +193,7 @@ Contributors
* Carlos Roca
* Bhavesh Odedra <[email protected]>
* Dhara Solanki <[email protected]> (http://www.initos.com)
* Alexandre D. Díaz <[email protected]>

Maintainers
~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions web_m2x_options/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
* Carlos Roca
* Bhavesh Odedra <[email protected]>
* Dhara Solanki <[email protected]> (http://www.initos.com)
* Alexandre D. Díaz <[email protected]>
4 changes: 4 additions & 0 deletions web_m2x_options/readme/USAGE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ in the field's options dict

Deactivates the color picker on many2many_tags buttons to do nothing (ignored if open is set)

``ignore_m2x_options`` *boolean* (Default: ``False``)

The field will be processed without following the implementation of this module.

ir.config_parameter options
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
29 changes: 23 additions & 6 deletions web_m2x_options/static/src/js/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {

FieldMany2One.include({
_onInputFocusout: function () {
if (this.nodeOptions.ignore_m2x_options) {
return this._super(...arguments);
}

var m2o_dialog_opt =
is_option_set(this.nodeOptions.m2o_dialog) ||
(_.isUndefined(this.nodeOptions.m2o_dialog) &&
Expand All @@ -112,6 +116,10 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
_search: function (search_val) {
var self = this;

if (self.nodeOptions.ignore_m2x_options) {
return this._super(...arguments);
}

var def = new Promise((resolve) => {
// Add options limit used to change number of selections record
// returned.
Expand All @@ -127,10 +135,7 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
self.field_color = self.nodeOptions.field_color;
self.colors = self.nodeOptions.colors;

const context = Object.assign(
self.record.getContext(self.recordParams),
self.additionalContext
);
var context = self.record.getContext(self.recordParams);
var domain = self.record.getDomain(self.recordParams);

var blacklisted_ids = self._getSearchBlacklist();
Expand Down Expand Up @@ -375,6 +380,10 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
}),

_onDeleteTag: function (event) {
if (this.nodeOptions.ignore_m2x_options) {
return this._super(...arguments);
}

var result = this._super.apply(this, arguments);
event.stopPropagation();
return result;
Expand All @@ -383,7 +392,7 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
_onOpenBadge: function (event) {
var self = this;
var open = self.nodeOptions && is_option_set(self.nodeOptions.open);
if (open) {
if (!self.nodeOptions.ignore_m2x_options && open) {
var context = self.record.getContext(self.recordParams);
var id = parseInt($(event.currentTarget).data("id"), 10);

Expand Down Expand Up @@ -442,7 +451,11 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
_onOpenRecord: function (ev) {
var self = this;
var open = this.nodeOptions.open;
if (open && self.mode === "readonly") {
if (
!this.nodeOptions.ignore_m2x_options &&
open &&
self.mode === "readonly"
) {
ev.stopPropagation();
var id = ev.data.id;
var res_id = self.record.data[self.name].data.filter(
Expand All @@ -467,6 +480,10 @@ odoo.define("web_m2x_options.web_m2x_options", function (require) {
}),

_onOpenBadge: function (event) {
if (this.nodeOptions.ignore_m2x_options) {
return this._super(...arguments);
}

var open = is_option_set(this.nodeOptions.open);
var no_color_picker = is_option_set(this.nodeOptions.no_color_picker);
this._super.apply(this, arguments);
Expand Down
Loading