From 0e74967b9a1c52e6a5c65e334e62f5e40884af70 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 25 Aug 2014 15:32:42 +0200 Subject: [PATCH] [IMP] doc/howtos/backend: finalize section on translations, and other small fixes --- doc/howtos/backend.rst | 47 ++++++++++-------------- doc/howtos/backend/exercise-translations | 39 ++++++++++++++++++++ doc/howtos/backend/series | 1 + 3 files changed, 60 insertions(+), 27 deletions(-) create mode 100644 doc/howtos/backend/exercise-translations diff --git a/doc/howtos/backend.rst b/doc/howtos/backend.rst index 8d89e22eb2a..10827ddd6a5 100644 --- a/doc/howtos/backend.rst +++ b/doc/howtos/backend.rst @@ -689,7 +689,8 @@ instead of a single view its ``arch`` field is composed of any number of .. exercise:: Alter existing content * Using model inheritance, modify the existing *Partner* model to add an - ``instructor`` boolean field + ``instructor`` boolean field, and a many2many field that corresponds to + the session-partner relation * Using view inheritance, display this fields in the partner form view .. only:: solutions @@ -1410,10 +1411,10 @@ the language and country combination when they differ (e.g. pt.po or pt_BR.po). Translations will be loaded automatically by Odoo for all enabled languages. Developers always use English when creating a module, then export the module terms using Odoo's gettext POT export feature -(Settings>Translations>Export a Translation File without specifying a -language), to create the module template POT file, and then derive the -translated PO files. Many IDE's have plugins or modes for editing and merging -PO/POT files. +(:menuselection:`Settings --> Translations --> Import/Export --> Export +Translation` without specifying a language), to create the module template POT +file, and then derive the translated PO files. Many IDE's have plugins or modes +for editing and merging PO/POT files. .. tip:: The GNU gettext format (Portable Object) used by Odoo is integrated into LaunchPad, making it an online collaborative @@ -1432,8 +1433,8 @@ PO/POT files. By default Odoo's POT export only extracts labels inside XML files or inside field definitions in Python code, but any Python string can be - translated this way by surrounding it with the tools.translate._ method - (e.g. _(‘Label') ) + translated this way by surrounding it with the function :func:`openerp._` + (e.g. ``_("Label")``) .. exercise:: Translate a module @@ -1446,8 +1447,8 @@ PO/POT files. #. Install whichever language you want ( :menuselection:`Administration --> Translations --> Load an Official Translation`) - #. Synchronize translatable terms (:menuselection`Administration --> - Translations --> Application termsn --> Synchronize Translations`) + #. Synchronize translatable terms (:menuselection:`Administration --> + Translations --> Application Terms --> Synchronize Translations`) #. Create a template translation file by exporting ( :menuselection:`Administration --> Translations -> Import/Export --> Export Translation`) without specifying a language, save in @@ -1460,20 +1461,13 @@ PO/POT files. dedicated PO-file editor e.g. POEdit_ and translate the missing terms - .. note:: - - By default, Odoo's export only extracts labels inside XML - records or Python field definitions, but arbitrary Python - strings can be marked as translatable by calling - :func:`openerp._` with them e.g. ``_("Label")``) - #. Add ``from openerp import _`` to ``course.py`` and mark missing strings as translatable - .. todo:: there isn't any! - #. Repeat steps 3-6 + .. patch:: + .. todo:: do we never reload translations? @@ -1483,7 +1477,7 @@ Reporting Printed reports --------------- -Odoo v8 comes with a new report engine based on :ref:`reference/qweb`, +Odoo 8.0 comes with a new report engine based on :ref:`reference/qweb`, `Twitter Bootstrap`_ and Wkhtmltopdf_. A report is a combination two elements: @@ -1576,16 +1570,15 @@ WebServices The web-service module offer a common interface for all web-services : -• SOAP -• XML-RPC -• NET-RPC +- XML-RPC +- JSON-RPC Business objects can also be accessed via the distributed object mechanism. They can all be modified via the client interface with contextual views. -Odoo is accessible through XML-RPC interfaces, for which libraries exist in -many languages. +Odoo is accessible through XML-RPC/JSON-RPC interfaces, for which libraries +exist in many languages. XML-RPC Library --------------- @@ -1667,10 +1660,10 @@ server with the library xmlrpclib. * https://github.com/nicolas-van/openerp-client-lib * https://pypi.python.org/pypi/oersted/ -.. [#autofields] it is possible to :attr:`disable the creation of some - ` +.. [#autofields] it is possible to :attr:`disable the automatic creation of some + fields ` .. [#rawsql] writing raw SQL queries is possible, but requires care as it - bypasses all Odoo authentication and security mechanisms. + bypasses all Odoo authentication and security mechanisms. .. _database index: http://use-the-index-luke.com/sql/preface diff --git a/doc/howtos/backend/exercise-translations b/doc/howtos/backend/exercise-translations new file mode 100644 index 00000000000..2fc98d04561 --- /dev/null +++ b/doc/howtos/backend/exercise-translations @@ -0,0 +1,39 @@ +Index: doc-backend/openacademy/models.py +=================================================================== +--- doc-backend.orig/openacademy/models.py 2014-08-25 14:43:52.288143046 +0200 ++++ doc-backend/openacademy/models.py 2014-08-25 14:49:46.148137793 +0200 +@@ -1,7 +1,7 @@ + # -*- coding: utf-8 -*- + + from datetime import timedelta +-from openerp import models, fields, api, exceptions ++from openerp import models, fields, api, exceptions, _ + + class Course(models.Model): + _name = 'openacademy.course' +@@ -85,15 +85,15 @@ + if self.seats < 0: + return { + 'warning': { +- 'title': "Incorrect 'seats' value", +- 'message': "The number of available seats may not be negative", ++ 'title': _("Incorrect 'seats' value"), ++ 'message': _("The number of available seats may not be negative"), + }, + } + if self.seats < len(self.attendee_ids): + return { + 'warning': { +- 'title': "Too many attendees", +- 'message': "Increase seats or remove excess attendees", ++ 'title': _("Too many attendees"), ++ 'message': _("Increase seats or remove excess attendees"), + }, + } + +@@ -135,4 +135,4 @@ + @api.constrains('instructor_id', 'attendee_ids') + def _check_instructor_not_in_attendees(self): + if self.instructor_id and self.instructor_id in self.attendee_ids: +- raise exceptions.ValidationError("A session's instructor can't be an attendee") ++ raise exceptions.ValidationError(_("A session's instructor can't be an attendee")) diff --git a/doc/howtos/backend/series b/doc/howtos/backend/series index 85755e5ee47..0206331ebaa 100644 --- a/doc/howtos/backend/series +++ b/doc/howtos/backend/series @@ -31,5 +31,6 @@ exercise-state-workflow-automatic exercise-state-workflow-actions exercise-access-rights exercise-access-rules +exercise-translations exercise-report exercise-dashboard