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

Bug found in form_relation_widgets.js #17051

Closed
odoo-iventiva opened this issue May 17, 2017 · 7 comments
Closed

Bug found in form_relation_widgets.js #17051

odoo-iventiva opened this issue May 17, 2017 · 7 comments
Assignees
Labels
Confirmed the bug was confirmed by testers

Comments

@odoo-iventiva
Copy link

Impacted versions: 10

Steps to reproduce:

We found a bug in file web/static/src/js/views/form_relation_widgets.js (V10). The bug consists in that for a model that is read-only and we want to visualise it in a popup, the buttons SAVE and DISCARD still appear in the popup, which is wrong because those buttons should not appear.

In line 156 of form_relation_widgets.js the statement: readonly: !self.can_write always assigns false because self.can_write is evaluated as a string instead of a boolean. It comes as string instead of boolean Please fix this because it is a terrible bug. Or advice if we are wrong.

Current behaviour: SAVE and DISCARD buttons still appear in form in popup window even if model is set to read only access.

Expected behaviour: SAVE and DISCARD button should not appear. It should only appear the CLOSE button.

Video/Screenshot link (optional):

@Yenthe666
Copy link
Collaborator

Hi @odoo-iventiva,

Thank you for your report.
I believe this one is for @ged-odoo. What do you think about this?

Regards,
Yenthe

@ged-odoo ged-odoo added the Confirmed the bug was confirmed by testers label May 18, 2017
@ged-odoo
Copy link
Contributor

@Yenthe666 @odoo-iventiva this is funny, when you look at https://github.com/odoo/odoo/blob/10.0/addons/web/static/src/js/views/form_common.js#L178,
you see that can_write is set to this.node.attrs.can_write || true. As far as I know, something || true is true, so this looks like a bug, and a big one (even if it is not a blocking bug: the widget still works). This is weird, because I think I remember that we fixed such a bug recently, but I can't remember exactly.

@odoo-iventiva
Copy link
Author

Actually because of this bug the widget does not work. If I make a model read only, I still see the buttons SAVE and DISCARD in the popup where model data is shown.

@celm1990
Copy link
Contributor

Hi,
Solutions is change this lines :
this.can_create = this.node.attrs.can_create || true;
this.can_write = this.node.attrs.can_write || true;

By

this.can_create = this.node.attrs.can_create == "false" ? false : true;
this.can_write = this.node.attrs.can_write == "false" ? false : true;

@Yenthe666
Copy link
Collaborator

@ged-odoo do you agree with the change suggested by @celm1990?
I'm happy to make a PR if you're fine with this.

@ged-odoo
Copy link
Contributor

ged-odoo commented Sep 5, 2017

@Yenthe666 yes

@Yenthe666
Copy link
Collaborator

Okay - will make a PR within the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed the bug was confirmed by testers
Projects
None yet
Development

No branches or pull requests

4 participants