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

[11.0] list view: many2one clickable by default #872

Closed
simahawk opened this issue Feb 20, 2018 · 3 comments
Closed

[11.0] list view: many2one clickable by default #872

simahawk opened this issue Feb 20, 2018 · 3 comments

Comments

@simahawk
Copy link
Contributor

simahawk commented Feb 20, 2018

After wasting a bit of time in try to port web_tree_many2one_clickable we discovered that if you put the attribute widget on the field (no matter if the widget exists or not, yes, even widget="foo" works) you get the nice link. This is because here we have:

        if (node.attrs.widget || (options && options.renderWidgets)) {
            var widget = this._renderFieldWidget(node, record, _.pick(options, 'mode'));
            this._handleAttributes(widget.$el, node);
            return $td.append(widget.$el);
        }
        var name = node.attrs.name;
        var field = this.state.fields[name];
        var value = record.data[name];

and the fallback for pure text value:

        var formattedValue = field_utils.format[field.type](value, field, {
            data: record.data,
            escape: true,
            isPassword: 'password' in node.attrs,
        });

So, it checks only that widget attribute is there and then rely on _renderFieldWidget which in turns does this:

        var Widget = record.fieldsInfo[this.viewType][fieldName].Widget;
        var widget = new Widget(this, fieldName, record, {
            mode: modifiers.readonly ? 'readonly' : mode,
            viewType: this.viewType,
        });

which means that is going to render the correct widget (m2o in this case) after retrieving it from fields info.

So, in the end, to get the m2o widget clickable, just do widget="many2one".
Same applies for all the other fields: just specify widget="the_widget". 😉

@simahawk simahawk mentioned this issue Feb 20, 2018
68 tasks
@simahawk simahawk changed the title [11.0] many2one clickable by default [11.0] list view: many2one clickable by default Feb 20, 2018
@simahawk
Copy link
Contributor Author

@astirpe mentioned that actually we have one more feature to enable / disable the widget in web_tree_many2one_clickable here.
I'll cherry-pick that then.

Even if I wonder why you would not want m2o to be always clickable... any pointer?

@astirpe
Copy link
Member

astirpe commented Feb 20, 2018

@simahawk thank you!
Of course when the user installs the "new" web_tree_many2one_clickable module, it's because he wants the functionality enabled in every tree view. So IMO there's no need of a system parameter anymore.

@pedrobaeza
Copy link
Member

This can be closed as the module is merged.

This issue was closed.
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

No branches or pull requests

3 participants