[ADD] reuse of existing openerp stuff

This commit is contained in:
Xavier Morel 2014-04-15 17:36:08 +02:00
parent 9cefa76988
commit ddf24b3ab6
7 changed files with 174 additions and 1 deletions

View File

@ -473,11 +473,92 @@ fix this, we have to create an explicit list view for lectures:
.. todo:: link to list view documentation
.. todo:: have lectures extend events -> reuse in OpenERP?
Reusing and customizing existing work
-------------------------------------
OpenERP and its standard modules provide a number of models which may already
solve your problem or part of your problem. Part of being a good OpenERP
developer is having an idea of existing models and how they can be retrofit
to your purposes.
For our courses, instead of developing teaching assistants and lectures from
scratch we could reuse existing OpenERP *users* (for teaching assistants) and
*events* (for lectures)\ [#bonus]_, as well as the built-in website support
for events.
Install ``website_event`` (which will also install ``events``) by restarting
the server as:
.. code-block:: console
$ ./openerp-server --addons-path=../web/addons,../addons,../my-modules \
-d academy -i website_event --db-filter=academy
We'll also add it as a dependency to our module:
.. patch::
Reload `your openerp`_, click on the new :menuselection:`Events` item which
was added to the menu. This will be our new lectures page, but there are a few
adaptations to perform
Fixing the menu
~~~~~~~~~~~~~~~
The menu title is currently a generic *Events*, we only want lectures so we
will rename it to *Lectures*. Website menu items are defined through the
``website.menu`` model, *Events* is defined by ``website_event`` and has the
external id ``website_event.menu_events``, renaming it is as simple as
overwriting the ``name`` field for that record:
.. patch::
Restart the server with
.. code-block:: console
$ ./openerp-server --addons-path=../web/addons,../addons,../my-modules \
-d academy -i academy --db-filter=academy
and the menu item has been renamed to Lectures.
Removing the sidebar
~~~~~~~~~~~~~~~~~~~~
The filters sidebar is not necessary for our lectures. It can be removed in
the UI via :menuselection:`Customize --> Filters` (and new filters can be
added to the current filtering by date). Template customization is done by
adding and removing extension views, so much like the renaming of the menu,
we simply need to find the right record (here the Filters template view
extending the basic event page) and set its value correctly:
.. todo:: documentation for view inheritance/in-place extension
.. patch::
Note that the option is still available in :menuselection:`Customize`, we
have merely flipped the default around.
Simplifying templates
~~~~~~~~~~~~~~~~~~~~~
There are still two things to fix in the lectures list. First, remove the
*Our Events* link in the top-left corner, simply replace the breadcrumb
element by nothing:
.. patch::
Second, remove the "organized by" and type rows in the event's description,
keep only the datetime and location:
.. patch::
.. [#taprofile] the teaching assistants profile view ends up broken for now,
but don't worry we'll get around to it
.. [#bonus] as a bonus, we get access rights and TA access to the
administrative backend "for free"
.. _bootstrap: http://getbootstrap.com
.. _converter pattern:

View File

@ -0,0 +1,15 @@
# HG changeset patch
# Parent a86395d8fd5fba9d902c6796a991ffd6e414d1c5
diff -r a86395d8fd5f -r 01f5cbb40de0 data/records.xml
--- a/data/records.xml Tue Apr 15 16:19:30 2014 +0200
+++ b/data/records.xml Tue Apr 15 16:19:47 2014 +0200
@@ -3,5 +3,9 @@
<record id="website_event.menu_events" model="website.menu">
<field name="name">Lectures</field>
</record>
+
+ <record id="website_event.event_left_column" model="ir.ui.view">
+ <field name="inherit_id" eval="False"/>
+ </record>
</data>
</openerp>

View File

@ -0,0 +1,14 @@
# HG changeset patch
# Parent 6a562e55935fe44a57220b0dcd9c389aa0b39e7e
diff -r 6a562e55935f -r a5a363ca0a78 __openerp__.py
--- a/__openerp__.py Mon Apr 14 17:04:36 2014 +0200
+++ b/__openerp__.py Tue Apr 15 16:03:34 2014 +0200
@@ -15,7 +15,7 @@
'version': '0.1',
# any module necessary for this one to work correctly
- 'depends': ['website'],
+ 'depends': ['website', 'website_event'],
'data': [
'security/ir.model.access.csv',
'views/templates.xml',

View File

@ -0,0 +1,26 @@
# HG changeset patch
# Parent a5a363ca0a784718f504d476d18e8ad4b0f4ec24
diff --git a/__openerp__.py b/__openerp__.py
--- a/__openerp__.py
+++ b/__openerp__.py
@@ -19,6 +19,7 @@
'data': [
'security/ir.model.access.csv',
'views/templates.xml',
+ 'data/records.xml',
'data/views.xml',
],
'demo': [
diff --git a/data/records.xml b/data/records.xml
new file mode 100644
--- /dev/null
+++ b/data/records.xml
@@ -0,0 +1,7 @@
+<openerp>
+ <data noupdate="1">
+ <record id="website_event.menu_events" model="website.menu">
+ <field name="name">Lectures</field>
+ </record>
+ </data>
+</openerp>

View File

@ -0,0 +1,14 @@
# HG changeset patch
# Parent 01f5cbb40de08d2a195c6a2ac3310efdbd3e1cbd
diff -r 01f5cbb40de0 -r eb4fbe025c90 views/templates.xml
--- a/views/templates.xml Tue Apr 15 16:19:47 2014 +0200
+++ b/views/templates.xml Tue Apr 15 17:11:13 2014 +0200
@@ -66,5 +66,8 @@
</t>
</template>
+<template id="remove_events_breadcrumb" inherit_id="website_event.index">
+ <xpath expr="//ol[hasclass('breadcrumb')]" position="replace"/>
+</template>
</data>
</openerp>

View File

@ -16,3 +16,8 @@ data-to-demo
lectures-action-and-menus
field-label
lecture-view-list
events-dependency
events-menu-rename
disable-events-filters
events-remove-breadcrumbs
simplify-lectures-list

View File

@ -0,0 +1,18 @@
# HG changeset patch
# Parent eb4fbe025c90df79b12a3fb18bf884c6c169e652
diff -r eb4fbe025c90 -r 30b20b46dbb2 views/templates.xml
--- a/views/templates.xml Tue Apr 15 17:11:13 2014 +0200
+++ b/views/templates.xml Tue Apr 15 17:21:18 2014 +0200
@@ -66,8 +66,11 @@
</t>
</template>
-<template id="remove_events_breadcrumb" inherit_id="website_event.index">
+<template id="simplify_events_list" inherit_id="website_event.index">
<xpath expr="//ol[hasclass('breadcrumb')]" position="replace"/>
+ <xpath expr="//ul[hasclass('media-list')]/li/div/div[1]" position="replace"/>
+ <xpath expr="//ul[hasclass('media-list')]/li/div/div[hasclass('text-muted')]" position="replace"/>
</template>
+
</data>
</openerp>