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

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

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

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

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

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

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

so you are not strictly bound by these defaults). 1. 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. shown in the screenshot Continuing with the database after installing new modules. Click MAIN MENU to see this. The main menu now displays all of the menu items that were loaded by the modules you installed.Configuration is required for both the accounts setup and the sales defaults. Accept the defaults for the Fiscal Year and choose the Charts of Account to be None then click Continue. Each of the modules that were installed has its own new tab . Click Next and Previous to move between them. 3. The sales defaults are shown in the screenshot The module form once a module is‟s not only the one you see displayed in front of you. The module form once a module is installed . Accept the initial set by clicking Set default behaviour. You‟ve reached the end of this configuration stage so click Continue to continue using the system as the Administrator. 2. 4.

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

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

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

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

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

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

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

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

write_uid. _inherit The name of the osv object which the current object inherits from.. the creation date of record. Default value: None. Default value: {}. _order Name of the fields used to sort the results of the search and read methods. Default value: „name‟. If true.}. Default value: None. Default value: „id‟. the id of the user who last modified the record. write_date. ) replaced by underscores ( _ ). See the object inheritance section (first form) for further details. 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. Default value: the value of the _name field above with the dots ( .. See the object inheritance section (second form) for further details. four fields will be created in the SQL table: create_uid. It means this code gets executed after the table is created. _table Name of the SQL table. ._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 list must be given in a python dictionary of the form: {„name_of_the_parent_object‟: „name_of_the_field‟. Note: by default. . and the date of that last modification. Examples: _order = "name" _order = "date_order desc" _rec_name Name of the field in which the name of every resource is stored. See the default value section for details. Those fields represent respectively the id of the user who created the record. the name_get method simply returns the content of this field. _name (required) Name of the object. create_date. _inherits The list of osv objects the object inherits from. _sequence Name of the SQL sequence that manages the ids for this object.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

Setting menu to False is useful in case of reports called by wizards. Using a custom parser allows you to define additional functions to your report. menu : whether the report will be able to be called directly via the client or not.</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. see below).RML report model. . Important Note : Path is relative to addons/ directory.RML file must be parsed using the default parser or not. string : the text of the menu that calls the report (if any. auto : determines if the . The different arguments of a report tag are : id : an identifier which must be unique. rml : the .

Sign up to vote on this title
UsefulNot useful