Openerp Technical Training v7 Exercises

  • View
    169

  • Download
    4

Embed Size (px)

Text of Openerp Technical Training v7 Exercises

  • Technical Training - ExercisesRelease 7.0

    OpenERP

    2013-01-21

    Contents

    1 Configuration 31.1 Open Source RAD with OpenObject . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.2 Installing OpenERP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    OpenERP Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.3 Package installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.4 Installing from source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    Typical bazaar checkout procedure (on Debian-based Linux) . . . . . . . . . . . . . . . . . . . . 41.5 Database creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    2 Build an OpenERP module 52.1 Composition of a module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2 Module Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.3 Object Service - ORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    Predefined osv.Model attributes for business objects . . . . . . . . . . . . . . . . . . . . . . . . . 62.4 ORM field types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    Common attributes supported by all fields (optional unless specified) . . . . . . . . . . . . . . . . 7Simple fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    2.5 Special/Reserved field names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.6 Actions and Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    3 Building views: basics 83.1 Generic view declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83.2 Tree views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3 Form views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    4 Relations between Objects 104.1 Relational fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    5 Inheritance 125.1 Inheritance mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    Predefined osv.Model attributes for business objects . . . . . . . . . . . . . . . . . . . . . . . . . 125.2 View inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

  • 2Domains . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    6 ORM Methods 136.1 Functional fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136.2 Onchange . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146.3 Predefined osv.Model attributes for business objects . . . . . . . . . . . . . . . . . . . . . . . . . 15

    7 Advanced Views 157.1 List & Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157.2 Calendars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167.3 Search Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167.4 Gantt Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177.5 (Charts) Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187.6 Kanban Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    8 Workflows 19

    9 Security 209.1 Group-based access control mechanisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209.2 Access rights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209.3 Record rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    10 Wizards 2110.1 Wizard objects (osv.TransientModel) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2110.2 Wizard execution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2210.3 Wizard views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    11 Internationalization 23

    12 Reporting 2312.1 Printed reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    Expressions used in OpenERP report templates . . . . . . . . . . . . . . . . . . . . . . . . . . . 24RML Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24WebKit reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    12.2 Dashboards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    13 WebServices 2513.1 XML-RPC Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2613.2 OpenERP Client Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

  • 3Based on a real case, this chapter covers: building an OpenERP module and its interface, Views,Reports, Workflows, Security aspects, Wizards, WebServices, Internationalization, Rapid ApplicationDevelopment (RAD) and Performance Optimization.

    1 Configuration

    1.1 Open Source RAD with OpenObject

    OpenERP is a modern Enterprise Management Software, released under the AGPL license, and featuring CRM,HR, Sales, Accounting, Manufacturing, Inventory, Project Management, ... It is based on OpenObject, a modular,scalable, and intuitive Rapid Application Development (RAD) framework written in Python.

    OpenObject features a complete and modular toolbox for quickly building applications: integrated Object-Relationship Mapping (ORM) support, template-based Model-View-Controller (MVC) interfaces, a reportgeneration system, automated internationalization, and much more.

    Python is a high-level dynamic programming language, ideal for RAD, combining power with clear syntax,and a core kept small by design.

    Tip:

    Useful links Main website, with OpenERP downloads: www.openerp.com Functional & technical documentation: doc.openerp.com Community resources: www.launchpad.net/openobject Integration server: demo.openerp.com Learning Python: doc.python.org OpenERP E-Learning platform: edu.openerp.com

    1.2 Installing OpenERP

    OpenERP is distributed as packages/installers for most platforms, but can of course be installed from the sourceon any platform.

    Note:

    The procedure for installing OpenERP is likely to evolve (dependencies and so on), so make sure to always checkthe specific documentation (packaged & on website) for the latest procedures. See http://doc.openerp.com/install.

    OpenERP Architecture

    OpenERP uses the well-known client-server paradigm, with different pieces of software acting as client and serverdepending on the desired configuration.

    OpenERP provides a web interface accessible using any modern browser.

  • 41.3 Package installation

    Windows All-in-one installer, and separate installers for server, client, and webserver are on the websiteLinux openerp-server and openerp-client packages are available via corresponding package manager

    (e.g. Synaptic on Ubuntu) OR using BaZaar bzr branch lp:openerp (or openerp/trunk for thetrunk version) when identified on Launchpad, then cd openerp (cd trunk in the trunk version)and ./bzr_set.py

    1.4 Installing from source

    There are two alternatives:

    1. using a tarball provided on the website, or

    2. directly getting the source using Bazaar (distributed Source Version Control).

    You also need to install the required dependencies (PostgreSQL and a few Python libraries - see documentationon doc.openerp.com).

    Note:

    OpenERP being Python-based, no compilation step is needed.

    Typical bazaar checkout procedure (on Debian-based Linux)

    $ sudo apt-get install bzr # install bazaar version control$ bzr branch lp:openerp # retrieve source installer$ cd openerp && python ./bzr_set.py # fetch code and perform setup

  • 51.5 Database creation

    After installation, run the server and the client. From the login screen of the web client, click on Manage Databasesto create a new database (default super admin password is admin). Each database has its own modules andconfiguration.

    Note:

    Demonstration data can also be included.

    2 Build an OpenERP module

    2.1 Composition of a module

    A module can contain the following elements :

    Business object : declared as Python classes extending the OpenObject class osv.Model, the persistence ofthese resource is completly managed by OpenObject,

    Data : XML/CSV files with meta-data (views and workflows declaration), configuration data (modulesparametrization) and demo data (optional bu recommended for testing),

    Wizards : stateful interactive forms used to assist users, often available as contextual actions on resources,

    Reports : RML (XML format). MAKO or OpenOffice report templates, to be merged with any kind ofbusiness data, and generate HTML, ODT or PDF reports.

    2.2 Module Structure

    Each module is contained in its own directory within either the server/bin/addons directory or anotherdirectory of addons, configured in server installation.

    Note:

    Configure addons locationsBy default, the only directory of addons known by the server is serv