Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nh_clinical/__openerp__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
'demo': ['data/test/locations.xml', 'data/test/users.xml'],
'css': [],
'js': [],
'qweb': [],
'qweb': ['static/src/xml/form_tree_selected_widget_template.xml'],
'images': [],
'application': True,
'installable': True,
Expand Down
37 changes: 37 additions & 0 deletions nh_clinical/static/src/js/form_tree_selected_widget.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
openerp.nh_clinical = function (instance) {

var QWeb = instance.web.qweb;
var _t = instance.web._t;

// Declare our widget so it can be used on a view
instance.web.list.columns.add('field.form_tree_selected', 'instance.web.list.FormTreeSelectedColumn');

instance.web.list.FormTreeSelectedColumn = instance.web.list.Boolean.extend({

// Extend the format function of the boolean widget to add a click event to the node
format: function (row_data, options) {
var self = this;
var clickableId = "o_web_tree_selected_clickable-" +
row_data.id.value;

// defer execution of setting the click event until the function has returned
window.setTimeout(function() {
$("#" + clickableId).click(function() {
if( $('#' + clickableId + ':checkbox:checked').length > 0 ) {
// Make the RPC call with the value of true
new instance.web.Model("nh.clinical.allocating")
.call("write", [row_data.id.value], {'vals': {'selected': true}});
} else {
// Make the RPC call with the value of false
new instance.web.Model("nh.clinical.allocating")
.call("write", [row_data.id.value], {'vals': {'selected': false}});
}
});
}, 0);
return QWeb.render(
'FormTreeSelected',
{widget: self._format(row_data, options), clickableId: clickableId}
);
},
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-name="FormTreeSelected">
<input type="checkbox"
t-att-id="clickableId"
t-att-name="widget.name"
class="field_boolean"/>
</t>
</templates>
1 change: 1 addition & 0 deletions nh_clinical/views/static_resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<template id="assets_backend" name="nh_clinical assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/nh_clinical/static/src/js/Many2ManyTags_override.js"></script>
<script type="text/javascript" src="/nh_clinical/static/src/js/form_tree_selected_widget.js"></script>
</xpath>
</template>
</data>
Expand Down
Loading