Merge lp:~openerp-dev/openerp-web/trunk-bug-1082009-bth into lp:openerp-web

Proposed by Bhumi Thakkar (Open ERP)
Status: Rejected
Rejected by: Fabien Meghazi (OpenERP)
Proposed branch: lp:~openerp-dev/openerp-web/trunk-bug-1082009-bth
Merge into: lp:openerp-web
Diff against target: 11 lines (+1/-0)
1 file modified
addons/web_calendar/static/src/js/calendar.js (+1/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-bug-1082009-bth
Reviewer Review Type Date Requested Status
Fabien Meghazi (OpenERP) Disapprove
Bhumi Thakkar (Open ERP) Needs Resubmitting
Xavier (Open ERP) (community) Needs Fixing
Review via email: mp+136596@code.launchpad.net

Description of the change

Hello,

   Calendar view should not allow drag & drop facility for readonly views.

To generate this issue:
1. In HUman Resources => Leaves => Leave Request
2. Open in Calendar view.

Observed:
A user gets leaves approved (e.g. sick days). Everybody can see this in the calendar (good!). Everybody can move the event around (bad!). This makes the calendar much less usable as a credible tool and source of information.
Expected:
Calendar view should not allow drag & drop facility for readonly views.

Check field has attribute readonly: true then could not drag and drop (move) the record.

Thanks.

To post a comment you must log in.
Revision history for this message
Xavier (Open ERP) (xmo-deactivatedaccount) wrote :

Why the conditional? Why not just assign the first field to the second one, maybe converting to boolean inbetween just to be sure?

review: Needs Fixing
3510. By Bhumi Thakkar (Open ERP)

[IMP] Remove condition and just assign the value.

Revision history for this message
Bhumi Thakkar (Open ERP) (bth-openerp) wrote :

> Why the conditional? Why not just assign the first field to the second one,
> maybe converting to boolean inbetween just to be sure?

Remove the condition and just assign the value.

review: Needs Resubmitting
Revision history for this message
Mohammed Shekha(Open ERP) (msh-openerp) wrote :

Hello,

I think checking just date_start readonly will not fix this issue, currently this fix will stops the feature of drag and drop in calendar view (Would you please recheck and test it with this fix) because if date_start will have readonly=True but there might be a possibility of state exceptions (readonly=True, states={'draft': [('readonly', False)]}), here you have not considered states exception

To check this create Sale order in sale order's calendar view, date_order is date_start and date_order has state exception for draft state, so in draft state date_order field will be editable and in all other state it will be readonly, so we should allow drag and drop for draft state.

The issue is that we will not have modifiers so that we can straight forward check whether field satisfying readonly or not, for calendar view, to fix this we should also consider state based conditions.

(One suggestion according to me) We may have to transfer the field's modifiers in calendar.js itself(As server's transfer_field_to_modifiers returns modifiers) and then we have to compute the domain based on modifiers to check date_start is readonly or not. With this fix we also have to put state field in calendar view as we web-client considers the fields of view in computing domain.

If you have better idea/suggestion or any other way to fix the state exception then it will be better to use that.

Thanks.

Revision history for this message
Fabien Meghazi (OpenERP) (fme) wrote :

You cannot globally set the view as readonly for a state that should be computed by record.
item#1 having a date_start readonly trough a @state modifier doesn't mean that it will be the same for item#2.

Besides, the more important issue here is the fact that the addons allows a given user to write a field that should not be writable according to the business logic.

In this particular case, a confirmed leave request should not have a date_start writable by the user.

I will transfer the related bug to the addons team.

review: Disapprove

Unmerged revisions

3510. By Bhumi Thakkar (Open ERP)

[IMP] Remove condition and just assign the value.

3509. By Bhumi Thakkar (Open ERP)

[FIX] Calendar view should not allow drag & drop facility for readonly views.--fixes:lp1082009

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web_calendar/static/src/js/calendar.js'
2--- addons/web_calendar/static/src/js/calendar.js 2012-11-21 16:04:52 +0000
3+++ addons/web_calendar/static/src/js/calendar.js 2012-11-29 05:53:21 +0000
4@@ -120,6 +120,7 @@
5 init_scheduler: function() {
6 var self = this;
7 scheduler.clearAll();
8+ scheduler.config.readonly = this.fields[this.date_start]['readonly'];
9 if (this.fields[this.date_start]['type'] == 'time') {
10 scheduler.config.xml_date = "%H:%M:%S";
11 } else {