Author: |
initOS GmbH |
License: |
no license |
Branch: |
7.0-add_web_listview_date_range_bar |
Repository: |
initOS/web |
Dependencies: |
web |
Languages: |
CSS (3, 2.6%),
JavaScript (50, 43.5%),
PO File (19, 16.5%),
Python (30, 26.1%),
and
XML (13, 11.3%) |
<img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.svg">
<a name="listview-date-range-bar"></a>
<h2>Listview date range bar.</h2>
<p>This module provides a new list view widget view mode 'listview_date_range_bar'
that adds a date range selector bar on top of your list view that allows you
to specifiy a date range for your list items.</p>
<a name="usage"></a>
<h2>Usage</h2>
<p>To use this module, you need to:</p>
<ul class="simple">
<li>To use this in your models list view set <code>listview_date_range_bar</code> as
view_mode for the window action that shows your view.</li>
<li>Everytime a date is changed a reload of the current content of the list view
is triggered.</li>
<li>The selected start and end dates are accessible in the context of the
<code>search()</code> function in your model and subsequently called functions like
<code>read()</code>.</li>
<li>To use the generic start/end dates from context to filter your model by
custom fields, override <code>search()</code> in your model and modify the domain with
the date range given in context before calling the super class <code>search()</code>.</li>
<li>The context fields to use are: <code>list_date_range_bar_start</code> /
<code>list_date_range_bar_end</code></li>
<li>By default the date fields are empty. If <code>list_date_range_bar_start</code>/
<code>list_date_range_bar_end</code> are already present in context when showing the
widget than their values are used to set the initial date range.</li>
</ul>
<a name="example"></a>
<h3>Example</h3>
<p>Your window action could look like:</p>
<pre>
<code><record id="my_view_id" model="ir.actions.act_window">
...
<field name="view_type">form</field>
<field name="view_mode">listview_date_range_bar</field>
...
</record></code>
</pre>
<p>Your models search function could look like this to filter on field <code>my_date</code>:</p>
<pre>
<code>def search(self, cr, user, args, offset=0, limit=None, order=None,
context=None, count=False):
date_start = context and context.get('list_date_range_bar_start')
if date_start:
args.append(('my_date','>=', date_start))
return super(my_model_class, self).\
search(cr, user, args, offset=offset, limit=limit, order=order,
context=context, count=count)</code>
</pre>
<a name="credits"></a>
<h2>Credits</h2>
<a name="contributors"></a>
<h3>Contributors</h3>
<ul class="simple">
<li>Peter Hahn <<a class="reference external" href="mailto:peter.hahn@initos.com">peter.hahn@initos.com</a>></li>
</ul>
<a name="maintainer"></a>
<h3>Maintainer</h3>
<a class="reference external image-reference" href="http://odoo-community.org"><img alt="Odoo Community Association" src="http://odoo-community.org/logo.png" /></a>
<p>This module is maintained by the OCA.</p>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>To contribute to this module, please visit <a class="reference external" href="http://odoo-community.org">http://odoo-community.org</a>.</p>