Skip to content

Commit

Permalink
[FIX] web: prevent set value of priority if readonly
Browse files Browse the repository at this point in the history
The priority widget did not handle the readonly concept
It was therefore possible to set the priority of
an issue (for instance) even if the field was marked
as readonly.

opw-628960
  • Loading branch information
beledouxdenis committed Feb 26, 2015
1 parent 5f45e7c commit 25bf267
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion addons/web/static/src/js/view_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -2424,7 +2424,9 @@ instance.web.form.Priority = instance.web.form.FieldChar.extend({
this.record_id = this.view.datarecord.id;
this.priorities = this.prepare_priority();
this.$el.html(QWeb.render("Priority", {'widget': this}));
this.$el.find('li').on('click', this.set_priority.bind(this));
if (!this.get('readonly')){
this.$el.find('li').on('click', this.set_priority.bind(this));
}
},
/* setting the value: in view mode, perform an asynchronous call and reload
the form view; in edit mode, use set_value to save the new value that will
Expand Down
3 changes: 2 additions & 1 deletion addons/web/static/src/xml/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1056,9 +1056,10 @@
<ul style="list-style: none; padding-left: 2px; display: inline-block;">
<t t-foreach="widget.priorities" t-as="rec" >
<li t-att-data-value="rec.click_value" style="display: inline-block;">
<a href="#" t-att-title="rec.name">
<a t-if="!widget.get('readonly')" href="#" t-att-title="rec.name">
<span t-att-class="widget.get('value') gte rec.value and 'oe_e oe_star_on' or 'oe_e oe_star_off'">7</span>
</a>
<span t-if="widget.get('readonly')" t-att-title="rec.name" t-att-class="widget.get('value') gte rec.value and 'oe_e oe_star_on' or 'oe_e oe_star_off'">7</span>
</li>
</t>
</ul>
Expand Down
8 changes: 7 additions & 1 deletion addons/web_kanban/static/src/js/kanban.js
Original file line number Diff line number Diff line change
Expand Up @@ -1300,8 +1300,14 @@ instance.web_kanban.Priority = instance.web_kanban.AbstractField.extend({
var self = this;
this.record_id = self.parent.id;
this.priorities = self.prepare_priority();
var readonly = this.field && this.field.readonly;
if (readonly){
this.set('readonly', true);
}
this.$el = $(QWeb.render("Priority", {'widget': this}));
this.$el.find('li').click(self.do_action.bind(self));
if (!readonly){
this.$el.find('li').click(self.do_action.bind(self));
}
},
do_action: function(e) {
var self = this;
Expand Down

0 comments on commit 25bf267

Please sign in to comment.