[ADD] web_statusbar_clickable

This commit is contained in:
Holger Brunn
2014-08-27 15:28:10 +02:00
parent b1ff27f646
commit ae1b94077e
6 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
.oe_form_status_clickable li:hover
{
cursor: pointer;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

View File

@@ -0,0 +1,54 @@
//-*- coding: utf-8 -*-
//############################################################################
//
// OpenERP, Open Source Management Solution
// This module copyright (C) 2014 Therp BV (<http://therp.nl>).
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
//############################################################################
openerp.web_statusbar_clickable = function(instance)
{
instance.web.form.FieldStatus.include({
render_list: function()
{
this._super.apply(this, arguments);
if(this.node.attrs.clickable)
{
this.$element.find('ul').addClass('oe_form_status_clickable');
this.$element.find('li').click(this.on_state_clicked);
}
},
on_state_clicked: function(e)
{
var self = this,
clicked_val = jQuery(e.currentTarget).data('id');
if(clicked_val != this.value)
{
this.view.recursive_save().then(function()
{
var data = {}
data[self.name] = clicked_val;
self.view.dataset.write(
self.view.datarecord.id, data)
.then(function()
{
self.view.reload();
});
});
}
},
});
}

View File

@@ -0,0 +1,7 @@
<templates>
<t t-extend="FieldStatus.content">
<t t-jquery="li">
this.attr('t-att-data-id', 'widget.to_show[i][0]')
</t>
</t>
</templates>