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

[ADD] New module: web_readonly_bypass #162

Merged
merged 9 commits into from
Oct 4, 2015

Conversation

JonathanNEMRY
Copy link

This Module provides a solution to the problem of the interaction between 'readonly' attribute and 'on_change' attribute when used together

------------

* Jonathan Nemry <jonathan.nemry@acsone.eu>
* Laetitia Gangloff <laetitia.gangloff.eu>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think email address isn't correct

@adrienpeiffer
Copy link
Contributor

Can you remove All Rights Reserved from header ?

@legalsylvain legalsylvain added this to the 8.0 milestone Jul 2, 2015
@adrienpeiffer
Copy link
Contributor

Little remarks on readme file and about header. Otherwise, 👍

#
# Authors: Nemry Jonathan & Laetitia Gangloff
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
# All Rights Reserved
Copy link
Member

Choose a reason for hiding this comment

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

Remove this useless line

@pedrobaeza
Copy link
Member

Very interesting feature! 👍 (code review)

@sbidoul sbidoul force-pushed the 8.0-web_readonly_bypass-jne branch from 5c0c721 to 3260cd2 Compare July 2, 2015 12:37
<data>
<template id="assets_backend" name="readonly_bypass" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/readonly_bypass/static/src/js/readonly_bypass.js"></script>
Copy link

Choose a reason for hiding this comment

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

As you rename module you miss to change the path:

Should be

<script type="text/javascript" src="/web_readonly_bypass/static/src/js/readonly_bypass.js"></script>

@petrus-v petrus-v mentioned this pull request Jul 2, 2015
* Use a better test condition
* Fix the email address
[FIX]
* rename the path and web instance just as the module was
@petrus-v
Copy link

petrus-v commented Jul 3, 2015

Excellent 👍

@pedrobaeza
Copy link
Member

DO NOT MERGE YET!

Thinking about this carefully, this module inverts the behaviour by default, so it applies to all existing codebase, and can lead to unexpected behaviours in modules that rely on the volatibility of onchange to change data, but they don't want to store it.

The module must act the contrary: use the normal behaviour by default, and include a context key not_filter_out_readonly or similar that allows that someone include this dependency and this value in the field context when he wants to change the behaviour.

@sbidoul
Copy link
Member

sbidoul commented Jul 9, 2015

Although I don't have any concrete cases in mind, I agree with @pedrobaeza: it's risky to have a module that changes the standard behavior system wide, as this may have unexpected side effects.

@petrus-v since you are testing it these days, would you mind doing that change?

@petrus-v
Copy link

petrus-v commented Jul 9, 2015

@sbidoul

I agree with @pedrobaeza! This behavior will be safer for me as well, I'll make change on #164 as well!

I wonder how to set the context correctly, I expected to set it on the field or the entire view but it looks more complicated as I expected to forward it properly!

Thanks to take me in consideration!

@pedrobaeza
Copy link
Member

I think the best approach is to define the context at field level, so you can fine-grain the control over each readonly field.

@JonathanNEMRY
Copy link
Author

@petrus-v
an idea could be to say: if we want this behavior then add it into the context action of the form. And then the added context should simply be like that {'readonly_by_pass': True} or in a more complex way {'readonly_by_pass': ['concerned_field', '...', ...]}
By this way, it will be possible to extend the scope of this behavior, from a specific field to an entire form and the changes into the existing code are minimals

@pedrobaeza
Copy link
Member

Well, I prefer the duality of the key in the action window context or the key in the field context.

function ignore_readonly(data, options, mode, context){
if (options){
if ('readonly_fields' in options && options['readonly_fields'] &&
!('filter_out_readonly' in context && context['filter_out_readonly'] == true )) {
Copy link

Choose a reason for hiding this comment

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

@JonathanNEMRY , @pedrobaeza

To be accurate, my problem was that, when I quickly tested to define context on the field like this on the view:

<field name="my_readonly_field" context="{'filter_out_readonly': True}" />

or on the action windows.

The javascript context parameter does'nt contain the filter_out_readonly properties :-/

It needs more investigations ;-)

@JonathanNEMRY
Copy link
Author

Added a specific context into a field will be not propagated until the dataset or datasetbuffer action (create/write in our case). Context is propagated for relational fields if a context is present into the node:
build_context: function() { // only use the model's context if there is not context on the node var v_context = this.node.attrs.context;
This method is not called for other fields so I agree with @pedrobaeza to have a dual context key action or field but it will be more difficult and that's why I suggested to use the context action

@pedrobaeza
Copy link
Member

Ok, I don't know about the difficulty in JS side, so go ahead with the one you propose, @JonathanNEMRY

@JonathanNEMRY
Copy link
Author

So @petrus-v do you think it is OK for you to consider the special context key will be added into the action's context (ir.action.act_window)? (so it will be available into the self.context of create/write from the dataset classe )

@petrus-v
Copy link

@JonathanNEMRY

Yes I'm fine with that! I'll do the same. thanks for the tip!

@petrus-v
Copy link

petrus-v commented Aug 6, 2015

@JonathanNEMRY I've done some works there https://github.com/petrus-v/web/tree/8.0-web_readonly_bypass but I'm going to be off for a month, I could create a PR on acsone repo first, then let you follow this PR, or I create a new fresh PR on OCA/web repo, or you can directly merge my branch (becarefull I rebase on the top of oca/8.0)? What do you prefer ?

@JonathanNEMRY
Copy link
Author

@petrus-v you can make a PR on https://github.com/acsone/web/tree/8.0-web_readonly_bypass-jne and then I will take care of the next steps! see you next month ;)

@petrus-v
Copy link

petrus-v commented Aug 7, 2015

@JonathanNEMRY

Ok, thanks, I'll do that.

Pierre Verkest added 3 commits August 7, 2015 12:15
@pedrobaeza
Copy link
Member

Any update on this?

@petrus-v
Copy link

@pedrobaeza, @sbidoul

I think we could replace work in progress tag by needs review tag as PR #164 was merged.

Obviously I give my 👍 as I've done the end of works, but I'm not sure it has values!

@@ -0,0 +1,86 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:alt: License: AGPL-3
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

Can you take a look to the latest version of the sample README.rst (https://raw.githubusercontent.com/OCA/maintainer-tools/master/template/module/README.rst) and fix the following issues?

  • add target to the image licence badge
  • put a lot of '===' above the module title to make the title a real title
  • add a link 'Try me on Runbot' in the usage section

* Improve .rst
* user_strict into js
* review Authors
@JonathanNEMRY
Copy link
Author

Hi,
I just add some improvements referenced to the last review and I've also tested the module with @petrus-v 's changes. It seems OK for me now. Just some more thumbs up before merging.

@lmignon
Copy link
Sponsor Contributor

lmignon commented Oct 1, 2015

👍

------------

* Jonathan Nemry <jonathan.nemry@acsone.eu>
* Laetitia Gangloff <laetitia.gangloff@acsone.eu>
Copy link
Member

Choose a reason for hiding this comment

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

Add @petrus-v in contributors.

@JonathanNEMRY
Copy link
Author

@petrus-v is added to the contributors into README.rst: sorry for this omission and thanks again for your contribution!

@petrus-v
Copy link

petrus-v commented Oct 2, 2015

@JonathanNEMRY,

oh yes I missed it too, thanks! That was with pleasure ;), you did the hardest way

@pedrobaeza
Copy link
Member

👍

pedrobaeza added a commit that referenced this pull request Oct 4, 2015
[ADD] New module: web_readonly_bypass
@pedrobaeza pedrobaeza merged commit da4402d into OCA:8.0 Oct 4, 2015
@sbidoul sbidoul deleted the 8.0-web_readonly_bypass-jne branch October 22, 2016 15:01
leemannd pushed a commit to camptocamp/web that referenced this pull request May 29, 2018
Update all submodules + project + fix build
vrenaville pushed a commit to camptocamp/web that referenced this pull request Jul 19, 2018
…constraint

BSMTS-286 Remove BVR/ESR unique constraint
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

Successfully merging this pull request may close these issues.

None yet

8 participants