[ADD] extensions: add a custom example
admonition
closes odoo/documentation#1498 Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
This commit is contained in:
parent
2c7310a41f
commit
acda12669d
2
conf.py
2
conf.py
@ -112,7 +112,7 @@ extensions = [
|
|||||||
# Youtube and Vimeo videos integration (youtube, vimeo directives)
|
# Youtube and Vimeo videos integration (youtube, vimeo directives)
|
||||||
'embedded_video',
|
'embedded_video',
|
||||||
|
|
||||||
'exercise_admonition',
|
'custom_admonitions',
|
||||||
|
|
||||||
# Redirection generator
|
# Redirection generator
|
||||||
'redirects',
|
'redirects',
|
||||||
|
@ -26,7 +26,7 @@ Integrating messaging features to your model is extremely easy. Simply inheritin
|
|||||||
the ``mail.thread`` model and adding the messaging fields (and their appropriate
|
the ``mail.thread`` model and adding the messaging fields (and their appropriate
|
||||||
widgets) to your form view will get you up and running in no time.
|
widgets) to your form view will get you up and running in no time.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Let's create a simplistic model representing a business trip. Since organizing
|
Let's create a simplistic model representing a business trip. Since organizing
|
||||||
this kind of trip usually involves a lot of people and a lot of discussion, let's
|
this kind of trip usually involves a lot of people and a lot of discussion, let's
|
||||||
@ -200,7 +200,7 @@ The ``mail`` module adds a powerful tracking system on fields, allowing you
|
|||||||
to log changes to specific fields in the record's chatter. To add tracking
|
to log changes to specific fields in the record's chatter. To add tracking
|
||||||
to a field, simple set the tracking attribute to True.
|
to a field, simple set the tracking attribute to True.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Let's track changes on the name and responsible of our business trips:
|
Let's track changes on the name and responsible of our business trips:
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ can override the ``_track_subtype()`` function:
|
|||||||
:returns: a subtype's full external id or False if no subtype is triggered
|
:returns: a subtype's full external id or False if no subtype is triggered
|
||||||
|
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Let's add a ``state`` field on our example class and trigger a notification
|
Let's add a ``state`` field on our example class and trigger a notification
|
||||||
with a specific subtype when this field change values.
|
with a specific subtype when this field change values.
|
||||||
@ -422,7 +422,7 @@ The urls in the actions list can be generated automatically by calling the
|
|||||||
:returns: link of the type selected for the record
|
:returns: link of the type selected for the record
|
||||||
:rtype: str
|
:rtype: str
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Let's add a custom button to the Business Trip state change notification;
|
Let's add a custom button to the Business Trip state change notification;
|
||||||
this button will reset the state to Draft and will be only visible to a member
|
this button will reset the state to Draft and will be only visible to a member
|
||||||
@ -609,7 +609,7 @@ which means that while the alias is stored in another table, you have
|
|||||||
access to all these fields directly from your parent object. This allows
|
access to all these fields directly from your parent object. This allows
|
||||||
you to make your alias easily configurable from the record's form view.
|
you to make your alias easily configurable from the record's form view.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Let's add aliases on our business trip class to create expenses on the fly via
|
Let's add aliases on our business trip class to create expenses on the fly via
|
||||||
e-mail.
|
e-mail.
|
||||||
@ -738,7 +738,7 @@ and the specific widgets to display them (via the field ``activity_ids``) in the
|
|||||||
view and kanban view of your records (``mail_activity`` and ``kanban_activity``
|
view and kanban view of your records (``mail_activity`` and ``kanban_activity``
|
||||||
widgets, respectively).
|
widgets, respectively).
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
Organizing a business trip is a tedious process and tracking needed activities
|
Organizing a business trip is a tedious process and tracking needed activities
|
||||||
like ordering plane tickets or a cab for the airport could be useful. To do so,
|
like ordering plane tickets or a cab for the airport could be useful. To do so,
|
||||||
|
@ -165,7 +165,7 @@ into a compatible type:
|
|||||||
* :func:`~odoo.fields.Date.to_date` will convert to a :class:`datetime.date`
|
* :func:`~odoo.fields.Date.to_date` will convert to a :class:`datetime.date`
|
||||||
* :func:`~odoo.fields.Datetime.to_datetime` will convert to a :class:`datetime.datetime`.
|
* :func:`~odoo.fields.Datetime.to_datetime` will convert to a :class:`datetime.datetime`.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
To parse date/datetimes coming from external sources::
|
To parse date/datetimes coming from external sources::
|
||||||
|
|
||||||
@ -814,7 +814,7 @@ Domain criteria can be combined using logical operators in *prefix* form:
|
|||||||
Individual criterion generally have a negative form (e.g. ``=`` ->
|
Individual criterion generally have a negative form (e.g. ``=`` ->
|
||||||
``!=``, ``<`` -> ``>=``) which is simpler than negating the positive.
|
``!=``, ``<`` -> ``>=``) which is simpler than negating the positive.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
To search for partners named *ABC*, from belgium or germany, whose language
|
To search for partners named *ABC*, from belgium or germany, whose language
|
||||||
is not english::
|
is not english::
|
||||||
|
@ -980,7 +980,7 @@ take the following attributes:
|
|||||||
* ``plan``: If enabled and ``edit`` enabled, a "magnifying glass" button will be displayed
|
* ``plan``: If enabled and ``edit`` enabled, a "magnifying glass" button will be displayed
|
||||||
on time slots to plan unassigned records into that time slot.
|
on time slots to plan unassigned records into that time slot.
|
||||||
|
|
||||||
.. admonition:: Example
|
.. example::
|
||||||
|
|
||||||
When you do not want to create records on the gantt view and the beginning and end
|
When you do not want to create records on the gantt view and the beginning and end
|
||||||
dates are required on the model, the planning feature should be disabled
|
dates are required on the model, the planning feature should be disabled
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
""" Add a new "exercise" admonition directive. """
|
""" Add new custom admonition directives. """
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.parsers.rst.directives import admonitions
|
from docutils.parsers.rst.directives import admonitions
|
||||||
from sphinx.locale import admonitionlabels
|
from sphinx.locale import admonitionlabels
|
||||||
|
|
||||||
|
|
||||||
|
class example(nodes.Admonition, nodes.Element):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Example(admonitions.BaseAdmonition):
|
||||||
|
node_class = example
|
||||||
|
|
||||||
|
|
||||||
class exercise(nodes.Admonition, nodes.Element):
|
class exercise(nodes.Admonition, nodes.Element):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -14,6 +22,11 @@ class Exercise(admonitions.BaseAdmonition):
|
|||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
app.add_directive('example', Example)
|
||||||
|
app.add_node(example, html=(
|
||||||
|
lambda self, node: self.visit_admonition(node, 'example'),
|
||||||
|
lambda self, node: self.depart_admonition(node),
|
||||||
|
))
|
||||||
app.add_directive('exercise', Exercise)
|
app.add_directive('exercise', Exercise)
|
||||||
app.add_node(exercise, html=(
|
app.add_node(exercise, html=(
|
||||||
lambda self, node: self.visit_admonition(node, 'exercise'),
|
lambda self, node: self.visit_admonition(node, 'exercise'),
|
||||||
@ -26,4 +39,5 @@ def setup(app):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
admonitionlabels['example'] = 'Example'
|
||||||
admonitionlabels['exercise'] = 'Exercise'
|
admonitionlabels['exercise'] = 'Exercise'
|
@ -217,6 +217,7 @@ $brand-danger : #D9534F;
|
|||||||
|
|
||||||
$doc_paper_dark: $gray-lighter;
|
$doc_paper_dark: $gray-lighter;
|
||||||
$doc_paper: #ffffff;
|
$doc_paper: #ffffff;
|
||||||
|
$doc_example: #519161;
|
||||||
$doc_exercise: #938E94;
|
$doc_exercise: #938E94;
|
||||||
$doc_code-bg: #F8F8F8;
|
$doc_code-bg: #F8F8F8;
|
||||||
$doc_lime: #CDDC39;
|
$doc_lime: #CDDC39;
|
||||||
|
@ -938,13 +938,28 @@ header.o_main_header {
|
|||||||
border-color: $danger;
|
border-color: $danger;
|
||||||
|
|
||||||
> .alert-title, > h3 {
|
> .alert-title, > h3 {
|
||||||
color: darken($brand-danger,20%);
|
color: darken($brand-danger, 20%);
|
||||||
|
|
||||||
&:before {
|
&:before {
|
||||||
content: '#{$i-danger}';
|
content: '#{$i-danger}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.alert-example {
|
||||||
|
border-color: tint-color($doc_example, 30%);
|
||||||
|
background-color: tint-color($doc_example, 90%);
|
||||||
|
color: shade-color($doc_example, 35%);
|
||||||
|
|
||||||
|
> .alert-title, > h3 {
|
||||||
|
color: shade-color($doc_example, 35%);
|
||||||
|
}
|
||||||
|
|
||||||
|
> .alert-title:before, > h3:before {
|
||||||
|
content: '#{$i-knowledge}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&.alert-exercise {
|
&.alert-exercise {
|
||||||
border-color: tint-color($doc_exercise, 30%);
|
border-color: tint-color($doc_exercise, 30%);
|
||||||
background-color: tint-color($doc_exercise, 90%);
|
background-color: tint-color($doc_exercise, 90%);
|
||||||
|
@ -34,6 +34,7 @@ ADMONITION_MAPPING = {
|
|||||||
'danger': 'alert-danger',
|
'danger': 'alert-danger',
|
||||||
'error': 'alert-danger',
|
'error': 'alert-danger',
|
||||||
|
|
||||||
|
'example': 'alert-example',
|
||||||
'exercise': 'alert-exercise',
|
'exercise': 'alert-exercise',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user