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

of modules

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.

The web client is also easier to maintain. Open ERP Architecture To access Open ERP you can: use a web browser pointed at the Open ERP client-web server. and a web interface is also accessible using any modern browser. or use an application client (the GTK client) installed on each computer. so more satisfying to use.Client software OpenERP provides a thick desktop client (GTK+) on all platforms. because it‟s generally already installed on users‟ computers. 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). each of which contains all data and most elements of the Open ERP system configuration.Architecture OpenERP uses the well-known client-server paradigm. which contains all of the enterprise logic and ensures that . An Open ERP system is formed from three main components: the PostgreSQL database server. The two methods of access give very similar facilities. 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. 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. the Open ERP application server. which contains all of the databases.

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

Confirm password : admin . (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. Administrator password : admin (because it‟s easiest to remember at this stage. Load Demonstration data checkbox: checked . This makes your database quite secure because you can ensure that it is unique from the outset.Creating a New Database If you‟re using the GTK client. Now you‟ve created this seed database you can extend it without having to know the super-administrator password. If you‟re using the web client. and the name of the new database you‟re creating. The consequences of checking this box or not affect the whole use of this database. Super admin password : by default it‟s admin . Default Language : English . In both cases you‟ll also see that you can choose the Administrator password. New database name : openerp_ch01 . In both cases you‟ll see a checkbox that determines whether you load demonstration data or not. 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. along with the user accounts and passwords (admin/XXXX and demo/demo ). Failure to create a database . but obviously completely insecure). Enter the super-administrator password. then the name of the new database you‟re creating. choose Files -> Databases -> New database in the menu at the top left.

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

At the first screen click Continue to go into the first wizard. 3.first screen 1. Choose View Mode : Extended Interface so that you can see everything and then click Set to save it. 2. 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.Configuring a minimal database . Click Skip Step to step over the next wizard. which would enable you to add other users. Starting the minimal database .

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

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

Click MAIN MENU to see this. The sales defaults are shown in the screenshot The module form once a module is installed. Each of the modules that were installed has its own new tab . The main menu now displays all of the menu items that were loaded by the modules you installed. The module form once a module is installed . 3. 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. 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. 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. 4. so you are not strictly bound by these defaults). 2.Configuration is required for both the accounts setup and the sales defaults. Accept the initial set by clicking Set default behaviour. shown in the screenshot Continuing with the database after installing new modules. Click Next and Previous to move between them.‟s not only the one you see displayed in front of you.

It may be configuring the partners. . products .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. categories. journals and accounts etc.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

'employee_id'. context): for i in ids: #get the id of the current function of the employee of identifier "i" sql_req= """ SELECT f.contract'.function. arg. cr.partner.partner. . obj="res.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. = c. the value of sql_res[„func_id‟] will be None. The code of this method is: def _get_cur_function_id(self.function) WHERE (c._columns = { 'contract_ids' : fields. 'function' : fields. 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. method=True.) cr. uid.execute(sql_req) sql_res = cr.employee_id = %d) """ % (i.one2many('hr.function” is used to specify that the object to use for the many2one field is res. ids.partner. 'Contracts'). and whose corresponding values are ids of the function of those employees.function(_get_cur_function_id. Note that if the query returns no result. We called our method _get_cur_function_id because its role is to return a dictionary whose keys are ids of employees.function".id AS func_id FROM hr_contract c LEFT JOIN res_partner_function f ON (f. string='Contract Function'). } hr_employee() Note three points type =‟many2one‟ is because the function field must create a many2one field. function is declared as a many2one in hr_contract also. type='many2one'. obj =”res.

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

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

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

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

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

partner. and the object res. highly recommended): the actual context Note This method is only useful locally (on the server itself) and not with the other interfaces !! write Description: .partner'. Returns: if an integer (identifier) has been passed as select parameter. 'Partner'. 'name': fields. to recover the two fields that interest us. context (optional. if a list of integer (identifiers) has been passed.partner. return an object having the properties described here above. 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. you have to write: name = addr_obj.browse(cr.partner_id.address‟). the most simple way to proceed is to use the browse method: addr_obj = self.address contains the fields: 'partner_id': fields. size=64).pool.address').many2one('res.partner‟) and of a partner contact (object „res. required=True).get('res. Knowing that the object account_num = addr_obj.char('Contact Name'.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. return the object list.size=64). uid.char('Bank account'.partner contains the field: 'bank':fields. Example: Let‟s consider the case of a partner (object „res. contact_id) so. limit (optional): the maximum number of results to return.

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

value. cr.get('hr. value: the value by default. uid.'product_uom_id']) default_set Description: Change the default value for one or several fields. for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users.analytic. 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 . cr. } Example: self..default_get(cr. Signature: def default_set(self.pool. uid. Returns: True Example: TODO Methods to manipulate the permissions perm_read Signature: def perm_read(self..timesheet').reference (optional): TODO Returns: dictionary of the default values of the form {„field_name‟: value. field. . ['product_id'. uid. for_user=False) Parameters: field: the name of the field that we want to change the value by default.

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

view_type. context=None. 'in'. cr. field. context=None. search(cr. Result: Example: In membership module [product.ui.get('ir. toolbar=False): if ('product' in context) and (context['product']=='membership_product'): model_data_ids_form = self.fields_view_get Signature: def fields_view_get(self. uid.'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('). toolbar=False) Parameters: Description: context (optional.get('ir. view_type=‟form‟.data').model. ('name'. value. view_id=None.pool. 'ir.pool. offset=0.model_data_ids_form. view_id.view').user.fields=['res_id'. '='. read(cr. highly recommended): the actual context dictionary.self). 'membership_products_tree'])]) resource_id_form = self. cr. user. context. [('model'. toolbar) distinct_field_get Signature: def distinct_field_get(self. view_id=None. args=None. user.model. ['membership_products_form'. uid. cr. limit=2000) Description: Parameters: Result: Example: TODO . user.fields_view_get(cr. view_type='form'.product]: def fields_view_get(self.

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

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

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


These views are simpler than the form views and thus have less options. .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.

New : You can now add shortcut using the shortcut tag. ..0"?> <openerp> <data> [view definitions] </data> </openerp> The view definitions contain mainly three types of tags: <record> tags with the attribute model=”ir.order" logins="demo" menu="m"/> Note that you should add an id attribute on the menuitem which is refered by menu attribute..order</field> <field name="priority" eval="2"/> <field name="arch" type="xml"> <form string="Sale Order"> .view" id="v"> <field name="name">sale...act_window”. </form> </field> </record> Default value for the priority field : 16.view”.. and link them with actions New : You can precise groups for whom the menu is accessible using the groups attribute in menuitem tag. <record model="ir. Example: <shortcut name="Draft Purchase Order (Proposals)" model="purchase.order.ui. which contain the view definitions themselves <record> tags with the attribute model=”ir.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.form</field> <field name="model">sale. When not specified the system will use the view with the lower priority.actions.ui.. which link actions to these views <menuitem> tags. which create entries in the menu...

Example: <notebook colspan="4">. 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.</notebook> Group <group>: groups several columns and split the group in as many columns as desired.. </page>: .... Example: <page string="Order Line"> . down. left. You can use the tabpos properties to set tab at: up. with a label containing the string. right. a frame will be drawn around the group of fields.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). Notebook <notebook>: With notebooks you can distribute the view fields on different tabs (each one defined by a page tag).. 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. Otherwise. the frame will be invisible.

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

'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. '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. Example: <?xml version="1.'='.tree" name="address" nolabel="1" select="1"> <form string="Partner Contacts"> <field name="name" select="2"/> <field domain="[('domain'.view"> <field name="name">res.<field digits="(14. '='.0"?> <openerp> <data> <record id="view_partner_form" model="ir. '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. This is the same object as the object shown on the screen shots of the presentation. '='. 3)" name="volume" attrs="{'readonly':[('type'.form</field> <field name="model">res.ui.

content inside <field> tags are always evaluated as strings.3' and not the float 2.3</field> This will evaluate to the string '2.menu_base_partner" sequence="2"/> </data> </openerp> The eval attribute¶ The eval attribute evaluate its content as if it was Python code. Normally.3 Example 2:<field name="value">False</field> . Example 1: <field name="value">2. This allows you to define values that are not strings. 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.</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.

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. . it can trigger methods on the object. When clicked. except string.). uid. workflow transitions or actions (reports.. it must take 4 arguments: cr.3" /> <field name="value" eval="False" /> Button <button/>: add a button using the string attribute as label. the button is always visible. Eg: confirm=”Are you sure?” name: the name of the function to call when the button is pressed.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. Example: <label string="Test"/> New Line Force a return to the line even if all the columns of the view are not filled in. Example: <newline/> . If the states attribute is not given. a boolean or another type. string: define the button‟s label confirm: the message for the confirmation window. you need to use the eval attribute: <field name="value" eval="2. In the case it‟s an object function.. wizards. if needed. ids.

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

STOCK_CONNECT. name defines the position of the menu item in the menu hierarchy. STOCK_COPY. for_user (optional): boolean that determines if the new default value must be available only for the current user or for all users. STOCK_GOTO_LAST. A menu item name with no slash in its text is a top level menu. 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_FILE. STOCK_DND_MULTIPLE.actions. STOCK_COLOR_PICKER. This identifier must be unique. STOCK_BOLD. STOCK_DIALOG_INFO. STOCK_CONVERT.value: the value by default. STOCK_GOTO_BOTTOM.act_window). STOCK_CLOSE. Mandatory field. Note that this field is not mandatory : you can define menu elements without associating actions to them. STOCK_DIALOG_ERROR. STOCK_CUT. STOCK_FLOPPY. 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_CANCEL. STOCK_CDROM. . STOCK_DND. icon specifies which icon will be displayed for the menu item using the menu item. “Human Resources” in Open ERP are defined). STOCK_DIALOG_QUESTION. o The available icons are : STOCK_ABOUT. STOCK_DIALOG_AUTHENTICATION. STOCK_DIRECTORY. STOCK_FIND_AND_REPLACE. STOCK_DISCONNECT. STOCK_APPLY. Elements are separated by slashes (“/”). STOCK_FIND. STOCK_DIALOG_WARNING. STOCK_ADD. The default icon is STOCK_OPEN. STOCK_EXECUTE. STOCK_GOTO_FIRST. STOCK_CLEAR. action specifies the identifier of the action that must have been defined in the action table (ir. Mandatory field. STOCK_DELETE.

STOCK_UNINDENT. STOCK_MISSING_IMAGE. STOCK_PREFERENCES. STOCK_UNDELETE. the downer the menu item. STOCK_ZOOM_OUT. STOCK_OK. Menu items with the same sequence numbers are sorted by order of creation (_order = “sequence. STOCK_OPEN. STOCK_JUMP_TO. STOCK_MEDIA_NEXT. STOCK_STOP. . STOCK_ZOOM_100. STOCK_ZOOM_FIT. terp-hr. This argument is not mandatory: if sequence is not specified. STOCK_ITALIC. STOCK_GO_FORWARD. STOCK_REFRESH. STOCK_MEDIA_STOP. STOCK_REVERT_TO_SAVED. STOCK_MEDIA_PLAY. STOCK_MEDIA_REWIND. STOCK_PASTE. terp-mrp.user”) sequence is an integer that is used to sort the menu item in the menu. <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 . login of a new user. STOCK_HELP. click on the action button. STOCK_PROPERTIES.STOCK_REDO. terp-report. STOCK_INDEX. STOCK_GO_DOWN.“). The higher the sequence number.‟ (example: groups=”admin. STOCK_ZOOM_IN. STOCK_JUSTIFY_CENTER. 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 .STOCK_GOTO_TOP. STOCK_SAVE. STOCK_PRINT. Multiple groups should be separated by a „. STOCK_SORT_DESCENDING. STOCK_PRINT_PREVIEW. STOCK_NEW. STOCK_SORT_ASCENDING. STOCK_UNDERLINE. STOCK_SAVE_AS. STOCK_NO. STOCK_GO_UP. STOCK_GO_BACK. STOCK_MEDIA_PAUSE. STOCK_MEDIA_FORWARD. STOCK_MEDIA_RECORD.. double-click on an invoice. STOCK_UNDO. See section ” Management of Access Rights” for more information. terp-product. STOCK_YES. STOCK_QUIT. STOCK_SELECT_FONT. STOCK_JUSTIFY_LEFT. terpadministration. STOCK_JUSTIFY_FILL. the menu item gets a default sequence number of 10. terp-partner. STOCK_SPELL_CHECK. STOCK_NETWORK. terp-tools. STOCK_MEDIA_PREVIOUS. terp-project.. terp-stock groups specifies which group of user can see the menu item (example : groups=”admin”). terp-purchase. terp-crm. STOCK_STRIKETHROUGH. STOCK_HOME. STOCK_REMOVE. terp-sale. STOCK_INDENT. STOCK_HARDDISK. STOCK_SELECT_COLOR. terp-account.

1. The steps are: 1. 2. Execution of the action 1. the fields description and the XML view. The user clicks on the icon „print‟ or „action‟. the client must search the action to use for the first screen of this user. The user double-clicks on the menu. 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). User connection. all the actions are described and not configured. Generally. The user asks the object and receives information necessary to trace a form. Reading of a user file to obtain ACTION_ID 2. If the action is the type Opening the Window.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. the next steps are done to give the user information on the action to undertake. User connection When a new user is connected to the server. 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”. Example of events In Open ERP. Search the action in the IR. 2. Reading of the action and execution of this one . this action is: open the menu in the „Operations‟ section.

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

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

actions. ('manager'.project</field> <field name="res_model">project.actions.Examples of actions¶ This action is declared in server/bin/addons/project/project_view. uid)]</field> <field name="view_id" ref="view_my_project" /> </record> This action is declared in server/bin/addons/stock/stock_view. <record model="ir.actions.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.False).'='.picking</field> <field name="res_model">stock.picking</field> <field name="type">ir.act_window" id="open_view_my_project"> <field name="name">project.xml.xml.act_window" id="action_picking_form"> <field name="name">stock.project</field> <field name="view_type">tree</field> <field name="domain">[('parent_id'. '='.

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”.order" name="sale_category. See “Add A New Wizard” for more information about wizard XML.rml" menu="True" auto="False"/> .employee" name="employee.0"?> <openerp> <data> <wizard string="Employee Info" model="hr.XML file that declares a wizard.print" rml="sale_category/report/sale_category_report.employee" name="employee. Here‟s an example of a XML file that declares a RML report : <?xml version="1.0"?> <openerp> <data> <report id="sale_category_print" string="Sales Orders By Categories" model="sale. <?xml version=" also you can add wizard in menu using following xml entry <?xml version="1.Url Action Here‟s an example of a .0"?> <openerp> <data> <wizard string="Employee Info" model="hr.wizard" id="wizard_employee_info"/> </data> </openerp> A wizard is declared using a wizard

Setting menu to False is useful in case of reports called by wizards. . 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. auto : determines if the .</data> </openerp> A report is declared using a report tag inside a “data” block. rml : the . model : the Open ERP object on which the report will be rendered.RML report model. string : the text of the menu that calls the report (if any. Using a custom parser allows you to define additional functions to your report. see below).RML file must be parsed using the default parser or not. Important Note : Path is relative to addons/ directory.