Open ERP Introduction History Technical view Architecture Installing OpenERP Database Creation Install/uninstall and upgrade

of modules

Introduction
ERP What is ERP? ERP is the acronym of Enterprise Resource Planning. ERP is just not only a software. ERP definition refers to both; ERP software and business strategies that implement ERP systems.ERP is one of the most widely implemented business software systems in a wide variety of industries and organizations. Enterprise resource planning (ERP) is an integrated computer-based system used to manage internal and external resources including tangible assets, financial resources, materials, and human resources. It is a software architecture whose purpose is to facilitate the flow of information between all business functions inside the boundaries of the organization and manage the connections to outside stakeholders. Built on a centralized database and normally utilizing a common computing platform, ERP systems consolidate all business operations into a uniform and enterprise wide system environment. ERP Purpose The main value ERP systems provide is the opportunity to integrate an entire organization. End to end business processes that were traditionally disjointed, now share information through a common database. The information flow is much more efficient in that there are clear lines of business processes across the enterprise. For example, in a horizontally integrated ERP system, a purchasing department would process a purchase order in a central database with a common General Ledger (GL). Both Accounts Payable and Receiving have access to the same GL so the data would be immediately available to them. There is no time lag, re-entry of information, or dependency on paper documents. By having a single point of entry the risk of inaccuracy in the end-to-end transaction is reduced, resulting in fewer reconciliation points. Additionally, the ERP systems of today provide utilities for vertical integration with suppliers and distributors. When properly implemented as part of a comprehensive transformation effort, ERP solutions can yield the following results: Reduced reliance on programmers to make software changes Integrated processes and information systems Consolidation and/or elimination of current systems Reduced complexity of application and technology portfolios Authoritative data source Reduced data redundancy and duplicative data entry More effective and efficient business processes

Intro to Open ERP Open ERP is Enterprise Resource Planning software. It provides a complete, integrated ERP solution for small and medium sized businesses and organizations. Open ERP includes financial and analytic accounting, warehouse and inventory management, sales and purchase management, customer and supplier relations management, association management, tasks automation, human resource management, marketing campaign, document management, help desk, e-commerce integration, and point of sale functionality. More details about various features maybe be found on the Open ERP Features webpage. Open ERP has enjoyed robust development and growth in recent years, as shown in this screencast about global Open ERP deployments. OpenERP is a popular and powerful Open Source enterprise resource management (ERP) system that includes over 300 modules you can configure for your specific purposes. Combining CRM capabilities with financial management, product inventory, human resource control, purchase management, sales management, and point-of-sale capabilities, OpenERP provides you a complete solution for managing your business.

History of Open ERP Open ERP– a fully featured, free and open source ERP software suite. But before describing the features of OpenERP there are some background points to make about the use of ERPs by enteprises and the scope of the post needs to be clarified. 2005- Debuted as Developer 2006- Development of various Modules 2007- Adapted by many mid-level companies and proved to be significative 2008- Tiny erp to Open ERP 2009- Updating with new modules as well as maintaining the existing modules. Many organisations, in the late nineties commissioned bespoke software to match their business processes. They worked from these processes and „computerised‟ them. Often as not the result amounted to a collection of Visual Basic forms which were (and often still are) very popular. However the following systemic problems emerged:

Process Freeze: being „fleet of foot‟ is intrinsic to successful trading so having business processes effectively frozen in time by bespoke software (which cannot easily be modified) is a very bad thing indeed; Over Elaboration: operatives in the field have much less interest in ERP than do the managers in the office! So any excuse not to complete a form or navigate a menu will do just fine. Things like „more than you need‟ or over complex menus and mandatory fields which no longer exist on the new product just stop folk from using the software; Use Anywhere: even SMEs operate in multiple countries on different computing platforms and increasingly require access away from the office. Risks and integration costs are important barriers to all the advantages you gain from such systems. That‟s why, today, few small- and medium-sized companies use ERP. In addition, the larger ERP vendors such as SAP, Microsoft and Oracle haven‟t been able to reconcile the power and comprehensive cover of an ERP system with the simplicity and flexibility wanted by the users. But this is exactly what small and medium enterprises are looking for. The development processes of open source software, and the new business models adopted by their developers, provide a new way of resolving such problems of cost and quality for this kind of enterprise software. To make an ERP system fully available to small and medium enterprise, cost reduction is the first priority. Open source software makes it possible to greatly reduce development costs by aggressive reuse of open source software libraries; to eliminate intermediaries (the distributors), with all of their expensive sales overhead; to cut out selling costs by free publication of the software; and to considerably reduce the marketing overhead. Since there is open interaction among thousands of contributors and partners working on the same project, the quality of the resulting software benefits greatly from the scrutiny. And you can‟t be everything at once: accountant, software developer, salesperson, ISO 9001 quality professional, specialist in agricultural products, expert in the customs and habits of pharmaceutical vendors, just as a start. Faced with these wide-ranging requirements, what could be better than a world network of partners and contributors? Everyone adds their own contribution according to their professional competence. But the real challenge of development is to make this solution simple and flexible, as well as complete. And to reach this level of quality you need a leader and co-ordinator who can organize all of these activities. So the development team of Tiny ERP, today called Open ERP, is responsible for most of the organization, synchronization and coherence of the software.

Technical view OpenERP is free and open source software written in the popular Python programming language. It uses GTK to create an attractive user front end and enterprise-class database PostgreSQL at back end. It has three main packages: OpenERP server, OpenERP desktop client and OpenERP Web Client. This means... OpenERP is a Client/Server system that works over a IP Network. OpenERP programming language is Python. OpenERP uses Object-Oriented technologies. OpenERP records its data with a PostgreSQL relational database.

OpenERP business objects are modelled with an Object Relational Mapping (ORM) system. OpenERP offers three Human Machine Interfaces (HMI) a GTK client, a QT client and a web client (eTiny). OpenERP uses ReportLab for report generation in (PDF). OpenERP uses XML for several purpose: describing data, view, reports, data transport (XML-RPC) OpenERP installation is relatively easy to setup. It took our engineers less than an hour to have the system up and running with sample data for a 'services' company installed. OpenERP provides a good range of alternative sample data packs for differnet companies. The desktop client works on Mac, Linux and Windows. The web-based client worked on every browser we tested. The first thing to appreciate is that OpenERP is modular. It has 300 modules to chose from out-ofthe-box and, of course, you are free to write your own. It follows that you can assemble what is effectively a bespoke package to meet your company's processes. OpenERP is a modern Enterprise Management Software, released under the AGPL license, and featuring CRM, HR, Sales, Accounting, Manufacturing, Inventory, Project Management etc..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 report generation 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. PostgreSQL, is an object-relational database management system (ORDBMS). As with many other open source programs, PostgreSQL is not controlled by any single company, but has a global community of developers and companies to develop it. It contains all of the databases, each of which contains all data and most elements of the Open ERP system configuration. Extensible Markup Language (XML) provides a foundation for creating documents and document systems. XML operates on two main levels: first, it provides syntax for document markup; and second, it provides syntax for declaring the structures of documents. XML is clearly targeted at the Web, though it certainly has applications beyond it. Users who have worked with HTML before should be able to learn the basics of XML without too much difficulty. XML's simplicity is its key selling point, perhaps even its strongest feature.

each of which contains all data and most elements of the Open ERP system configuration. because it‟s generally already installed on users‟ computers.Architecture OpenERP uses the well-known client-server paradigm. the Open ERP application server. Conversely you‟d be better off with the application client (called the GTK client because of the technology it‟s built with) if you‟re using a local server (such as in the same building). and a web interface is also accessible using any modern browser. which contains all of the enterprise logic and ensures that . The web client is also easier to maintain. or use an application client (the GTK client) installed on each computer. with different pieces of software acting as client and server depending on the desired configuration. In this case the GTK client will be more responsive. and you can use both on the same server at the same time.Client software OpenERP provides a thick desktop client (GTK+) on all platforms. The two methods of access give very similar facilities. Open ERP Architecture To access Open ERP you can: use a web browser pointed at the Open ERP client-web server. An Open ERP system is formed from three main components: the PostgreSQL database server. so more satisfying to use. which contains all of the databases. It‟s best to use the web browser if the Open ERP server is some distance away (such as on another continent) because it‟s more tolerant of time delays between the two than the GTK client is.

com.taktik.openerp./bzr_set. From the GTK client. and you should also check if there are more up to date instructions for the Ubuntu distribution as well.g. client. a separate application called the Open Object client-web. Database creation After installation. Synaptic on Ubuntu) Mac look online for package installers for the GTK client. and demo data can be included. openerp_ch01(Example) . You‟ll need to know your super administrator password for this – or you‟ll have to find somebody who does have it to create this seed database. devteam. Compilation tip: OpenERP being Python-based.com). . Each database has its own modules and config. 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 . Detailed instructions are given there for different distributions and releases. You also need to install the required dependencies (PostgreSQL and a few Python libraries – see documentation on doc. which enables you to connect to Open ERP from standard web browsers and is not needed when you connect using a GTK client. use File→Databases→New Database to create a new database (default super admin password is admin).openerp. Use the technique outlined in this section to create a new database. and separate installers for server. Package installation Windows all-in-one installer.py # fetch code and perform setup For information about installation on other distributions.g. visit the documentation section by following Product ‣ Documentation on http://www. run the server and the client. and webserver are on the website Linux openerp-server and openerp-client packages are available via corresponding package manager (e. the web server. Installing OpenERP OpenERP is distributed as packages/installers for most platforms. but can of course be installed from the source on any platform.be) Installing from source There are two alternatives: using a tarball provided on the website. This database will contain the demonstration data provided with Open ERP and a large proportion of the core Open ERP functionality. or directly getting the source using Bazaar (distributed Source Version Control).Open ERP runs optimally. as well as tutorials for installing the server (e.

The consequences of checking this box or not affect the whole use of this database. If you‟re using the web client. (In fact many people find it hard to resist admin as their password!) Wait for the message showing that the database has been successfully created. Start the database creation process from the Welcome page by clicking Databases and then completing the following fields on the Create new database form: Enter the super-administrator password. if you or your system administrator haven‟t changed it. Super admin password : by default it‟s admin . This makes your database quite secure because you can ensure that it is unique from the outset. but obviously completely insecure). Enter the super-administrator password. and the name of the new database you‟re creating. Default Language : English . Confirm password : admin . then the name of the new database you‟re creating. Failure to create a database . New database name : openerp_ch01 . along with the user accounts and passwords (admin/XXXX and demo/demo ). In both cases you‟ll also see that you can choose the Administrator password. Load Demonstration data checkbox: checked . In both cases you‟ll see a checkbox that determines whether you load demonstration data or not. choose Files -> Databases -> New database in the menu at the top left. Now you‟ve created this seed database you can extend it without having to know the super-administrator password. Administrator password : admin (because it‟s easiest to remember at this stage.Creating a New Database If you‟re using the GTK client.

2. click Start Configuration.first screen . At the Define Main Company step you could select your own Company Name and Currency. and you can add more details on the second tab Report Information including a logo that would appear on reports. starting with the menu layout Configuring a minimal database . At the Summary page you can go back to change details if you need.How do you know if you’ve successfully created your new database? You’re told if the database creation has been unsuccessful.first screen 1. In this test you should leave everything untouched for the moment and just click Next: you‟ll change them later. . You‟ll have to go through the Setup wizard in steps: Setting up a blank database . Select a profile : select Minimal Profile and click Next. If you have entered a database name using prohibited characters (or no name. 3. Configuration consists of a set of wizards that help you through options for the installed modules. you’ll be alerted by the dialog box Error during database creation! After a short delay you are connected to the new openerp_ch03 database as user adminwith the password you gave it. Click the Install button. Since you chose the minimal database hardly anything is installed so this is a very simple process at the moment. If you’ve entered the wrong super-administrator password or a name already in use (some names can be reserved without your knowledge). or too short a name) you will be alerted by the dialog box Bad database name! explaining how to correct the error. at the Installation done page. Finally. 4. and address details on the first tab General Information.

which would enable you to add other users.Configuring a minimal database . Choose View Mode : Extended Interface so that you can see everything and then click Set to save it. 3. 2. Click Skip Step to step over the next wizard.first screen 1. You‟ve now reached the end of the configuration so click Continue to start using the system as the Administrator as shown in the screenshot Starting the minimal database. At the first screen click Continue to go into the first wizard. Starting the minimal database .

But in general each user of the system is presented with a dashboard that‟s designed to show performance indicators and urgent documents that are most useful to someone of the user‟s position in the company. as shown in screenshot The Main Menu of the openerp_ch02 database: Two menus are available on the left: Partners. which is described in the next subsection of this chapter. This is a mandatory field. The Language field enables the user‟s working language to be changed. or to the same database as another user. just below you‟ll find information about the Request system. The Signature field gives the user a place for the signature attached to messages sent from within Open ERP. So it should currently be showing Welcome Administrator (unless you logged in as another user and it‟s reflecting the name of that user instead). All of the dates in the system are converted to the user‟s timezone automatically. a timezone. the Preferences toolbar to the top right. Preferences. The next element in the Toolbar is a link to Preferences. . You‟ll see how to assign dashboards to different users in a later chapter. You‟ll find a link to the Home page to its right. If your database is new it will say No request. Preferences toolbar When you‟re connected to Open ERP the Preferences toolbar indicates which user you‟re connected as. the main contents of the window with by the menu toolbar to the left: links generally line up on the right but there are none to show at the moment. It is only visible if you‟re logged into a database. This takes you to either the dashboard or the available menus. In the case of the openerp_ch02database so far the Home page is the Main Menu. This can be different from that of the server. The Requests link sits just below this toolbar. This page also gives you access to the super-administrator functions for managing databases on this server. About and Logout. The Logout link enables you to logout and return to the original login page. links to the Home page. But first the system must be loaded with other languages for the user to be able to choose an alternative. The About link gives information about the development of the Open ERP software and various links to other information. By clicking that link you reach a page where the current user can set their password.Once you‟re displaying the main menu you‟re able to see the following screen items. information about copyright and the database you‟re logged into at the bottom of the page. depending on the user configuration. You can then login to another database. You should take steps (perhaps written policies) to prevent users making these too trivial. You can click on that link to look at requests that have been sent to you at any time. Administration. links to the MAIN MENU and the SHORTCUTS. showing the user name. although might initially be set as blank. and a signature: The Password field gives the user the opportunity to change their own password. The Timezone setting indicates the user‟s location to Open ERP. a working language.

and process modules along with the sale module. You‟ll start by checking if there are any updates available online that apply to your initial installation. 9. The Scan for new modules window opens showing the addresses that Open ERP will look in for downloading new modules (known as the repositories). inventory control (the stock module). Search for the sale module then select it. Additional modules can also be loaded online from the official Open ERP site http://openerp. For example few modules are installed and explained below: product management (the product module). and can then be installed in a separate step. and updating existing ones. are automatically loaded during the initial installation of the system and can be updated online later. Many of these. the core modules. they‟re available on your computer for immediate installation. Click the name product in the list to display the product module in form view. When the System Upgrade form appears. sales management (the sale module). Click Check New Modules to start the download from the specified locations. to show it in form view. Use the menu Administration ‣ Modules Management ‣ Modules ‣ Uninstalled modules to show the list of all modules that are registered within Open ERP but as yet uninstalled. Then: 1. 4. These modules are inactive when they‟re loaded into the system. Then you‟ll install a CRM module to complete your existing database. 5. purchase management (the purchase module). too. Click the Search button at the top of the form to toggle back to the list view with search selection fields on it. rather than the list view that a search displays. mrp. Update Modules List Click Administration ‣ Modules Management ‣ Update Modules List to start the updating tool. Click Apply Scheduled Upgrades in the Action toolbar to the right. It won‟t matter in this chapter if you can‟t download anything.com. Although they‟re mostly not installed in your database at the outset. wait for System upgrade done to be displayed. Enter product into the Name field and click Filter to list the product module. review the list of Modules to update – it may be longer than you had expected. Click the Schedule for Installation button on the product module form. but some of the later chapters refer to modules that aren‟t part of the core installation and have to be obtained from a remote repository. then click Start Configuration on that form. accounting and finance (the account module). Click Start Upgrade.Installing New functionality All of Open ERP‟s functionality is contained in its many and various modules. Click the Dependencies tab to see that you‟ll automatically be loading the product. and now includes all the modules you need. because the dependencies themselves had their own dependencies. 2. . 7. Installing and configuring modules Open ERP contain many modules . When it‟s complete you‟ll see a New Modules window indicating how many new modules were downloaded and how many existing modules were updated. 3. as you did with product. stock. product and process are both already marked for installation as a result of the first steps. 8. 6. Click OK to return to the updated list. Return to the Module tab and then click its Schedule for Installation button.

Each of the modules that were installed has its own new tab . 3. Accept the initial set by clicking Set default behaviour. Accept the defaults for the Fiscal Year and choose the Charts of Account to be None then click Continue. You‟ve reached the end of this configuration stage so click Continue to continue using the system as the Administrator.Configuration is required for both the accounts setup and the sales defaults. Click Next and Previous to move between them. The selections you make determine how Open ERP‟s processes work by setting its default behaviour (although you can override any of them for any sales order. 2. You first reach a new tab Features that lists the new menus and views as shown in the figure The Features tab once a module is installed. The main menu now displays all of the menu items that were loaded by the modules you installed. 4.it‟s not only the one you see displayed in front of you. so you are not strictly bound by these defaults). The sales defaults are shown in the screenshot The module form once a module is installed. The module form once a module is installed . Click MAIN MENU to see this. 1. shown in the screenshot Continuing with the database after installing new modules.

categories. products . journals and accounts etc. It may be configuring the partners. .The Features tab once a module is installed Continuing with the database after installing new modules Data base is set by entering the necessary details required for the suitable module which is installed.

py 2..py create the Python file containing the objects create . The Modules . General structure of Tiny ERP XML files is more detailed in the section Data Loading Files XML. Profiles All the modules are located in the server/addons directory. Actions 2.File Structure Even though many modules exists. menu entries. wizards declaration. Once installed Open ERP has a modular structure that allows modules to be added as needed. __init__.Module Development. Wizards 3. XML Files 1. Open ERP is a Python based client/server program for Enterprise Resource Planning. 1. reports declaration.) optionally create reports. among which we can cite : initialization and demonstration data declaration. Open ERP currently uses XML-RPC for communication over a network. wizards and workflows declaration. .Files And Directories . reports.XML Files XML files located in the module directory are used to modify the structure of the database.. The following steps are necessary to create a new module: create a subdirectory in the server/addons directory create a module description file: __terp__. views declaration. They are used for many purposes. Menu Entries 3.xml files that download the data (views. The following section are only related to XML specific to actions. menu entries. workflows declaration. It consist of a client “openerp-client” and a server “openerp-server” while the persistence is provided by Postgresql. Files & Directories 1. Reports 4. Introduction 2. demo data. It is necessary for the developer to customize the module according to client requirements. . Look here if you are interested in learning more about initialization and demonstration data declaration XML files. wizards or workflows.py 3. __terp__. customers requirements will vary accordingly.

1. "version" : "1.osv class gp_website_country(osv.py and __terp.osv): _name = 'gp. "author" : "Softapps".py__ import module __terp.xml(interface file) Note – Only __init.py__ module. 2.website. But module. 3. 4.Basically four files are necessary to develop a module.py are default names used.1".boolean('Status').required=True).py__ { "name" : "City Details". __init.py and custom_view. "category" : "Intranet". "depends" : ["base"].py from osv import fields.xml". Let us develop simple city module.py__ __terp. "active": False.py(class file) custom_view. Sample programming lines are given below and its description of each files will be explained later. "update_xml" : [ "custom_view. 'active':fields. "init_xml" : []. } _defaults={ 'active': lambda *a: True } gp_website_country() . ]. size=64.char('Country' . __init.xml files can be changed according to the module work.country' _description = "Country Management" _columns = { 'name':fields. "installable": True } module.

actions.ui.<openerp> .city</field> <field name="type">tree</field> <field name="arch" type="xml"> .website.<record id="view_city_form" model="ir.<record id="action_city_form" model="ir.custom_view .city</field> <field name="type">form</field> .xml <?xml version="1.act_window"> <field name="name">Add City</field> <field name="type">ir.<field name="arch" type="xml"> .<form string="City Management"> <field name="country_id" required="1" select="1" /> <field name="state_id" required="1" select="1" /> <field name="name" required="1" /> <field name="active" select="1" /> </form> </field> </record> #####tree view .view"> <field name="name">view_city_form</field> <field name="model">gp.ui.actions.<tree string="City Management"> <field name="country_id" /> <field name="state_id" /> <field name="name" required="1" /> <field name="active" select="1" /> </tree> </record> ##### action .0" encoding="utf-8" ?> .form</field> </record> <menuitem action="action_city_form" id="menu_gp_city" name="City Management" parent="menu_group_website_root" sequence="1" /> </data> </opener> .<record id="view_city_tree" model="ir.website.city</field> <field name="view_type">form</field> <field name="view_mode">tree.act_window</field> <field name="res_model">gp.website.<data> <menuitem icon="terp-sale" id="menu_group_website_root" name="GPL Website" /> #####form view .view"> <field name="name">view_city_tree</field> <field name="model">gp.

py” file. description The module description (text). which must be in Python format. license The license of the module (default:GPL-2). This file must contain a Python dictionary with the following values: name The (Plain English) name of the module. and also to 2. author The author of the module.py file The __init__.py: import module OpenERP Module Descriptor File __terp__. So. is responsible to 1. version The version of the module. It needs to import the Python files that need to be loaded. you have to write one line in __init__. executed at the start of the program.py In the created module directory. determine the XML files that will be parsed during the initialization of the server. This file. website The website of the module.py The __init__.py file is. . containing the description of your objects.Python Module Descriptor File __init__. if you create a “module. determine the dependencies of the created module.py file. like any Python module. you must add a __terp__.

"author" : "Open". Open ERP XML File Format is detailed in this section.depends List of modules on which this module depends.xml".1"..xml". "update_xml" : ["product_data. Open ERP XML File Format is detailed in this section. "product_wizard. Example Here is an example of __terp__. "depends" : ["base". reports. .. active True or False (default: False). "version" : "1. update_xml List of . "category" : "Generic Modules/Inventory Control". installable True or False.xml files to load when the server is launched with the “–update=module” launched. "account"]. "product_view.py file for the product module { "name" : "Products & Pricelists". "installable": True.xml files to load when the server is launched with the “–init=module” argument.xml". "active": True } The files that must be placed in init_xml are the ones that relate to the workflow definition. "pricelist_view.xml"]. Filepaths must be relative to the directory where the module is. are in the base module. The base module must almost always be in the dependencies because some necessary data for the views. reports and wizards. "demo_xml" : ["product_demo. The files in update_xml concern: views. "init_xml" : []. "product_report.xml". Determines if the module is installable or not. data to load at the installation of the software and the data for the demonstrations. . Determines the modules that are installed on the database creation. Filepaths must be relative to the directory where the module is.xml"]. init_xml List of .

this parameter contains a list of resource ids on which the method must be applied. we will see how to define a new object.invoice object for the data concerning the invoices. If we talk in “object oriented” terms. For example. and we want to call the res_partner method “send_email”. For developers: Open ERP “objects” are usually called classes in object oriented programming.. etc. on which partner) the method must be applied. A Open ERP “resource” is usually called an object in OO programming. Precisely. we could also say that there is an object per level.. an Open ERP “resource” can be converted magically into a nice Python object using the “browse” class method (Open ERP object method)... The direct consequences is that all the methods of objects have a common parameter: the “ids” parameter. and Python is a fully object oriented language.partner object to manage all the partners and not a res. We have thus a res. an account.OpenERP Objects All the ERP‟s pieces of data are accessible through “objects”. Luckily. This specifies on which resources (for example. [1... instance of a class.partner object to access the data concerning the partners. Then. Please note that there is an object for every type of resource. there is a res. because the language used is Python. It‟s a bit confusing when you try to program inside Open ERP.. we will write something like: res_partner. we will check out the different methods of doing this.) We will see the exact syntax of object method calls further in this document. In the following section.partner object per partner.. As an example. .send_email(. and not an object per resource. . 5]. if we have two partners with the identifiers 1 and 5. and has objects and instances . .

.of. _constraints The constraints on the object. Setting _auto to False can be useful in case of Open ERP objects generated from PostgreSQL views.Models. See the constraints section for details... A Open-object is modeling by a static python description for his behavior and data. . OpenERP Object Attributes To define a new object. an a miror sql description for his data storage. “ORM” is the python class ancestor of all Open-objects. See the SQL constraints section for further details. This class must inherit from the osv class in the osv module. name_of_the_object() An object is defined by declaring some fields with predefined names in the class. ORM job is to fill the gap between Open-objects and sql tables. _columns (required) The object fields. you have to define a new Python class then instantiate it.the.. _sql_constraints The SQL Constraint on the object. Object Definition The first line of the object definition will always be of the form: class name_of_the_object(osv. The predefined fields are: _auto Determines whether a corresponding PostgreSQL table must be generated automatically from the object. } . Python is the programming langage giving the behavior and data description of Open-objects (This is not stored in the database). See the “Reporting From PostgreSQL Views” section for more details.ORM ORM is for Object-Relational Mapping. Two of them are required (_name and _columns).osv): _name = 'name.object' _columns = { . OpenERP modeling is based on “objects” but its data is stored in a classical relational database named Postgresql. the rest are optional. See the fields section for further details.

This list must be given in a python dictionary of the form: {„name_of_the_parent_object‟: „name_of_the_field‟.._defaults The default values for some of the object‟s fields. and the date of that last modification. the id of the user who last modified the record. See the object inheritance section (second form) for further details. If true. _order Name of the fields used to sort the results of the search and read methods. Default value: the value of the _name field above with the dots ( . See the default value section for details. create_date. . This data may be obtained by using the perm_read method. _log_access Determines whether or not the write access to the resource must be logged.. _sql SQL code executed upon creation of the object (only if _auto is True). Default value: „id‟. Note: by default. . four fields will be created in the SQL table: create_uid. Default value: None. write_uid. _name (required) Name of the object. Default value: None. write_date. _table Name of the SQL table. _sequence Name of the SQL sequence that manages the ids for this object. Those fields represent respectively the id of the user who created the record.}. ) replaced by underscores ( _ ). It means this code gets executed after the table is created. See the object inheritance section (first form) for further details. the creation date of record. _inherit The name of the osv object which the current object inherits from. Default value: „name‟. Default value: {}. Examples: _order = "name" _order = "date_order desc" _rec_name Name of the field in which the name of every resource is stored. the name_get method simply returns the content of this field. _inherits The list of osv objects the object inherits from.

float('Field Name' [. Syntax: fields. . integer: An integer. Optional Parameters]). size=n [. Syntax: fields. char: A string of limited length.integer('Field Name' [. false). Example: 'rate' : fields. Optional Parameters]). The required size parameter determines its size.boolean('Field Name' [.char('Field Name'. float: A floating point number. You should always use the digits parameter for monetary amounts. Optional Parameters]). Optional Parameters]). If the parameter digits is not present. digits=(12.Types of fields boolean: A boolean (true. the number will be a double precision floating point number. The scale being the number of digits after the decimal point whereas the precision is the total number of significant digits in the number (before and after the decimal point). # where ''n'' is an integer. Optional Parameters]).float('Relative Change rate'. Warning: these floating-point numbers are inexact (not any value can be converted to its binary representation) and this can lead to rounding errors.6) [. Syntax: fields. Syntax: fields. Note The optional parameter digits defines the precision and scale of the number.

. ('c'. required=True). ) Example Using relation fields many2one with selection. In fields definitions add: . text: A text field with no limit in length. Optional Parameters]). Syntax: fields. Optional Parameters]). datetime: Allows to store a date and the time of day in the same field. Syntax: fields.. binary: A binary chain selection: A field which allows the user to make a selection between various predefined values. Note Format of the selection parameter: tuple of tuples of strings of the form: (('key_or_value'.selection((('n'. Syntax: fields.'Confirmed')). Optional Parameters]). Optional Parameters]). size=30. 'string_to_display'). 'Field Name' [. date: A date.datetime('Field Name' [.char('City Name'. Syntax: fields.date('Field Name' [.Example: 'city' : fields.'Unconfirmed').text('Field Name' [..

required: True . 'Title'. cr. 'my_field': fields. r['name']) for r in res] return res Relational Types A one2one field expresses a one:to:one relation between two objects.(creates an index on the Foreign Key field) Example 'commercial': fields. ids.many2one('other..search(cr..select: True . Use many2one instead.relation.read(cr. "set null". . optional parameter) many2one: * Optional parameters: .name'. context) res = [(r['id']. 'Field Name') Associates this object to a parent object via this Field. ondelete='cascade'). .pool.many2one('mymodule. And then define the _sel_func like this (but before the fields definitions): def _sel_func(self.many2one('res. For example Department an Employee belongs to would Many to one.name'. + Predefined value: "cascade". one2one: Syntax: fields.object. uid. "set default" + Default value: "set null" .. i. It is deprecated.. 'id'].object. "no action".users'. 'Field Name'. "restrict". uid. []) res = obj.e Many employees will belong to a Department Syntax: fields. ['name'. context=None): obj = self.. 'Commercial'.one2one('other. uid.get('mymodule.relation.readonly: True ..ondelete: What should happen when the resource this field points to is deleted. selection=_sel_func)..model') ids = obj.model'.

id'.object.one2many('res.object. 'Categories'). many2many: Syntax: fields. 'actual.invisible: True/False . 'category_id'.category'.address'.many2many('actual.readonly: True/False Example 'address': fields.object. 'actual. 'Fieldname'.one2many('other.object.states: ? .name'.id'.object. 'Other Field Name').object.object. 'res_partner_category_rel'.id'.one2many: Syntax: fields. 'partner_id'.many2many( 'res. 'relation object'.id and other.object.object.object. } other_object_name2() .name' _columns = { 'other_fields': fields.object.partner. 'partner_id'. 'Field Name') Where o o o other.id'.id are the fields‟ names used in the relation table Example: 'category_ids': fields.osv): _inherit = 'other.partner.name'. 'other.many2many('other. 'Field relation id'. 'Contacts'). 'other. To make it bidirectionnal (= create a field in the other object): class other_object_name2(osv.name'. optional parameter) * Optional parameters: .name is the other object which belongs to the relation relation object is the table that makes the link actual. 'relation object'.

For example. relation="module. 'partner_id'. ids. type="many2one". 'Partners'). you can define a field as below in the City object: 'country_id': fields. store=False) Functional Field A functional field is a field whose value is calculated by a function (rather than being stored in the database).Example: class res_partner_category2(osv. cr. uid. If method is True. method whether the field is computed by a method (of an object) or a global function fnct is the function or method that will compute the field value. context) Either way.Country. 'res_partner_category_rel'. arg=None. store If you want to store field in database or not.State <.related('state_id'. It can be any field type name except function. fnct_search=None. its signature must be: def fnct(cr. It must have been declared before declaring the functional field. arg. . table. context) otherwise (if it is a global function). the signature of the method must be: def fnct(self..many2many('res. id‟_2_‟: value‟_2_‟. 'country_id'. string="Country". and you need to refer Country in a City. obj=None. 'category_id'. Parameters: fnct..partner. field_name. Default is False.osv): _inherit = 'res. fnct_inv_arg=None. supposing you have objects: City <..country". } res_partner_category2() Sometimes you need to refer the relation of a relation. fnct_inv=None.partner'.}.category' _columns = { 'partner_ids': fields. store=True where type is the field type name returned by the function. arg. type="float". ids. it must return a dictionary of values of the form {id‟_1_‟: value‟_1_‟. method=False. field_name.

required=True). it should be: def fnct(cr. arg.char('Contract Name'. name. ids.[1. } hr_contract() If we want to add a field that retrieves the function of an employee by looking its current contract. uid. field_value. cr. size=30.many2one('hr. context) fnct_search allows you to define the searching behaviour on that field. uid. If method is true. The object hr_employee is inherited this way: class hr_employee(osv. table. field_value. arg.3. cr. the signature of the method must be: def fnct(self. name.osv): _name = 'hr. obj.osv): _name = "hr. args) The return value is a list countaining 3-part tuplets which are used in search funtion: return [('id'. If method is true. required=True).employee" . the signature of the method must be: def fnct(self.many2one('res.The values of the returned dictionary must be of the type specified by the type argument in the field declaration.5])] Example Of Functional Field: Suppose we create a contract object which is : class hr_contract(osv. we use a functional field.employee" _description = "Employee" _inherit = "hr. obj.employee'. args) otherwise (if it is a global function). 'Employee'.contract' _description = 'Contract' _columns = { 'name' : fields.partner.'in'. fnct_inv is the function or method that will allow writing values in that field. 'function' : fields. field_name.function'. field_name. uid. ids. it should be: def fnct(cr. 'employee_id' : fields. context) otherwise (if it is a global function). 'Function').

. The code of this method is: def _get_cur_function_id(self. method=True.contract'.partner. type='many2one'. uid.function.id = c. } hr_employee() Note three points type =‟many2one‟ is because the function field must create a many2one field.function) WHERE (c.partner.function". We called our method _get_cur_function_id because its role is to return a dictionary whose keys are ids of employees.one2many('hr. string='Contract Function'). context): for i in ids: #get the id of the current function of the employee of identifier "i" sql_req= """ SELECT f. obj =”res. obj="res._columns = { 'contract_ids' : fields.function(_get_cur_function_id. 'function' : fields.execute(sql_req) sql_res = cr. 'Contracts').id AS func_id FROM hr_contract c LEFT JOIN res_partner_function f ON (f.employee_id = %d) """ % (i. function is declared as a many2one in hr_contract also. the value of sql_res[„func_id‟] will be None. and whose corresponding values are ids of the function of those employees. arg. field_name. ids. We force the False value in this case value because XML:RPC (communication between the server and the client) doesn‟t allow to transmit this value.dictfetchone() if sql_res: #The employee has one associated contract res[i] = sql_res['func_id'] else: #res[i] must be set to False and not to None because of XML:RPC # "cannot marshal None unless allow_none is enabled" res[i] = False return res The id of the function is retrieved using a SQL query. cr.) cr.function” is used to specify that the object to use for the many2one field is res.partner. Note that if the query returns no result. 'employee_id'.

osv): _name = "res.ids. method=True. 10).'res. type='many2one'.store={.pricelist.property( 'product. 'membership.partner" _columns = { 'property_product_pricelist': fields. selection=STATE.'+str(list0)"/> .. Property Fields¶ Declaring a property A property is a special field: fields. string='Current membership state'. 10).partner" _inherit = "res. ('name'. type='selection'.membership_line':(_get_partner_id. store={„object_name‟:(function_name. relation='product.uid. view_load=True. method=True.partner': (lambda self.pricelist'.function(_membership_state.'='. group_name="Pricelists Properties").'property_product_pricelist')]"/> <field name="value" eval="'product.[„field_name1‟. 'res.c={}:ids. store={'account.['state'].['state']. ['free_member']. Example In membership module: 'membership_state': fields. string="Sale Pricelist". } Then you have to create the default value in a ..'='.invoice':(_get_invoice_partner.‟field_name2‟].cr.property. 10)}).‟field2‟] on object „object_name‟ and output of the function will send as a parameter for main function of the field.XML file for this property: <record model="ir.partner'). class res_partner(osv.pricelist'.property" id="property_product_pricelist"> <field name="name">property_product_pricelist</field> <field name="fields_id" search="[('model'.} Enhancement: It will compute the field depends on other objects.priority)} It will call function function_name when any changes will be applied on field list Syntax: [„field1‟.

adding more features or data. others won‟t). so in the form a property is represented like a many2one function. Using properties or normal fields When you want to add a new feature. But the value of a property is stored in the ir.property class/table as a complete record. you will have to choose to implement it as a property or as normal field. If this object has no value. (It is rendered in the client like a separator tag).model. depending on the group_name attribute. The stored value is a field of type reference (not many2one) because each property may point to a different object. When you read a property. these are represented like a field of type reference. (some people will be able to change a specific property. In the definition of the property. the program gives you the property attached to the instance of object you are reading. you can use the ref function like this: <field name=”value” eval=“„product.</record> Tip if the default value points to a resource from another module. The type of this field is many2one. the system will give you the default property.data_id‟))”/> Putting properties in forms To add properties in forms.function and overrides the read and write method. The system will add properties depending on your rights. The definition of a property is stored in the ir.pricelist. If you edit properties values (from the administration menu). How does this work ? The fields.property class inherits from fields.fields class like any other fields. Use a property when the new feature is not related to the object but to an external concept. . Use a normal field when you inherit from an object and want to extend this object. just put the <properties/> tag in your form. This will automatically add all properties fields that are related to this object. you can add groups that are allowed to change to property. Properties are displayed by section.‟+str(ref(„module. Here are a few tips to help you choose between a normal field or a property: Normal fields extend the object.

product' _columns = { 'life_time': fields. both objects will depend on each other. product usetime.. Note One interesting thing is that properties avoid “spaghetti” code. these are not the same rights that are applied to partner objects.) Example 2: Product Times The product expiry module implements all delays related to products: removal date.integer('Product removal time').integer('Product alert time').integer('Product lifetime'). This module inherits from the product. If you add a field that points to an account in the partner object. This module is very useful for food industries. This is a multi-company field: the same partner may have different account receivable values depending on the company the user belongs to. there is one account chart per company. The default account receivable is the same for all partners and is configured from the general property menu (in administration). so it is an account property that is visible on a partner form.integer('Product usetime'). Rights have to be managed on this fields for accountants. The account receivable of a partner depends on the company it placed the sale order. 'removal_time': fields. It‟s much more difficult to maintain and code (for instance. } . try to remove a table when both tables are pointing to each others. .A property is a concept that is attached to an object and have special features: Different value for the same property depending on the company Rights management per field It‟s a link between resources (many2one) Example 1: Account Receivable The default “Account Receivable” for a specific partner is implemented as a property because: This is a concept related to the account chart and not to the partner. So you have specific rights just for this field of the partner form: only accountants may change the account receivable of a partner. In a multi-company system.osv): _inherit = 'product. But you can install the partner (base) module without the accounting module.product object and adds new fields to it: class product_product(osv.product' _name = 'product. The account module depends on the partner (base) module. 'alert_time': fields. 'use_time': fields..

get('res. context=None) Parameters: vals: a dictionary of values for every field. value). Returns: the id of the newly created resource.dbname). count=False) Parameters args: a list of tuples containing the search criteria.]. order=None. We did not use properties because: We extend a product. .get_pool(cr. Example: id = pooler. the life_time field is a concept related to a product. This list must be of the form: [(„name_of_the_field‟. not to another object. }. ORM methods create Description: Create a new resource Signature: def create(cr.. context=my_context) search Description: Search all the resources which satisfy certain criteria Signature: def search(self. We do not need a right management per field. . offset=0.. uid. vals.partner. 'partner_id': partner. The available operators are: . „operator‟. {'name': 'Email sent through mass mailing'. This dictionary must use this form: {„name_of_the_field‟: value.id. uid.event'). limit=2000. the different delays are managed by the same people that manage all products. context=None.create(cr. 'description': 'The Description for Partner Event'. uid.} context (optional.product object... args. cr.product_product() This module adds simple fields to the product. highly recommended): the actual context dictionary.

uid. ILIKE (sql) child_of offset (optional): do not return the “offset” first results. [('category_id'.=. <=.dbname). ['name'. fields (optional): the list of the interested fields.}. cr. cr. uid. highly recommended): the actual context dictionary. Returns: the list of ids of matching resources. <.search(cr. If a value is not provided for this parameter.'category_id'].] Example: values = pooler.. context=my_context) o o o o This example will return a list with all the partners that have the category „Customer‟.get('res. Returns: A list of dictionaries (a dictionary per resource asked) of the form [{„name_of_the_field‟: value. These object fields can be reached directly with the pointed notation (“object.get_pool(cr.read(cr. Signature: def read(self. fields=None. offset=0. ..partner').. Signature: def browse(self.get('res. ids. context (optional.get_pool(cr.name_of_the_field”). The “relations” fields are also automatically evaluated to allow you to recover the values in the “neighbors” objects. highly recommended): the actual context dictionary. 'Customer')]. context (optional. context=None) Parameters: ids: list of the identifiers of the resources to read (list of integers). '='. read Description: List of fields resources values. . limit (optional): maximum number of results to return. uid. >. Example: ids = pooler. context=None) .. uid. context=my_context) browse Description: Return one or several resources with the objects form. limit=2000.partner'). select. ids. the function will check all the fields.dbname). >= IN (sql) LIKE.

address‟).partner contains the field: 'bank':fields.partner‟) and of a partner contact (object „res.Parameters select: this parameter accept data of several types: o an integer : identifier of a resource o a list of integers (list of identifiers) offset (optional): the number of results to pass. to recover the two fields that interest us.partner. you have to write: name = addr_obj. Let‟s suppose that we know the identifier of a partner contact (name contact_id) and we want to recover his name and the account number of the company he works for. and the object res. uid. required=True). 'name': fields.partner.bank Note This method is only useful locally (on the server itself) and not with the other interfaces !! write Description: . return an object having the properties described here above. highly recommended): the actual context dictionary. size=64). limit (optional): the maximum number of results to return. contact_id) so. Knowing that the object res. Example: Let‟s consider the case of a partner (object „res.partner_id.address').char('Contact Name'.browse(cr.partner'.address contains the fields: 'partner_id': fields.char('Bank account'.get('res.pool.size=64). Returns: if an integer (identifier) has been passed as select parameter.many2one('res. if a list of integer (identifiers) has been passed. 'Partner'. return the object list. the most simple way to proceed is to use the browse method: addr_obj = self.name account_num = addr_obj.partner. context (optional.

context=my_context) unlink Description: Delete one or several resources Signature: def unlink(self.get('sale.}. vals. Returns: True Example: self.get('sale. uid. {'state':'cancel'}.. ids. fields. Returns: True Example: self. cr. uid.unlink(cr.order'). . This dictionary must be with the form: {„name_of_the_field‟: value.order').pool. ids.Writes values in one or several fields of one or several resources Signature: def write(self. form (optional): TODO . context=None) Parameters: ids: the resources identifiers list to modify. context=my_context) Methods to manipulate the default values¶ default_get Description: Get back the value by default for one or several fields. vals: a dictionary with values to write. form=None.uid. uid. highly recommended): the actual context dictionary.pool.. cr. context (optional. Signature: def default_get(self. ids. cr.write(cr. ids. context=None) Parameters: ids: the identifiers resources list to delete. highly recommended): the actual context dictionary. reference=None) Parameters: fields: the fields list which we want to recover the value by default. uid. context (optional.

ids) Parameters: ids: an integer list Returns: a list of dictionaries with the following keys Description: level : access level uid : user id gid : group id create_uid: user who created the resource create_date: date when the resource was created write_uid: last user who changed the resource write_date: date of the last change to the resource . ['product_id'. Signature: def default_set(self. . uid. cr. Returns: True Example: TODO Methods to manipulate the permissions perm_read Signature: def perm_read(self..analytic.timesheet').get('hr. cr. uid. for_user=False) Parameters: field: the name of the field that we want to change the value by default. for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users.reference (optional): TODO Returns: dictionary of the default values of the form {„field_name‟: value. field..default_get(cr. value: the value by default. } Example: self. value.pool. uid.'product_uom_id']) default_set Description: Change the default value for one or several fields.

cr. Returns: Example: self. self). context=None) Parameters: Description: context (optional.partner'). uid.get('res. if None. cr. uid. highly recommended): the actual context dictionary. fields = None.fields_get(cr. ids. ids. uid. fields.perm_write Signature: def perm_write(self. context) if 'communication2' in res: res['communication2'].setdefault('states'. cr. user. uid. context=None) Parameters: Description: fields: a list of fields that interest us. all the fields context (optional.perm_read(cr. context=my_context) Methods to generate the fields and the views fields_get Signature: def fields_get(self. highly recommended): the actual context dictionary.line in account_payment module def fields_get(self.pool. fields=None. Result: Example: In payment. True)] res['communication2']['states']['normal'] = [('readonly'. False)] return res . fields. {}) res['communication2']['states']['structured'] = [('readonly'. context=None): res = super(payment_line.

toolbar=False) Parameters: Description: context (optional. view_id=None.data'). ['membership_products_form'.get('ir. uid. view_id. toolbar) distinct_field_get Signature: def distinct_field_get(self. context. value. limit=2000) Description: Parameters: Result: Example: TODO . highly recommended): the actual context dictionary.view'). ('name'. read(cr. cr. view_type='form'.pool. view_type.pool. '='.'name']) dict_model={} for i in resource_id_form: dict_model[i['name']]=i['res_id'] if view_type=='form': view_id = dict_model['membership_products_form'] else: view_id = dict_model['membership_products_tree'] return super(Product.model. offset=0. user. 'membership_products_tree'])]) resource_id_form = self. 'in'. [('model'. user.self). view_id=None. user. search(cr. args=None.model_data_ids_form. context=None. context=None. view_type=‟form‟.user.get('ir.model.data').fields_view_get Signature: def fields_view_get(self. cr. Result: Example: In membership module [product.fields=['res_id'. cr.ui. uid.product]: def fields_view_get(self. 'ir.fields_view_get(cr. field. toolbar=False): if ('product' in context) and (context['product']=='membership_product'): model_data_ids_form = self.

Methods concerning the name of the resources name_get Signature: def name_get(self. ' addr += str(r['zip'] or '') + ' ' + str(r['city'] or '') res.address: def name_get(self.search(cr.partner.'city']): addr = str(r['name'] or '') if r['name'] and (r['zip'] or r['city']): addr += '. user. [('code'.append((r['id']. ids. '='. user. ids. addr)) return res name_search Signature: def name_search(self. cr. context=context) . cr. context=None) Description: Parameters: Result: a list of tuples of the form [(id. cr. args=None. name=''. user. user. operator=‟ilike‟. . context={}): if not len(ids): return [] res = [] for r in self. cr. limit=80): if not args: args=[] if not context: context={} ids = False if len(name) == 2: ids = self. name=‟„. uid. name)] + args. ids. args=None. uid.country: def name_search(self. limit=limit.read(cr.] Example: In res. context=None. name). operator='ilike'... context=None) Description: „Parameters: Result: Example: In res.'zip'. ['name'.

operator. [('name'. Fields are distributed on the screen following the rules below: By default. illustrate those 4 columns. There are two types of views: 1. or an “edition” field. name)] + args. and from top to bottom. with its name. Every screen is divided into 4 columns. user. They designate respectively the labels and their corresponding fields.search(cr. each column being able to contain either a label.name_get(cr. Fields are placed on the screen from left to right. there will be two fields (and their respective labels) on each line of the screen. form views 2. context=context) return self. context) Views and Events Views describe how each object (type of resource) is displayed. More precisely. As every edition field is preceded (by default) by a label with its name. ids. for each object.if not ids: ids = self. . we can define one (or several) view(s) to describe which fields should be drawn and how. tree views Form views The field disposition in a form view always follows the same principle. The green and red zones on the screen-shot below. limit=limit. according to the order in which they are declared in the view. each field is preceded by a label. user.

For example. .Views also support more advanced placement options: A view field can use several columns. on the screen-shot below. We will come back later on this note. the zone in the blue frame is. As we can see below in the purple zone of the screen. Precisely. We can also make the opposite operation: take a columns group and divide it in as many columns as desired. but let‟s note that it uses the whole width of the screen and not only one column. The surrounded green zones of the screen above are good examples. in fact. but contains 4 columns. the green framework up and on the right side takes the place of two columns. there is also a way to distribute the fields of an object on different tabs. the only field of a “one to many”.

.

Tree views These views are used when we work in list mode (in order to visualize several resources at once) and in the search screen. . These views are simpler than the form views and thus have less options.

which link actions to these views <menuitem> tags. </form> </field> </record> Default value for the priority field : 16...form</field> <field name="model">sale..view”. When not specified the system will use the view with the lower priority.order. New : You can now add shortcut using the shortcut tag. <record model="ir..ui. which create entries in the menu.ui..0"?> <openerp> <data> [view definitions] </data> </openerp> The view definitions contain mainly three types of tags: <record> tags with the attribute model=”ir..actions.. .act_window”.Design Elements The common structure to all the XML files of Tiny ERP is described in the DataLoadXML “Data Loading Using XML Files” section The files describing the views are also of the form: Example: <?xml version="1.view" id="v"> <field name="name">sale.order</field> <field name="priority" eval="2"/> <field name="arch" type="xml"> <form string="Sale Order"> . Example: <shortcut name="Draft Purchase Order (Proposals)" model="purchase..order" logins="demo" menu="m"/> Note that you should add an id attribute on the menuitem which is refered by menu attribute. which contain the view definitions themselves <record> tags with the attribute model=”ir. and link them with actions New : You can precise groups for whom the menu is accessible using the groups attribute in menuitem tag.

a frame will be drawn around the group of fields.. with a label containing the string..</notebook> Group <group>: groups several columns and split the group in as many columns as desired. the frame will be invisible. Notebook <notebook>: With notebooks you can distribute the view fields on different tabs (each one defined by a page tag)... Example: <group col="3" colspan="2"> <field name="invoiced" select="2"/> <button colspan="1" name="make_invoice" states="confirmed" string="Make Invoice" type="object"/> </group> Page Defines a new notebook page for the view.Grouping Elements Separator¶ Adds a separator line Example: <separator string="Links" colspan="4"/> The string attribute defines its label and the colspan attribute defines his horizontal size (in number of columns). Example: <page string="Order Line"> . </page>: . Example: <notebook colspan="4">. left. You can use the tabpos properties to set tab at: up. Otherwise. down. colspan: the number of columns to use rowspan: the number of rows to use expand: if we should expand the group or not col: the number of columns to provide (to its children) string: (optional) If set. right..

o Example: widget=”one2many_list”  one2one_list  one2many_list  many2one_list  many2many  url  email  image  float_time  reference mode: sequences of the views when switching. Note that this label is also used in the search view: see select attribute above). “*”.string: defines the name of the page. readonly=”1”: set the widget as read only required=”1”: the field is marked as required. required o Default value: {}.partner_id)]” widget: can change the widget. invisible.‟=‟.]}” o where attribute will be readonly.‟value‟). nolabel=”1”: hides the label of the field (but the field is not hidden in the search view).graph” on_change: define a function that is called when the content of the field changes.‟value‟)].‟value‟).product) . button and notebook tag also) o Format: “{„attribute‟:[(„field_name‟. domain: can restrict the domain.‟operator‟. invisible=”True”: hides both the label and the field. o Example: (in product. Data Elements Field attributes for the “field” tag select=”1”: mark this field as being one of the research criteria for this resource search view. group.‟operator‟. (It can be use on page.(„field_name‟. colspan=”4”: the number of columns on which a field must extend. ‟attribute2‟:[(„field_name‟. o Example: on_change=”onchange_partner(type. o Example: domain=”[(„partner_id‟. If a field is marked as required. This attribute supersede the required field value defined in the object. o Example: mode=”tree. password=”True”: replace field entry by asterisk.partner_id)” o See ViewsSpecialProperties for details attrs: Permits to define attributes of a field depends on other fields of the same window.‟operator‟. a user has to fill it the system won‟t save the resource if the field is not filled. string=”“: change the field label.

'partner')]" name="title"/> <field name="lang" select="2"/> <field name="supplier" select="2"/> </group> <notebook colspan="4"> <page string="General"> <field colspan="4" mode="form.tree" name="address" nolabel="1" select="1"> <form string="Partner Contacts"> <field name="name" select="2"/> <field domain="[('domain'. '='. Example: <?xml version="1.'='.form</field> <field name="model">res. This is the same object as the object shown on the screen shots of the presentation.0"?> <openerp> <data> <record id="view_partner_form" model="ir.view"> <field name="name">res. 3)" name="volume" attrs="{'readonly':[('type'. '='. 'contact')]" name="title"/> <field name="function"/> <field name="type" select="2"/> <field name="street" select="2"/> <field name="street2"/> <newline/> <field name="zip" select="2"/> <field name="city" select="2"/> <newline/> <field completion="1" name="country_id" select="2"/> <field name="state_id" select="2"/> <newline/> <field name="phone"/> <field name="fax"/> <newline/> <field name="mobile"/> <field name="email" select="2" widget="email"/> .partner</field> <field name="type">form</field> <field name="arch" type="xml"> <form string="Partners"> <group colspan="4" col="6"> <field name="name" select="1"/> <field name="ref" select="1"/> <field name="customer" select="1"/> <field domain="[('domain'.partner.'service')]}"/> eval: evaluate the attribute content as if it was Python code (see below for example) Example Here‟s the source code of the view of a sale order object.ui.<field digits="(14.

Purchases"> <separator string="General Information" colspan="4"/> <field name="user_id" select="2"/> <field name="active" select="2"/> <field name="website" widget="url"/> <field name="date" select="2"/> <field name="parent_id"/> <newline/> </page> <page string="History"> <field colspan="4" name="events" nolabel="1" widget="one2many_list"/> </page> <page string="Notes"> <field colspan="4" name="comment" nolabel="1"/> </page> </notebook> </form> </field> </record> <menuitem action="action_partner_form" id="menu_partner_form" parent="base. Example 1: <field name="value">2. Normally.3</field> This will evaluate to the string '2. This allows you to define values that are not strings.menu_base_partner" sequence="2"/> </data> </openerp> The eval attribute¶ The eval attribute evaluate its content as if it was Python code.</form> <tree string="Partner Contacts"> <field name="name"/> <field name="zip"/> <field name="city"/> <field name="country_id"/> <field name="phone"/> <field name="email"/> </tree> </field> <separator colspan="4" string="Categories"/> <field colspan="4" name="category_id" nolabel="1" select="2"/> </page> <page string="Sales &amp.3' and not the float 2. content inside <field> tags are always evaluated as strings.3 Example 2:<field name="value">False</field> .

you need to use the eval attribute: <field name="value" eval="2. If the states attribute is not given. ids. the button is always visible. string: define the button‟s label confirm: the message for the confirmation window. type: this attribute can have 3 values o “workflow” (value by default): the function to call is a function of workflow o “object”: the function to call is a method of the object o “action”: call an action instead of a function Example: <button name="order_confirm" states="draft" string="Confirm Order" icon="gtkexecute"/> Label Adds a simple label using the string attribute as caption. Eg: confirm=”Are you sure?” name: the name of the function to call when the button is pressed. wizards. it can trigger methods on the object. uid. In the case it‟s an object function. Example: <newline/> . workflow transitions or actions (reports. if needed.This will evaluate to the string 'False' and not the boolean False If you want to evaluate the value to a float. o cr is a database cursor o uid is the userID of the user who clicked the button o ids is the record ID list o **args is a tuple of additional arguments states: a comma-separated list of states (from the state field or from the workflow) in which the button must appear.3" /> <field name="value" eval="False" /> Button <button/>: add a button using the string attribute as label.). it must take 4 arguments: cr.. except string. When clicked.. Example: <label string="Test"/> New Line Force a return to the line even if all the columns of the view are not filled in. a boolean or another type. .

..analytic. cr. for_user=False) Parameters: field: the name of the field that we want to change the value by default.timesheet'). fields.. form (optional): TODO reference (optional): TODO Returns: dictionary of the default values of the form {„field_name‟: value. ids.. reference=None) Parameters: fields: the fields list which we want to recover the value by default.pool. other_field'_n_')"/> Getting Defaults Description: Get back the value by default for one or several fields.get('hr. . This method takes at least arguments: cr.'product_uom_id']) default_set Description: Change the default value for one or several fields. form=None. Signature: def default_set(self. } Example: self.default_get(cr. You can add parameters to the method.. which are the three classical arguments and also the context dictionary. uid. . field. uid. Signature: def default_get(self. uid.Events On Change The on_change attribute defines a method that is called when the content of a view field has changed. and must also be defined in the XML with fields defined this way: <field name="name_of_field" on_change="name_of_method(other_field'_1_'. cr. They must correspond to other fields defined in the view. value. ['product_id'. uid. .

STOCK_APPLY. STOCK_CLOSE. This identifier must be unique. STOCK_FLOPPY.value: the value by default. STOCK_ADD. STOCK_CUT. STOCK_EXECUTE. A menu item name with no slash in its text is a top level menu. STOCK_COLOR_PICKER. STOCK_GOTO_LAST. . name defines the position of the menu item in the menu hierarchy. STOCK_CANCEL. action specifies the identifier of the action that must have been defined in the action table (ir. STOCK_DIALOG_WARNING. STOCK_EDIT. Returns: True Example: TODO Menus Here‟s the template of a menu item : <menuitem id="menuitem_id" name="Position/Of/The/Menu/Item/In/The/Tree" action="action_id" icon="NAME_FROM_LIST" groups="groupname" sequence="<integer>"/> Where id specifies the identifier of the menu item in the menu items table. STOCK_FIND_AND_REPLACE. STOCK_DIRECTORY. STOCK_DIALOG_INFO. STOCK_COPY. STOCK_DIALOG_AUTHENTICATION. STOCK_DIALOG_QUESTION. “Human Resources” in Open ERP are defined). Mandatory field. STOCK_DELETE. for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users. Note that this field is not mandatory : you can define menu elements without associating actions to them. STOCK_DISCONNECT. STOCK_FILE. STOCK_BOLD. STOCK_CONVERT. icon specifies which icon will be displayed for the menu item using the menu item.act_window).actions. This is useful when defining custom icons for menu elements that will act as folders (for example this is how custom icons for “Projects”. STOCK_DND. STOCK_CLEAR. STOCK_CDROM. STOCK_GOTO_FIRST. The default icon is STOCK_OPEN. STOCK_GOTO_BOTTOM. STOCK_FIND. STOCK_DIALOG_ERROR. STOCK_CONNECT. STOCK_DND_MULTIPLE. o The available icons are : STOCK_ABOUT. Elements are separated by slashes (“/”). Mandatory field.

STOCK_UNDERLINE. the menu item gets a default sequence number of 10. STOCK_OPEN. STOCK_QUIT. STOCK_JUSTIFY_LEFT. terp-hr. STOCK_HARDDISK. STOCK_REFRESH. STOCK_SAVE_AS. STOCK_REVERT_TO_SAVED. STOCK_NETWORK. <menuitem name="Sales Management/Sales Order/Sales Order in Progress" id="menu_action_order_tree4" action="action_order_tree4"/> he actions define the behavior of the system in response to the actions of the users . STOCK_ZOOM_OUT. terp-partner. terp-project. STOCK_SELECT_COLOR. . STOCK_MEDIA_FORWARD. the downer the menu item. STOCK_PROPERTIES. STOCK_ZOOM_FIT. STOCK_MISSING_IMAGE.user”) sequence is an integer that is used to sort the menu item in the menu. STOCK_NO. STOCK_MEDIA_RECORD. Menu items with the same sequence numbers are sorted by order of creation (_order = “sequence. STOCK_JUMP_TO. There are different types of simple actions: Window: Opening of a new window Report: The printing of a report o Custom Report: The personalized reports o RML Report: The XSL:RML reports . terp-product.STOCK_REDO. terp-account. terp-crm. STOCK_PRINT. STOCK_SELECT_FONT. The higher the sequence number. STOCK_ZOOM_100. This argument is not mandatory: if sequence is not specified. terp-mrp.id“). STOCK_REMOVE. STOCK_SORT_DESCENDING. STOCK_SPELL_CHECK. double-click on an invoice. STOCK_MEDIA_PLAY. click on the action button. STOCK_INDEX.. STOCK_MEDIA_REWIND. STOCK_GO_BACK. STOCK_HOME. STOCK_ITALIC. STOCK_UNINDENT. STOCK_MEDIA_STOP.STOCK_GOTO_TOP. STOCK_INDENT. STOCK_GO_DOWN. STOCK_STRIKETHROUGH. login of a new user. terpadministration. terp-tools. STOCK_PREFERENCES. STOCK_JUSTIFY_FILL.‟ (example: groups=”admin. STOCK_STOP. terp-purchase. terp-sale. STOCK_HELP. See section ” Management of Access Rights” for more information. terp-report. STOCK_GO_FORWARD. STOCK_UNDELETE. STOCK_PASTE. Multiple groups should be separated by a „. STOCK_MEDIA_NEXT. STOCK_NEW. STOCK_SAVE. STOCK_GO_UP. STOCK_YES. STOCK_SORT_ASCENDING. STOCK_OK. STOCK_MEDIA_PREVIOUS. STOCK_PRINT_PREVIEW. STOCK_ZOOM_IN. terp-stock groups specifies which group of user can see the menu item (example : groups=”admin”). STOCK_UNDO. STOCK_JUSTIFY_RIGHT.. STOCK_JUSTIFY_CENTER. STOCK_MEDIA_PAUSE.

Reading of the action and execution of this one .Wizard: The beginning of a Wizard Execute: The execution of a method on the server side Group: Gather some actions in one group The actions are used for the following events. this action is: open the menu in the „Operations‟ section. Two examples: Opening of a window when double-clicking in the menu User connection Opening of the menu When the user open the option of the menu “Operations > Partners > Partners Contact”. Execution of the action 1. 2. If the action is the type Opening the Window. 1. the fields description and the XML view. 2. Reading of a user file to obtain ACTION_ID 2. The user clicks on the icon „print‟ or „action‟. Search the action in the IR. Example of events In Open ERP. the next steps are done to give the user information on the action to undertake. it indicates to the user that a new window must be opened for a selected object and it gives you the view (form or list) and the filed to use (only the pro-forma invoice). The user double-clicks on the menu. The steps are: 1. User connection. User connection When a new user is connected to the server. the client must search the action to use for the first screen of this user. all the actions are described and not configured. Generally. The user asks the object and receives information necessary to trace a form.

list of tuples. The domains are written in python. like) the tested value For example. =. even if they are not from a part of the domain will be posted if the user develop the branches of the tree. A form can be called by an action opening in „Tree‟ mode. The other resources. Actions are explained in more detail in section “Administration Modules .‟draft‟)] In the case of a simple view. in the invoice case. use the following domain. The form view is generally opened from the list mode (like if the user pushes on „switch view‟).‟=‟.act_window‟ View Ref The view used for showing the object Model The model of the object to post Type of View The type of view (Tree/Form) Domain Value The domain that decreases the visible data with this view The view The view describes how the edition form or the data tree/list appear on screen.actions. The tuples have three elements. if you want to obtain only „Draft‟ invoice. according to whether they represent a form for the edition or a list/tree for global data viewing. you can define an action that opens a view that shows only invoices not paid. Here‟s the template of an action XML record : . [(„state‟.Actions”. >.The fields Action Name The action name Action Type Always „ir. the domain define the resources which are the roots of the tree.(restriction) For example. the field on which the test must be done the operator used for the test (<. The views can be of „Form‟ or „Tree‟ type. The Domain This parameter allows you to regulate which resources are visible in a selected view.

the list view can be displayed by clicking the “alternate view button” . Context dictionaries are declared with the same syntax as Python dictionaries in the XML file. (version 5 introduced graph and calendar views) usage is used [+ *TODO* +] target the view will open in new window like wizard. They indicate at the user that he has to open a new window in a new „tab‟. the first defined view of a kind is used). It must be unique. If this field is not defined.form|form|tree</field> <field name="usage">menu</field> <field name="target">new</field> </record> Where id is the identifier of the action in the table “ir.form : the view is first displayed as a list. view_type is set to form when the action must open a new form view.name</field> <field name="view_id" ref="view_id_1"/> <field name="domain">["list of 3-tuples (max 250 characters)"]</field> <field name="context">{"context dictionary (max 250 characters)"}</field> <field name="res_model">Open. the form view can be displayed by clicking the “alternate view button” .act_window" id="action_id_1"> <field name="name">action. and is set to tree when the action must open a new tree view. and ignored otherwise. o tree. For more information about context dictionaries. context is the context dictionary which will be visible in the view that will be opened when the action is activated. Administration > Custom > Low Level > Base > Action > Window Actions .<record model="ir. res_model is the name of the object on which the action operates. name is the name of the action (mandatory). the view of a kind (list or form) associated to the object res_model with the highest priority field is used (if two views have the same priority. o tree : the view is displayed as a list and there is no way to switch to form view. o form : the view is displayed as a form and there is no way to switch to list view . domain is a list of constraints used to refine the results of a selection. and hence to get less records displayed in the view.act_window”.actions. view_mode is only considered if view_type is form. Constraints of the list are linked together with an AND clause : a record of the table will be displayed in the view only if all the constraints are satisfied.actions.tree|tree.tree : the view is first displayed as a form. The four possibilities are : o form. view_id is the name of the view to display when the action is activated.object</field> <field name="view_type">form|tree</field> <field name="view_mode">form. see section ” The context Dictionary”.

picking</field> <field name="res_model">stock.xml.picking</field> <field name="type">ir. '='.act_window</field> <field name="view_type">form</field> <field name="view_id" ref="view_picking_form"/> <field name="context">{'contact_display': 'partner'}</field> </record> . <record model="ir. uid)]</field> <field name="view_id" ref="view_my_project" /> </record> This action is declared in server/bin/addons/stock/stock_view.actions.project</field> <field name="res_model">project.act_window" id="action_picking_form"> <field name="name">stock.'='. ('manager'.actions. <record model="ir.actions.Examples of actions¶ This action is declared in server/bin/addons/project/project_view.project</field> <field name="view_type">tree</field> <field name="domain">[('parent_id'.act_window" id="open_view_my_project"> <field name="name">project.xml.False).

Url Action Here‟s an example of a .info.0"?> <openerp> <data> <wizard string="Employee Info" model="hr. Here‟s an example of a XML file that declares a RML report : <?xml version="1. also you can add wizard in menu using following xml entry <?xml version="1.info.0"?> <openerp> <data> <wizard string="Employee Info" model="hr.employee" name="employee.XML file that declares a wizard.order" name="sale_category.wizard" id="wizard_employee_info"/> <menuitem name="Human Resource/Employee Info" action="wizard_employee_info" type="wizard" id="menu_wizard_employee_info"/> </data> </openerp> Report Action Reports in Open ERP are explained in chapter “Reports Reporting”.employee" name="employee. See “Add A New Wizard” for more information about wizard XML.wizard" id="wizard_employee_info"/> </data> </openerp> A wizard is declared using a wizard tag.0"?> <openerp> <data> <report id="sale_category_print" string="Sales Orders By Categories" model="sale. <?xml version="1.print" rml="sale_category/report/sale_category_report.rml" menu="True" auto="False"/> .

RML report model. The different arguments of a report tag are : id : an identifier which must be unique. menu : whether the report will be able to be called directly via the client or not. string : the text of the menu that calls the report (if any. .RML file must be parsed using the default parser or not. Using a custom parser allows you to define additional functions to your report.</data> </openerp> A report is declared using a report tag inside a “data” block. model : the Open ERP object on which the report will be rendered. Setting menu to False is useful in case of reports called by wizards. Important Note : Path is relative to addons/ directory. see below). auto : determines if the . rml : the .

Sign up to vote on this title
UsefulNot useful