summaryrefslogtreecommitdiff
path: root/addons/base/static/src
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2011-05-31 13:23:39 +0200
committerXavier Morel <xmo@openerp.com>2011-05-31 13:23:39 +0200
commitcd3e60aef10a74fd04580b6e5903ee319f160604 (patch)
tree429a3c075bd43ec859cdcae22ba420e45ad54ed4 /addons/base/static/src
parent9a5058a6b478b7778f9e824d1177b4daf82434dd (diff)
[ADD] editability status to ListView options (hence all sub-objects of the list view)
bzr revid: xmo@openerp.com-20110531112339-701lpf42p8h19mfj
Diffstat (limited to 'addons/base/static/src')
-rw-r--r--addons/base/static/src/js/list.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/addons/base/static/src/js/list.js b/addons/base/static/src/js/list.js
index 2fd4aff2e1c..a64cb0c0021 100644
--- a/addons/base/static/src/js/list.js
+++ b/addons/base/static/src/js/list.js
@@ -14,7 +14,9 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
// sorted it can not be reordered anymore
'sortable': true,
// whether the view rows can be reordered (via vertical drag & drop)
- 'reorderable': true
+ 'reorderable': true,
+ // editability status of list rows
+ 'editable': null
},
/**
* Core class for list-type displays.
@@ -39,6 +41,7 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
* @param {null|String} [options.addable="New"] should the new-record button be displayed, and what should its label be. Use ``null`` to hide the button.
* @param {Boolean} [options.sortable=true] is it possible to sort the table by clicking on column headers
* @param {Boolean} [options.reorderable=true] is it possible to reorder list rows
+ * @param {null|"bottom"|"top"} [options.editable=null] can rows be edited, and do new rows appear at the top or the bottom of the list
*
* @borrows openerp.base.ActionExecutor#execute_action as #execute_action
*/
@@ -271,6 +274,21 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
$.proxy(this, 'compute_aggregates')));
},
/**
+ * Sets editability status for the list, based on defaults, view
+ * architecture and the provided flag, if any.
+ *
+ * @param {Boolean} [force] forces the list to editability. Sets new row edition status to "bottom".
+ */
+ set_editable: function (force) {
+ // If ``force``, set editability to bottom
+ // else if editability flag in view arch, use that
+ // otherwise rely on view default
+ this.options.editable = (
+ (force && "bottom")
+ || this.fields_view.arch.attrs.editable
+ || this.defaults.editable);
+ },
+ /**
* Event handler for a search, asks for the computation/folding of domains
* and contexts (and group-by), then reloads the view's content.
*
@@ -296,6 +314,8 @@ openerp.base.ListView = openerp.base.View.extend( /** @lends openerp.base.ListVi
if (_.isEmpty(results.group_by) && !results.context['group_by_no_leaf']) {
results.group_by = null;
}
+ self.set_editable(results.context['set_editable']);
+
self.reload_view(!!results.group_by).then(
$.proxy(self, 'reload_content'));
});