7 The list view provides a few style hook classes for re-styling of list views in
12 The root element of the list view, styling rules should be rooted
15 ``table.oe_list_content``
17 The root table for the listview, accessory components may be
18 generated or added outside this section, this is the list view
23 The action buttons array for the list view, with its sub-elements
27 The default "Create"/"Add" button of the list view
31 The "alternative choice" for the list view, by default text
32 along the lines of "or import" with a link.
34 ``.oe_list_field_cell``
36 The cell (``td``) for a given field of the list view, cells which
37 are *not* fields (e.g. name of a group, or number of items in a
38 group) will not have this class. The field cell can be further
43 Numeric cell types (integer and float)
47 Action button (``button`` tag in the view) inside the cell
53 ``.oe_list_field_$type``
55 Additional class for the precise type of the cell, ``$type``
56 is the field's @widget if there is one, otherwise it's the
59 ``.oe_list_record_selector``
66 The editable list view module adds a few supplementary style hook
67 classes, for edition situations:
71 Added to both ``.oe_list`` and ``.oe_list_button`` (as the
72 buttons may be outside of the list view) when a row of the list is
73 currently being edited.
77 Class set on the row being edited itself. Note that the edition
78 form is *not* contained within the row, this allows for styling or
79 modifying the row while it's being edited separately. Mostly for
80 fields which can not be edited (e.g. read-only fields).
86 List view edition is an extension to the base listview providing the
87 capability of inline record edition by delegating to an embedded form
92 cleanup options and settings for editability configuration. Right
97 ``null``, ``"top"`` or ``"bottom"``, generally broken and
100 ``context.set_editable``
102 forces ``options.editable`` to ``"bottom"``
104 ``view.arch.attrs.editable``
106 same as ``defaults.editable``, but applied separately (after
107 reloading the view), if absent delegates to
108 ``options.editable`` which may have been set previously.
110 ``options.read_only``
112 force options.editable to false, or something?
114 .. note:: can probably be replaced by cancelling ``edit:before``
116 and :js:func:`~openerp.web.ListView.set_editable` which
117 ultimately behaves weird-as-fuck-ly.
119 The editable list view module adds a number of methods to the list
120 view, on top of implementing the :js:class:`EditorDelegate` protocol:
125 .. js:function:: openerp.web.ListView.ensureSaved
127 Attempts to resolve the pending edition, if any, by saving the
128 edited row's current state.
130 :returns: delegate resolving to all editions having been saved, or
131 rejected if a pending edition could not be saved
132 (e.g. validation failure)
134 .. js:function:: openerp.web.ListView.startEdition([record])
136 Starts editing the provided record inline, through an overlay form
137 view of editable fields in the record.
139 If no record is provided, creates a new one according to the
140 editability configuration of the list view.
142 This method resolves any pending edition when invoked, before
143 starting a new edition.
145 :type record: :js:class:`~openerp.web.list.Record`
146 :returns: delegate to the form used for the edition
148 .. js:function:: openerp.web.ListView.saveEdition
150 Resolves the pending edition.
152 :returns: delegate to the save being completed, resolves to an
153 object with two attributes ``created`` (flag indicating
154 whether the saved record was just created or was
155 updated) and ``record`` the reloaded record having been
158 .. js:function:: openerp.web.ListView.cancelEdition
160 Cancels pending edition, cleans up the list view in case of
161 creation (removes the empty record being created).
166 .. js:function:: openerp.web.ListView.getCellsFor(row)
168 Extracts the cells from a listview row, and puts them in a
169 {fieldname: cell} mapping for analysis and manipulation.
174 .. js:function:: openerp.web.ListView.withEvent(event_name, event, action[, args][, trigger_params])
176 Executes ``action`` in the context of the view's editor,
177 bracketing it with cancellable event signals.
179 :param String event_name: base name for the bracketing event, will
180 be postfixed by ``:before`` and
181 ``:after`` before being called
182 (respectively before and after
183 ``action`` is executed)
184 :param Object event: object passed to the ``:before`` event
186 :param Function action: function called with the view's editor as
187 its ``this``. May return a deferred.
188 :param Array args: arguments passed to ``action``
189 :param Array trigger_params: arguments passed to the ``:after``
190 event handler alongside the results
193 Behavioral Customizations
194 +++++++++++++++++++++++++
196 .. js:function:: openerp.web.ListView.handleOnWrite(record)
198 Implements the handling of the ``onwrite`` listview attribute:
199 calls the RPC methods specified by ``@onwrite``, and if that
200 method returns an array of ids loads or reloads the records
201 corresponding to those ids.
203 :param record: record being written having triggered the
205 :type record: openerp.web.list.Record
206 :returns: deferred to all reloadings being done
211 For simpler interactions by/with external users of the listview, the
212 view provides a number of dedicated events to its lifecycle.
214 .. note:: if an event is defined as *cancellable*, it means its first
215 parameter is an object on which the ``cancel`` attribute can
216 be set. If the ``cancel`` attribute is set, the view will
217 abort its current behavior as soon as possible, and rollback
218 any state modification.
220 ``edit:before`` *cancellable*
222 Invoked before the list view starts editing a record.
224 Provided with an event object with a single property ``record``,
225 holding the attributes of the record being edited (``record`` is
226 empty *but not null* for a new record)
230 Invoked after the list view has gone into an edition state,
231 provided with the attributes of the record being edited (see
232 ``edit:before``) as first parameter and the form used for the
233 edition as second parameter.
235 ``save:before`` *cancellable*
237 Invoked right before saving a pending edition, provided with an
238 event object holding the listview's editor (``editor``) and the
239 edition form (``form``)
243 Invoked after a save has been completed
245 ``cancel:before`` *cancellable*
247 Invoked before cancelling a pending edition, provided with the
248 same information as ``save:before``.
252 Invoked after a pending edition has been cancelled.
257 The list view has grown hooks for the ``keyup`` event on its edition
258 form (during edition): any such event bubbling out of the edition form
259 will be forwarded to a method ``keyup_EVENTNAME``, where ``EVENTNAME``
260 is the name of the key in ``$.ui.keyCode``.
262 The method will also get the event object (originally passed to the
263 ``keyup`` handler) as its sole parameter.
265 The base editable list view has handlers for the ``ENTER`` and
271 The list-edition modules does not generally interact with the embedded
272 formview, delegating instead to its
273 :js:class:`~openerp.web.list.Editor`.
275 .. js:class:: openerp.web.list.Editor(parent[, options])
277 The editor object provides a more convenient interface to form
278 views, and simplifies the usage of form views for semi-arbitrary
281 However, the editor does *not* task itself with being internally
282 consistent at this point: calling
283 e.g. :js:func:`~openerp.web.list.Editor.edit` multiple times in a
284 row without saving or cancelling each edit is undefined.
287 :type parent: :js:class:`~openerp.web.Widget`
288 :param EditorOptions options:
290 .. js:function:: openerp.web.list.Editor.isEditing
292 Indicates whether the editor is currently in the process of
293 providing edition for a field.
297 .. js:function:: openerp.web.list.Editor.edit(record, configureField)
299 Loads the provided record into the internal form view and
300 displays the form view.
302 Will also attempt to focus the first visible field of the form
305 :param Object record: record to load into the form view
306 (key:value mapping similar to the result
308 :param configureField: function called with each field of the
309 form view right after the form is
310 displayed, lets whoever called this
311 method do some last-minute
312 configuration of form fields.
313 :type configureField: Function<String, openerp.web.form.Field>
314 :returns: jQuery delegate to the form object
316 .. js:function:: openerp.web.list.Editor.save
318 Attempts to save the internal form, then hide it
320 :returns: delegate to the record under edition (with ``id``
321 added for a creation). The record is not updated
322 from when it was passed in, aside from the ``id``
325 .. js:function:: openerp.web.list.Editor.cancel
327 Attemps to cancel the edition of the internal form, then hide
330 :returns: delegate to the record under edition
332 .. js:class:: EditorOptions
334 .. js:attribute:: EditorOptions.formView
336 Form view (sub)-class to instantiate and delegate edition to.
338 By default, :js:class:`~openerp.web.FormView`
340 .. js:attribute:: EditorOptions.delegate
342 Object used to get various bits of information about how to
345 By default, uses the editor's parent widget. See
346 :js:class:`EditorDelegate` for the methods and attributes to
349 .. js:class:: EditorDelegate
351 Informal protocol defining the methods and attributes expected of
352 the :js:class:`~openerp.web.list.Editor`'s delegate.
354 .. js:attribute:: EditorDelegate.dataset
356 The dataset passed to the form view to synchronize the form
357 view and the outer widget.
359 .. js:function:: EditorDelegate.editionView(editor)
361 Called by the :js:class:`~openerp.web.list.Editor` object to
362 get a form view (JSON) to pass along to the form view it
365 The result should be a valid form view, see :doc:`Form Notes
366 <form-notes>` for various peculiarities of the form view
369 :param editor: editor object asking for the view
370 :type editor: :js:class:`~openerp.web.list.Editor`
374 .. js:function:: EditorDelegate.isPrependOnCreate
376 By default, the :js:class:`~openerp.web.list.Editor` will
377 append the ids of newly created records to the
378 :js:attr:`EditorDelegate.dataset`. If this method returns
379 ``true``, it will prepend these ids instead.
381 :returns: whether new records should be prepended to the
382 dataset (instead of appended)
388 * The editable listview behavior has been rewritten pretty much from
389 scratch, any code touching on editability will have to be modified
391 * The overloading of :js:class:`~openerp.web.ListView.Groups` and
392 :js:class:`~openerp.web.ListView.List` for editability has been
393 drastically simplified, and most of the behavior has been moved to
394 the list view itself. Only
395 :js:func:`~openerp.web.ListView.List.row_clicked` is still
398 * A new method ``getRowFor(record) -> jQuery(tr) | null`` has been
399 added to both ListView.List and ListView.Group, it can be called
400 from the list view to get the table row matching a record (if such
403 * ``ListView#ensure_saved`` has been re-capitalized to
404 :js:func:`~openerp.web.ListView.ensureSaved`
406 * :js:func:`~openerp.web.ListView.do_button_action`'s core behavior
407 has been split away to
408 :js:func:`~openerp.web.ListView.handleButton`. This allows bypassing
409 overrides of :js:func:`~openerp.web.ListView.do_button_action` in a
412 Ideally, :js:func:`~openerp.web.ListView.handleButton` should not be
415 * Modifiers handling has been improved (all modifiers information
416 should now be available through :js:func:`~Column.modifiers_for`,
417 not just ``invisible``)
419 * Changed some handling of the list view's record: a record may now
420 have no id, and the listview will handle that correctly (for new
421 records being created) as well as correctly handle the ``id`` being
424 * Extended the internal collections structure of the list view with
425 `#find`_, `#succ`_ and `#pred`_.
427 .. _#find: http://underscorejs.org/#find
429 .. _#succ: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:succ
431 .. _#pred: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html#v:pred