Credits: Guillaume Rivière 2013 – 2018 OUTLINE
1. Overview – Birth and growth OpenERP – Customers, Partners, Vendors 2. Administration – Versions, Architecture Overview, Introduction to – Main modules Administration & Development 3. Development – Module programming – EFREI – – Webservice programming – ESTIA – Guillaume Rivière 4. Documentation Last update: March 2018 1 2
WARNING !!! History of OpenERP
• You are going to learn one ERP • Initiated by Fabien Pinckaers – But keep in mind to select an ERP only because it is – in 2002, in Belgium the best adapted to the case of your company – Written in Python Our competitors – Database is PostgreSQL This ERP fits all the use this ERP !!! This is the only needs of my company. – Open Source (but not free software, according to FSF) ERP i know … • Licence: AGPL v3
2002 2004 2005 2006 2008 2009 2011 2012 2013 2014 2015 2016 2017
1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0
1.0 2.0 3.0 3.4 3.6 4.0 4.6 3 4 OpenERP today Hardware needed
• Used for teaching since 2008 • 5 employees: 2 CPU 2GB RAM – The CERTA network teach accounting to BTS • 20 employees: 4 CPU 8GB RAM – CERPEG • 90 employees: 2x 8 CPU 32GB RAM • Arround the world, we find dozens of – Split application and database server Customers, Vendors and Partners • 250+ employees: 2x 12 CPU 128 GB RAM • Still supported Long Term Stable versions (LTS) – Load balancing – Version 7.0 released in December 2012 – Version 8.0 released in September 2014 – Version 9.0 released in October2015 • Enterprise (20€/user/month) & Community (90%) Editions 5 6
Vendors / Consultants Partners
• Smile • Gold / Silver / Ready / Training Center • Julius – Pay annual fees • Business & Decision • Aunéor Conseil • Anybox • Camptocamp • ZAD solutions • Audaxis • and many many others… 7 8 Partners’ world map Partners worldwide
Western Europe 219 Africa 57 Asia 55 North America 35 South America 36 Australia 5
1 partner 2 → 9 10 → 99 ≥ 100
(http://v6.openerp.com/partner-worldmap March 2013) 9 (http://v6.openerp.com/partner-worldmap March 2013) 10
Partners in Western Europe Partners in France
1 partner 2 → 9 10 → 99 ≥ 100
(http://v6.openerp.com/partner-worldmap March 2013) 11 (March 2013) 12 Customer references OUTLINE
1. Overview – Birth and growth – Customers, Partners, Vendors 2. Administration – Versions, Architecture – Main modules 3. Development – Module programming – Webservice programming 4. Documentation 14
Timeline of versions Elements to run OpenERP
Tiny SPRL (May 2002) TinyERP 1.0 : 06/07/2004 (3 companies) OpenERP SA (2005) TinyERP 2.0 : 25/03/2005 • Client TinyERP 3.0 : 02/09/2005 – GTK client: until version 6.x TinyERP 4.0 : 02/12/2006 TinyERP 4.1 : 13/06/2007 (web server) – Web client: since version 4.1 TinyERP 4.2 : 01/10/2007 Renamed (April 2008) – « full web »: since version 7.0 OpenERP 5.0 : 08/02/2009 Tryton 1.0 (Nov. 2008) OpenERP 6.0 : 20/01/2011 Tryton 2.0 (April 2011) • Server OpenERP 6.1 : 23/02/2012 (new web gui) OpenERP 7.0 : 22/12/2012 (full web) – Separated web server: from 4.1 to 6.x Tryton 3.0 (Oct. 2013) Odoo 8.0 : 18/09/2014 (front: e-com, CMS+builder, stocks) – Version 7.0: one-piece server Odoo 9.0 : 01/10/2015 (accounting) Tryton 4.0 (May 2016) Odoo 10.0 : 01/10/2016 (production) • v7.0 : Python >= 2.6 (Python 2.7) LTS 9.0 will be Odoo 11.0 : 01/10/2017 • v6.1 : Python >= 2.6 supported until LTS 12.0 is released 15 • v6.0 : Python >= 2.5 16
Compatibility Technical Architecture
• Server operating system • OpenERP v6 (for GTK client) – Linux, Windows, Mac OS Server Thick client OpenERP Server OpenERP GTK Client
• Web browser (OpenERP 7) (Odoo 10) Business Business Forms Calendar Report Wizard Objects Objects
Trees Action Pool – Mozilla Firefox (≥ 13) Business Windows Objects Business Objects Graph – Microsoft IE (≥ 9.0) - User interface XML-RPC:8069
– Microsoft Edge - Base Module WebServices Network RPC Gateway Core Base Distribution (Internet or Intranet)
NET-RPC:8070 Widgets – Safary (N.C.) Object Relational Report engine Mapping – Google Chrome (≥ 22) Forms Trees Search Workflow engine • OpenERP Mobile Client (Smartphones, tablets) 17 PostgreSQL 18 – Application Android, iOS (alternative : myodoo.com) http://doc.openerp.com
Technical Architecture Global navigation
Login Page • OpenERP v7 v8 v9 (web client) Preferences Create Settings Thin client Server Database Backup Manager Drop Web user: admin Administrator User browser Network Restore client pass: admin OpenERP PostgreSQL 8069 Messaging server DBMS 5432 Web user: openerp … user: demo browser (Internet or Intranet) pass: postgres Sales HTTP pass: demo client JSON Fleet user: HTML, CSS, pass: toor Accounting Javascript Reporting Purchases db_demo database Human Warehouse Resources 19 Manufacturing 20 Administration Connectors
• Administrator(s) must define • Enterprise Application Integration (EAI) – The users • Interoperate OpenERP and other programs – The access rights – Webservice (program in Python, Java, PHP, C/C++, …) – The languages – Business objects (module in Python) – The menus • http://openerp-connector.com/ – The basis data of the company Other Application A Other Application B OpenERP Server • Products, work centers, flows, etc. – The modules to install Connector
– Business The connections with other software Objects WebServices Connector – and many other things… 21 22
Connectors E-commerce
• CMS • Reporting • Prestashop
– Joomla! (PHP/MySQL) – JasperReports (Java) • E-commerce – ReportLab (Python)
– OSCommerce (PHP/MySQL) • Business Intelligence
– Magento (PHP) – Pentaho (Java)
– PrestaShop (PHP/MySQL) – SpagoBI (Java) • CMS + eCommerce
– eZ Publish (PHP/MySQL, PostgreSQL, SQLserver,Oracle)
23 24 Reporting Reporting
• JasperReports • ReportLab – Financial reporting and dynamic graphics
– Natively used in OpenERP for reporting diagrams 25 26
Business Intelligence Business Intelligence
• Pentaho • SpagoBI
27 28 VOIP ETL
• CRM • Extract-Transform-Load – Routing phone calls App1 App2 • Open the customer master record when they are calling • Call-center VoIP with Asterisk server – Automatically call a customer 2) Transform 1) Extract 3) Load DB1 ETL DB2
– Integrate data from multiple databases of Click2dial different applications
29 30
ETL ETL
• CRM • Kettle
– Targeting the customers VTiger SugarCRM Concursive – Data mining of sales history CRM • Weka (Java) • (PHP) SugarCRM ETL Kettle Talend • vTiger (PHP) • Concursive CRM (Java) OpenERP DB
PostgreSQL
31 32 ETL CRM
• Talend • SugarCRM – B2B – B2C
33 34
CRM PLM / PDM
• vTiger • OpenERP PLM – Fork of – OmniaSolutions SugarCRM
35 36 Manage management systems User Interface
• Certifications • User interfaces of ERPs are often quite simple – Quality (ISO 9001)
– Environment (ISO 14001) (3) Main – Security (ISO 27001, PCI-DSS) (1) Modules view – IT services (ISO 20001, ITIL) – Health & Safety (OHSAS 18001) • Extra menus and tabs (2) Menu of – In several modules www.pcsol.be the current module www.savoirfairelinux.com
37 38 Screenshot of OpenERP v7.0
Main modules Messaging
• Inbox • Messaging • Manufacturing • Meetings calendar • Sales • Marketing • Contacts • Point of Sales • Human Resources • … • Project • Fleet • Association • Events • Accounting • Knowledge • Purchases • Tools • • Warehouse Reporting 39 40 Screenshots of OpenERP v7.0 Sales Purchases
• Customers • Quotations • Products • Purchases orders • … • On Draft Invoices • Incoming shipments • …
41 42 Screenshots of OpenERP v7.0 Screenshots of OpenERP v7.0
Warehouse Manufacturing
• Procurement Exceptions • Manufacturing orders • Incoming Shipments • Incoming Products • …
(List view) (Calendar view) • Bill of materials
43 44 Screenshots of OpenERP v7.0 Screenshots of OpenERP v7.0 Human Resources Point of sales
• Timesheets • Tactile interface • Leave Requests • …
45 46 Screenshots of OpenERP v7.0
Point of sales Point of sales
• Barcodes • PosBox www.indiegogo.com/projects/opensource-your-shop • Receipts – Raspberry-Pi + Tablet + Printer + Scanner • …
47 48 CMS & E-commerce Reporting
• Available since Odoo 8.0 + website builder • Invoice Analysis • Purchase Analysis • Inventory Analysis • …
49 50 Screenshots of OpenERP v7.0 Settings Settings (Administrator) (Administrator) • Install new module • Parameter workflows
51 52 Settings Settings (Administrator) (Administrator) • Example: workflow of an idea • Example: workflow of an idea
53 54
Getting sources Download sources
• Launchpad (Sourceforge, GNU Savannah, …) • Bazaar (cvs, svn, git, …) – https://launchpad.net/openobject – bzr branch lp:openobject-server • Version under developement (trunk) – bzr branch lp:openobject-addons – bzr branch lp:openerp-web https://launchpad.net/ /trunk – openobject-server – https://launchpad.net/openobject-addons/trunk Remove .bzr hidden directories! – https://launchpad.net/openerp-web/trunk • Older versions • Older versions – bzr branch lp:openobject-server/7.0 – bzr branch lp:openobject-addons/7.0 – https://launchpad.net/openobject-server/7.0 – bzr branch lp:openerp-web/7.0 – https://launchpad.net/openobject-addons/7.0
– https://launchpad.net/openerp-web/7.0 – bzr branch lp:openobject-server/6.0 – bzr branch lp:openobject-addons/6.0 55 – bzr branch lp:openerp-web/6.0 56
Verticalizations Verticalizations
• Hostels • Textile & Spinning Manufacturing Industry – https://launchpad.net/~hotel-core-editors – https://launchpad.net/openerp-textiles • Electronic Medical Record and Hospital • Humanitarian non-governmental organization Information System – https://launchpad.net/openerp-humanitarian-ngo – https://launchpad.net/medical • Library Management System • Construction – https://launchpad.net/openerp-library – https://launchpad.net/openerp-btp • Veterinary and production farms – https://launchpad.net/openerp-construction – https://launchpad.net/openerp-openvet • Pedagogy / Education Management System • Agro farm management – https://launchpad.net/pedagogy – https://launchpad.net/agrooffice – https://launchpad.net/openerp-ems 57 58
OUTLINE Python
1. Overview • Language used to program OpenERP modules – Birth and growth • Don’t need to become an expert – Customers, Partners, Vendors • Short 12-slides-introduction 2. Administration – Indentation – Versions, Architecture – Main modules – Functions 3. Development – Data structures • Lists, Tupples, Dictionnaries – Module programming – – Webservice programming Classes 4. Documentation 59 60 3. DEVELOPMENT OpenERP database structure
Open ERP models Module description Fields of the model (columns) Views (in XML) Webservice communication
61 62
OpenERP database structure res.users
• Some of the numerous predefined models: • Fields of the predefined model res.users : – base.module.configuration – workflow Field name Field type . id integer – base.module.import – workflow.instance . login char Used in the modules: . login_date date auth_crypt, auth_ldap, – base.module.update – workflow.triggers . password char auth_oauth, . new_password char auth_oauth_signup, – res.users – workflow.activity auth_openid, . active boolean auth_signup, – res.partners – ir.ui.view . user_email char base, . signature text hr, mail, – res.company – ir.ui.menu . company_id many2one note, . company_ids many2many point_of_sale, – res.country – ir.filters sale_crm, . groups_id many2many share, – res.lang – ir.translation . partner_id many2one survey, . action_id many2one ... – res.currency – ir.cron 63 . menu_id many2one 64
product.product A module
• Some fields of the model product.product : • A module defines a namespace Field name Field type – Several Python classes can be defined in the same . code char . color integer Used in the modules: namespace . price float event_sale, mrp, . active boolean point_of_sale, • Each class defines a « model » / « business . image binary procurement, purchase_requisition, object », and fields are stored in PostgreSQL . track_incoming boolean stock, . track_outgoing boolean stock_location, – Thanks to the ORM track_production boolean warning, . ... . seller_id many2one – All classes must inherit the class osv.osv . seller_delay integer • osv = Object SerVice . seller_qty float . warehouse_id many2one • Models can be shared by different modules . qty_available float . ... 65 66
ORM Methods of the ORM
• Object Relational Mapping • create • copy_data • check_access_rule
Business Base Module Object Relational • search • default_get • get_xml_id Objects Distribution Mapping create() INSERT INTO • read • fields_get • name_search search() SELECT FROM PostgreSQL write() UPDATE WHERE • browse • name_get • perm_read – Technique to program with a relational DB as if it • write • export_data • read_group was an object-oriented one • unlink • import_data • fields_view_get – Makes the bridge between relational and OO worlds • copy • view_init – Centralizes data integrity verifications and access rights management – Can be called from business objects 67 – Can also be called through WebServices 68 The create() method The search() method
create(cr, user, vals, context=None) search(cr, user, args, offset=0, limit=None, order=None, context=None, count=False) Create new record with specified value Giving some examples Search for records based on a search domain Parameters: . cr – database cursor would be better Parameters: . cr – database cursor . user (integer) – current user id . user (integer) – current user id . vals (dictionary) – field values for new record, e.g {'field_name': field_value, ...} . args – list of tuples specifying the search domain [('field_name', 'operator', value), ...]. . context (dictionary) – (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...} Pass an empty list to match all records. Returns: id of new record created . offset – (optional) number of results to skip in the returned values (default: 0) Raises: AccessError . limit – (optional) max number of records to return (default: None) o if user has no create rights on the requested object . order – (optional) columns to sort by (default: self._order=id ) o if user tries to bypass access rules for read on the requested object. . context (dictionary) – (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...} ValidateError – if user tries to enter invalid value for a field that is not in selection . count – (optional) if True, returns only the number of records matching the criteria, UserError – if a loop would be created in a hierarchy of objects a result of the not their ids operation (such as setting an object as its own parent) Returns: id or list of ids of records matching the criteria Return type: integer or list of integers Raises: AccessError o if user tries to bypass access rules for read on the requested object. 69 70
The browse() method The write() method
browse(cr, user, select, context=None, list_class=None, write(cr, user, ids, vals, context=None) fields_process=None) Fetch records as objects allowing to use dot notation to browse fields and relations Update records with given ids with the given field values Parameters: . cr – database cursor Parameters: . cr – database cursor . user (integer) – current user id . user (integer) – current user id . select – id or list of ids . ids – object id or list of object ids to update according to vals . context (dictionary) – (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...} . vals (dictionary) – field values to update, e.g {'field_name': new_field_value, ...} Returns: object or list of objects requested . context (dictionary) – (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...} Returns: True Raises: AccessError o if user has no write rights on the requested object o if user tries to bypass access rules for write on the requested object ValidateError – if user tries to enter invalid value for a field that is not in selection UserError – if a loop would be created in a hierarchy of objects a result of the operation (such as setting an object as its own parent)
71 72 The unlink() method 3. DEVELOPMENT unlink(cr, user, ids, context=None) Open ERP models Delete records with given ids Parameters: . cr – database cursor . user (integer) – current user id Module description . ids – object id or list of object ids to update according to vals . context (dictionary) – (optional) context arguments, e.g. {'lang': 'en_us', 'tz': 'UTC', ...} Returns: True Fields of the model (columns) Raises: AccessError o if user has no write rights on the requested object o if user tries to bypass access rules for write on the requested object UserError – if a loop would be created in a hierarchy of objects a result of the Views (in XML) operation (such as setting an object as its own parent) Webservice communication
73 74
Writting a module Example of the module Idea
• A module is composed of several files • Each module is contained in one directory – Python files idea • Meta-informations about the module __openerp__.py __init__.py • Model for the ORM (Object-Relational Mapping) idea.py – XML files idea_view.xml idea_workflow.xml • Description of the views idea_data.xml • Description of the workflows i18n • Definition of demonstration data idea.pot fr.po ja.po en_GB.po it.po ko.po zh_CN.po es.po ... security idea_security.xml 75 ir.model.access.csv 76 Python class of a model Python class of a model
• RESERVED MEMBERS • Example of members declaration . _name : business object name 'module_namespace.object_name' class idea_idea(osv.osv): """ Idea """ . _columns : the fields of the model _name = 'idea.idea' . _defaults : default values for fields _inherit = ['mail.thread'] _columns = { . _inherit : _name of the parent 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, oldname='title', states={'draft': [('readonly', False)]}), . _sql_constraints : tuples defining SQL constraints 'description': fields.text('Description', help='Content of the idea', readonly=True, states={'draft': [('readonly', False)]}), 'state': fields.selection([('draft', 'New'),('open', 'Accepted'),('cancel', 'Refused'),('close', 'Done')],'Status', readonly=True, track_visibility='onchange',) • (name, sql_def, message) } . _constraints : tuples defining Python constraints _sql_constraints = [ ('name', 'unique(name)', 'Idea name must be unique') • (func_name, message, fields) ] . _order : the field to sort records (default field: 'id') _defaults = { . _auto, _inherits, _log_access, _rec_name, 'state': lambda *a: 'draft', } _sql, _table 77 _order = 'name asc' 78
3. DEVELOPMENT Fields of the model
• Declared as a dictionnary in the _columns Open ERP models member of the class • Example Module description class idea_idea(osv.osv): _columns = { 'create_uid': fields.many2one('res.users', 'Creator', required=True, readonly=True), Fields of the model (columns) 'name': fields.char('Idea Summary', size=64, required=True, readonly=True, oldname='title', states={'draft': [('readonly', False)]}), 'description': fields.text('Description', help='Content of the idea', readonly=True, states={'draft': [('readonly', False)]}), 'category_ids': fields.many2many('idea.category', string='Tags', readonly=True, states={'draft': [('readonly', False)]}), Views (in XML) 'state': fields.selection([('draft', 'New'), ('open', 'Accepted'), ('cancel', 'Refused'), ('close', 'Done')], Webservice communication 'Status', readonly=True, track_visibility='onchange', ) 79 } 80
Columns (fields) Type of fields
• RESERVED COLUMNS NAMES (i.e. FIELDS) • Basic types – id : unique identifier for the object (created by ORM, don’t add it!) – integer – char – date name – : defines the label to display in lists, etc. – float – text – datetime – state : defines object life-cycle stages (used for workflow) – – – – active : defines visibility boolean selection time – sequence : defines order • Relational types – binary – create_date, create_uid, write_date, write_uid: – many2one used to log meta information about the record (automatically defined and set by the ORM, so don’t define this column!) – one2many – parent_id, parent_left, parent_right : defines – many2many tree structure on records – one2one many2one 81 82
Fields declaration integer type
• Optional parameters fields.integer (string='Field Name' [, Opt. Param.]), – string : the field label (required) Giving a full example string parameter, which defines the label could help – required : set it to True if mandatory field fields.integer('Field Name' [, Optional Parameters]), – readonly : set it to True if not editable field – help : text for the help tooltip • Example of declaration – context : dictionary with contextual parameters _columns = { (for relational fields) 'level': fields.integer('Level of development'), 'code': fields.integer('Reference code', readonly=True), – states : dynamically changes the field's } attributes according to the changing state of the • Example of assignment object 83 self.write(cr, uid, ids, {'level': 5}) 84 float type boolean type
fields.float ('Field Name' [, Optional Parameters]), fields.boolean ('Field Name' [, Optional Parameters]), • Example of declaration • Example of declaration _columns = { _columns = { 'weight': fields.float('Product weight in kg'), 'is_active ': fields.boolean('Active product'), 'price': fields.float('Price in EUR', digits=(12,6)), 'msg_unread': fields.boolean('Unread message', readonly=True), 'rate': fields.float('FRS-EUR exchange rate', digits=(12,6), } readonly=True), } • Example of assignment • Example of assignment self.write(cr, uid, ids, {'msg_unread': False}) self.write(cr, uid, ids, {'weight': 0.256})
85 86
char type text type
• A string of limited length • A string with no limited length fields.char ('Field Name', size=n [, Optional Param.]), fields.text ('Field Name', [, Optional Parameters]), • Example of declaration • Example of declaration _columns = { _columns = { 'name': fields.char('Category Name', size=64, required=True), 'description': fields.text('Description'), 'code': fields.char('Reference code', size=9, readonly=True), 'purchase_msg': fields.text('Message for purchase order'), } } • Example of assignment • Example of assignment self.write(cr, uid, ids, {'description': 'This article...'}) self.write(cr, uid, ids, {'code': '000AR400M'})
87 88 selection type selection type
• Selection between predefined values • Examples of declaration _columns = { fields.selection(values, 'Field Name', [, Opt.Param.]), 'size': fields.selection( [('-1','Undefined'),('0','Small'), – where the parameter values is a list, or a tuple, ('1', 'Medium'),('2', 'Large')], of 2-tuples formed as (key, value) 'Package size'), }
• Example with a list of 2-tuples: countries = [('fr','France'),('es','Spain'),('it', 'Italy')]
values = [('n','Unconfirmed'),('c','Confirmed')] _columns = { 'dep ': fields.selection(countries, 'Departure'), • Example with a tuple of 2-tuples: 'arr': fields.selection(countries, 'Arrival'), }
values = (('n','Unconfirmed'),('c','Confirmed')) • Example of assignment 89 self.write(cr, uid, ids, {'size': '-1'}) 90
date type many2one relation
fields.many2one('model', 'Field Name' [, Opt.Param.]), fields.date ('Field Name' [, Optional Parameters]), • Example of declaration • Example _columns = { 'birthday ': fields.date('Date of birth'), 'last_mod': fields.date('Last modification', readonly=True), } class idea_idea(osv.osv): • Example of assignment _ columns = { 'create_uid': fields.many2one('res.users', 'Creator'), self.write(cr, uid, ids, {'last_mod': datetime.now()}) } – An idea is created by 1 (and only 1) user, but a user can create N ideas 91 92 many2many relation many2many relation fields.many2many('model', string='Field Name' [, Par]), fields.many2many(' modelB', 'rel', 'idA', 'idB' [, Par]),
• Example • Example
event_event(osv.osv): class idea_idea(osv.osv): class _columns = { _columns = { 'category_ids': fields.many2many('idea.category', 'sponsor_ids': fields.many2many('res.partner', string='Tags'), 'event_sponsor_rel', } 'event_id', 'sponsor_id', – An idea can belong to several categories, 'Sponsors'), } and a category can describe several ideas 93 94
one2many "virtual" relation one2one relation (deprecated) fields.one2many('model', 'id', 'Field Name', [, Par.]), fields.one2one(' model','Field Name' [, Opt.Param.]), fields.many2one('model','Field Name' [, Opt.Param.]),
• Example • Example class survey_question(osv.osv): _columns = { class country_country(osv.osv): 'answer_choice_ids': fields.one2many('survey.answer', _ columns = { 'question_id', 'president_id': fields.one2one('res.users', 'President'), 'Answer'), } } class country_country(osv.osv): Match corresponding foreign key _ columns = { class survey_answer(osv.osv): 'president_id': fields.many2one('res.users', 'President'), _columns = { } 'question_id': fields.many2one('survey.question', 'Question'), – Each country has 1 (and only 1) president, } 95 and a person can be president of only 1 country 96 Relation fields’ names 3. DEVELOPMENT
• By convention, Open ERP models – many2one fields end with '_id' – one2many fields end with '_ids' Module description – many2many fields end with '_ids' class survey_answer(osv.osv): Fields of the model (columns) _columns = { 'question_id': fields.many2one( class survey_question(osv.osv): Views (in XML) _columns = { 'answer_choice_ids': fields.one2many( class idea_idea(osv.osv): Webservice communication _columns = { 'category_ids': fields.many2many( 97 98
XML files for views Tree view
• Views (ir.ui.view) – Tree view – Form view – Search view • Actions (ir.actions.act_window) • Menus (menuitem)
Columns/Fields
99 100 Tree view Search view
• Extracted from idea_view.xml
101 102
Search view Filters
• Extracted from idea_view.xml • Condition: (Field,Operator,Value)
• Extracted from idea_view.xml
• Extracted from idea_view.xml
Open ERP models
Views (in XML)
• Must be defined at after the declarations of Webservice communication the views 108 109 Webservices Webservice with OpenERP
• SOA: Service Oriented Architecture • OpenERP v7 v8 v9 Web client HTTP • WOA: Web Oriented Architecture HTML,CSS, JSON Javascript • XML-RPC: XML Remote Procedure Call OpenERP Network (Internet or Intranet) Application A Application B OpenERP PostgreSQL Python server DBMS HTTP script 5432 Encode Decode Execute user: openerp pass: postgres XML-RPC HTTP XML-RPC user: setLimit(40) C/C++ pass: toor program
OpenERP webservice Calling ORM methods
• Allows calling the methods of the ORM • Can be called from any program written with a – Create: create a new record language having a XML-RPC library – Write: update a record – Python – Search: look records matching a criteria – C/C++ – Read: get the values of a record – Objective-C – Unlink: delete a record – Java (and also with android-xmlrpc) • Steps – JavaScript . 1 : connexion and identification – PHP (with Pear library for PHP) . 2 : execution – Perl . 3 : disconnexion 112 – … 113 The create() ORM method Example with PHP
• create({'field':'value'}) • Example with PHP (without error checking) require_once('XML/RPC.php'); // Include PEAR library for XML-RPC – Creates a new record with the specified value // Login – Returns: id of the new record $client = new XML_RPC_Client('/xmlrpc/common', "http://127.0.0.1:8069"); • Example with Python $client->setDebug(0); import xmlrpclib $msg = new XML_RPC_Message('login'); # Get the uid $msg->addParam(new XML_RPC_Value('db_name', 'string')); sock_common = xmlrpclib.ServerProxy ('http://127.0.0.1:8069/xmlrpc/common') $msg->addParam(new XML_RPC_Value('username', 'string')); uid = sock_common.login('db_name', 'username', 'passwd') $msg->addParam(new XML_RPC_Value('passwd', 'string'));
# Ask for execution on OpenERP $resp = $client->send($msg); // Send execution request on OpenERP sock = xmlrpclib.ServerProxy('http://127.0.0.1:8069/xmlrpc/object') $val = $resp->value(); partner_id = sock.execute('db_name', uid, 'passwd', 'res.partner', $uid = $val->scalarval(); 'create', {'name': 'Fabien Pinckaers', 'lang': 'en_US', }) 114 115
Example with PHP The search() ORM method
// Request • search([('arg1','=','value1')...], $client = new XML_RPC_Client('/xmlrpc/object', "http://127.0.0.1:8069"); $client->setDebug(0); offset=0, limit=1000)
$structVal = array( – arg1, arg2, .. ,argN: list of tuples specifying search 'name' => new XML_RPC_Value('Fabien Pinckaers', 'string'), 'lang' => new XML_RPC_Value('en_US', 'string'), criteria ); – offset: optional number of records to skip $msg = new XML_RPC_Message('execute'); $msg->addParam(new XML_RPC_Value('db_name', 'string')); – limit: optional max number of records to return $msg->addParam(new XML_RPC_Value($uid, 'int')); $msg->addParam(new XML_RPC_Value('passwd', 'string')); $msg->addParam(new XML_RPC_Value('res.partner', 'string')); – Returns: list of IDS of records matching the given $msg->addParam(new XML_RPC_Value('create', 'string')); criteria $msg->addParam(new XML_RPC_Value($structVal, 'struct'));
$resp = $client->send($msg); // Send execution request on OpenERP $val = $resp->value() ; $id = $val->scalarval() ; 116 117 The read() ORM method The write() ORM method
• read([IDS], ['field1','field2',...]) • write([IDS], – fields: optional list of field names to return {'field1':'value1','field2':3}) (default: all fields) – Updates records with given ids with the given – Returns: the id of each record and the values of values the requested field – values: dictionary of field values to update – Returns: True
118 119
The unlink() ORM method OUTLINE
• unlink([IDS]) 1. Overview – Deletes records with the given ids – Birth and growth – Returns: True – Customers, Partners, Vendors 2. Administration – Versions, Architecture – Main modules 3. Development – Module programming – Webservice programming 4. Documentation 120 121 Documentation Books
Authors Title Editor Year Pages • Documentation Fabien Pinckaers, Tiny ERP-Open ERP : Pour une gestion Eyrolles 2008 276 – https://doc.odoo.com/ Geoff Gardiner d'entreprise efficace et intégrée F.Pinckaers, E.Van 183 – https://doc.odoo.com/7.0/fr/ Gestion commerciale et marketing avec Eyrolles 2012 Vossel, B. Proust Open ERP Pinckaers,Gardin Open ERP: a modern approach to Tiny SPRL 2011 456 er, Van Vossel integrated business management • Documentation technique Els Van Vossel, Streamline your Manufacturing Processes Tiny SPRL 2011 230 Fabien Pinckaers – https://doc.odoo.com/trunk/server/ with OpenERP Fabien Pinckaers, Open ERP for Retail and Industrial Tiny SPRL 2009 320 Geoff Gardiner Management Els Van Vossel, Integrate your Logistic Processes with Tiny SPRL 2011 230 • Free E-Books Fabien Pinckaers OpenERP – https://www.odoo.com/ebooks Els Van Vossel, Drive your Sales & Marketing Activities Tiny SPRL 2011 202 Fabien Pinckaers with OpenERP 122 123
Books Books
Authors Title Editor Year Pages Authors Title Editor Year Pages Els Van Vossel, OpenERP for Accounting and Financial Tiny SPRL 2012 188 Greg Moss Working with OpenERP Packt 2013 334 Fabien Pinckaers Management M. Belaissaoui, Gestion Commerciale avec OpenERP 7 par Éd. Univ. Eur 2013 76 Fabien Pinckaers, Analytic & Financial Accouting Book Tiny SPRL 2009 157 A. Elkafil la pratique opéennes Geoff Gardiner Karl Hellec Open ERP : Découverte et mise en œuvre GEP 2013 110 Fabien Pinckaers, Open Source Accounting with OpenERP Tiny SPRL 2011 176 Els Van Vossel Daniel Reis Odoo Development Essentials Packt 2015 214 Y. Delsart, C. Van OpenERP evaluation with SAP as reference Feridis 2011 132 Daniel Reis Odoo 10 Development Essentials Packt 2016 289 Nieuwenhuysen Greg Moss Working with Odoo 10 Packt 2017 415 Simon André Piloter Prestashop avec OpenERP Anybox 2012 27 Florent Pigout Piloter Magento avec OpenERP Anybox 2011 91 Open Object Business Intelligence Tiny SPRL 2009 113 Books for high school : S. Fasciotti, F. 2nd Bac Pro - Informatique - Office 2010, Nathan 2012 245 Open Object Developer Book Tiny SPRL 2009 213 Roche, et al. Access, Ciel, EBP PGI, OpenERP OpenERP Agile Implementation Memento Open Object 2010 5 D. Le Rouzic Activités sur... OpenERP Réseau B. Lacoste 160 OpenERP Technical Memento Open Object 2010 18 124 125