[FIX] web: prevent set value of priority if readonly

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
This commit is contained in:
Denis Ledoux 2015-02-26 17:19:04 +01:00
parent 5f45e7ca96
commit 25bf2674d5
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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>

View File

@ -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;