{"id":495,"date":"2014-09-26T12:04:37","date_gmt":"2014-09-26T12:04:37","guid":{"rendered":"http:\/\/www.confianzit.com\/cit-blog\/?p=495"},"modified":"2022-10-31T17:53:32","modified_gmt":"2022-10-31T17:53:32","slug":"open-source-erp-module","status":"publish","type":"post","link":"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/","title":{"rendered":"Open source ERP Module development tutorial"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;3.22&#8243;][et_pb_row _builder_version=&#8221;4.9.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; column_structure=&#8221;3_5,2_5&#8243; sticky_enabled=&#8221;0&#8243;][et_pb_column type=&#8221;3_5&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text _builder_version=&#8221;4.9.4&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; hover_enabled=&#8221;0&#8243; module_class=&#8221;blog-left-content&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h4><\/h4>\n<p>You might want to build a module for <strong>OpenERP\/<a href=\"https:\/\/www.odoo.com\" target=\"_blank\" rel=\"noopener\">Odoo<\/a><\/strong> for solving a specific problem or for sheer curiosity to build something. At Confianz we thought of helping you by coming up with a simple yet effective tutorial.<\/p>\n<p><a href=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/blog_6.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-504 \" src=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/blog_6.jpg\" alt=\"Open source ERP Module development tutorial \" width=\"466\" height=\"220\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_62 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#OpenERP_Logger_for_Connectors\" title=\"OpenERP Logger for Connectors\">OpenERP Logger for Connectors<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#Development_Strategy\" title=\"Development Strategy\">Development Strategy<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#1_Database_Design\" title=\"1)\u00a0\u00a0\u00a0 Database Design\">1)\u00a0\u00a0\u00a0 Database Design<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#1_OpenERP_module_development\" title=\"1)\u00a0\u00a0\u00a0 OpenERP module development\">1)\u00a0\u00a0\u00a0 OpenERP module development<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#1_Files_and_Usage\" title=\"1)\u00a0\u00a0\u00a0 Files and Usage\">1)\u00a0\u00a0\u00a0 Files and Usage<\/a><ul class='ez-toc-list-level-5' ><li class='ez-toc-heading-level-5'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#_i_loggerpy\" title=\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger.py\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger.py<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#_i_logger_viewxml\" title=\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger_view.xml\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger_view.xml<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#_i_init_py\" title=\"\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __init__py\">\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __init__py<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#_ii_openerp_py\" title=\"\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ii.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __openerp__.py\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ii.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __openerp__.py<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-1'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#Talk_to_our_experts_now\" title=\"    Talk to our experts now  \">    Talk to our experts now  <\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\/#Talk_To_Our_Experts_Now\" title=\"Talk To Our Experts Now\n\t\">Talk To Our Experts Now\n\t<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"OpenERP_Logger_for_Connectors\"><\/span>OpenERP Logger for Connectors<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<table width=\"673\">\n<tbody>\n<tr>\n<td width=\"217\"><a name=\"_Toc390791392\"><\/a><strong>GENERAL DESCRIPTION<\/strong><\/td>\n<td width=\"456\"><\/td>\n<\/tr>\n<tr>\n<td width=\"217\">TECHNICAL NAME OF THE MODULE<\/td>\n<td width=\"456\"><strong><em>LOGGER<\/em><\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"217\">OVERVIEW<\/td>\n<td width=\"456\">This is a generic module developed in order to log all the errors and warnings resulting from all the connectors built on <strong>OpenERP<\/strong> .<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">AIM<\/td>\n<td width=\"456\">The log should be visible only to an Administrative user, yet it should provide enough information to the Administrator\/ Development team to identify and fix any issues that occurs during import or export of data between <strong>OpenERP<\/strong> and other third party systems integrated with it.<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">ADVANTAGE<\/td>\n<td width=\"456\">\n<ul>\n<li>The advantage of this module is that it is not required to access FTP and check the error log file to analyze the error report.<\/li>\n<li>Hence, it becomes easy for non-technical users to identify all the errors or warnings that occurred in the system during the previous sync.<\/li>\n<li>This will prove to be very much of use in bulk import\/export operation. With the help of this module, the connectors are allowed to continue their action even if one the records have failed to import\/export, while user can still view the failed records.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">FUTURE ENHANCEMENTS EXPECTED<\/td>\n<td width=\"456\">\n<ul>\n<li><strong>ALERTS:<\/strong> Whenever an error is logged into this module, send an email notification consisting of the error report to the Administrator\/ Technical Team using a pre-defined email template.<\/li>\n<li><strong>TICKET CREATION &amp; ALLOCATION<\/strong>: As an error is logged, <strong>OpenERP<\/strong> will auto-create an issue ticket and assign a technician to it. Once that ticket is marked as \u2018<em>Resolved<\/em>\u2019, the logger removes the log entry corresponding to it.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">DEVELOPMENT SYSTEM REQUIREMENTS<\/td>\n<td width=\"456\">\n<ul>\n<li>Server OS: Ubuntu 12.04 LTS<\/li>\n<li>Database : Postgres 2\u00a0 , PG ADmin lll<\/li>\n<li>Luggage : Python 2.7, XML<\/li>\n<li>IDE: Eclipse with Py Dev<\/li>\n<li>Bug Reporting Tool : Mantis Bug Tracker<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5><span class=\"ez-toc-section\" id=\"Development_Strategy\"><\/span><a name=\"_Toc390791393\"><\/a>Development Strategy<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<h5><span class=\"ez-toc-section\" id=\"1_Database_Design\"><\/span><a name=\"_Toc390791394\"><\/a>1)\u00a0\u00a0\u00a0 Database Design<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>Only one new table is required for this module.<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td width=\"130\"><strong>Table name <\/strong><\/td>\n<td width=\"435\"><strong><em>logger<\/em><\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>Columns\u00a0 :<\/strong><\/td>\n<td width=\"435\"><\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>id\u00a0 <\/strong><\/td>\n<td width=\"435\">integer, primary key<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>Log_date<\/strong><\/td>\n<td width=\"435\">datetime<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>log_uid\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">integer , foreign key to res_users table<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>res_id\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">\u00a0integer\u00a0\u00a0 (holds the resource id where error is reported)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>model_name\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">character (16)\u00a0\u00a0\u00a0\u00a0 (holds the name of the model )<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>\u00a0connector\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">character\u00a0 (32)\u00a0 ( this will hold the name of the connector is the shop)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>module\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">character( 32)\u00a0\u00a0 (holds the name of the module reported the error)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>message\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">text\u00a0\u00a0 (actual error messages)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>&#8216;type&#8217;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/strong><\/td>\n<td width=\"435\">enum (import, export, delete)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>&#8216;state&#8217;\u00a0 <\/strong><\/td>\n<td width=\"435\">enum(info, error, warning)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h5><span class=\"ez-toc-section\" id=\"1_OpenERP_module_development\"><\/span><a name=\"_Toc390791395\"><\/a>1)\u00a0\u00a0\u00a0 <strong><a href=\"http:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\">OpenERP module development<\/a><\/strong><span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>The module is to be developed with a folder name as &#8216; logger&#8217;.<\/li>\n<li>The directory structure will be as follows:<\/li>\n<\/ul>\n<p>Security<\/p>\n<p>ir.model.access.csv<\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0 Static<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Src<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 img<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 icon.png<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0 logger.py<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0 Logger_view.xml<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0\u00a0 __ini<\/span><\/p>\n<p><span style=\"color: #800080;\">t__.py<\/span><\/p>\n<p><span style=\"color: #800080;\">\u00a0\u00a0\u00a0 __openerp__.py<\/span><\/p>\n<ul>\n<li>Security directory is used to specify the access controls for the class used with in the module.<\/li>\n<li>Static will be used to insert the module thumbnail icon, which will be displayed on the OpenERP module Kanban and form view.<\/li>\n<\/ul>\n<ul>\n<li>As an icon for this module, use the following PNG file sized 32*32<\/li>\n<\/ul>\n<p><a href=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/icon.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-479\" src=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/icon.png\" alt=\"icon\" width=\"159\" height=\"151\" \/><\/a><\/p>\n<ul>\n<li>Place this image file inside Static\/Src\/img folder as \u2018<em>png\u2019<\/em> so that OpenERP will automatically pick this as the thumbnail<\/li>\n<li>For this module, we will not use any Wizards (popups). Hence, the Wizard directory is not required.<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"1_Files_and_Usage\"><\/span><a name=\"_Toc390791396\"><\/a>1)\u00a0\u00a0\u00a0 Files and Usage<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<h5><span class=\"ez-toc-section\" id=\"_i_loggerpy\"><\/span><a name=\"_Toc390791397\"><\/a>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger.py<span class=\"ez-toc-section-end\"><\/span><\/h5>\n<ul>\n<li>This is the main Python file where the class the all the python modules will be defined.<\/li>\n<li><strong>STEP 1:<\/strong> Import all the packages needed, by using the \u2018<em>import\u2019<\/em><\/li>\n<\/ul>\n<p>In this module, we will be using the following packages:<\/p>\n<p>From openerp.osv import osv, fields<\/p>\n<p>\/\/ ORM class used as the base class<\/p>\n<p>import logging<\/p>\n<p>\/\/ logging is a class used in openerp for terminal and file logging<\/p>\n<p>import time<\/p>\n<p>\/\/ time is a python class for operation on time<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>STEP 2:<\/strong> Once all the packages are imported, declare the class as<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>class logger(osv.osv):<\/p>\n<p>_name = &#8216;logger&#8217;<\/p>\n<p>_description = &#8216;Log details&#8217;<\/p>\n<p>&nbsp;<\/p>\n<ul>\n<li>\n<pre><em>The first line specifies the name of the class \u2018<strong>logger<\/strong>\u2019. This class inherits from the base class osv.osv where the ORM functions ( create, write, unlink, etc.) are defined.\u00a0 <\/em><\/pre>\n<\/li>\n<li>\n<pre><em>_name is an attribute of ORM class which will be used as a reference to a class within OpenERP<\/em><\/pre>\n<\/li>\n<li>\n<pre><em>In the XML files, this reference will be used to specify this class. In OpenERP, this is called a 'model' (i.e. an ORM class ) <\/em><\/pre>\n<\/li>\n<li>\n<pre><em>_ description is used to give a small deception to that model by the developer <\/em><\/pre>\n<\/li>\n<li><strong>STEP 3:<\/strong> Define the columns within the <em>attribute _columns<\/em>, which is a dictionary. OpenERP will pick the elements inside the dictionary and create them as columns inside the database table automatically.<\/li>\n<\/ul>\n<pre style=\"padding-left: 30px;\">_columns = {<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'log_date': fields.datetime('Time', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'log_uid': fields.many2one('res.users', \"User\"),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'res_id': fields.integer('Ressource id', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'connector':fields.char('Connector', size=156, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'model_name': fields.char('Model name', size=64, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'message': fields.text('Message', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'type':fields.selection([('import','Import'),('export','Export'),('delete','Delete'),],'Action', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'state':fields.selection([('info','Info'),('warning','Warning'),('error','Error')],'State', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'module':fields.char('Module', size=64, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">\u00a0\u00a0\u00a0 }<\/pre>\n<ul>\n<li>\u2018<em>fields<\/em>\u2019\u00a0 is a class in ORM which defines the type and other attributes as a readonly, size etc. of the columns .Here we can keep all fields as <em>readonly<\/em> as log should be created by the system and not manually by the user.\n<ul>\n<li>Now we can also specify the log_date as \u2018Time\u2019 by default by using the <em>_default<\/em> attribute in the ORM<\/li>\n<\/ul>\n<p>_defaults = {<\/p>\n<p>&#8216;log_date&#8217;: lambda *a: time.strftime(&#8216;%Y-%m-%d %H:%M:%S&#8217;)<\/p>\n<p>}<\/p>\n<ul>\n<li>Next , we need the function which the connectors can use to register the log. This function will be named as: <em>register_log<\/em><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<pre>Method : register_log<\/pre>\n<pre>Argument s\u00a0\u00a0 :<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 self\u00a0\u00a0\u00a0 --\u00a0 self (this) object<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 cr\u00a0\u00a0\u00a0\u00a0 --\u00a0 Database cursor object<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 uid\u00a0\u00a0\u00a0\u00a0 - id of the logged in user<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 module\u00a0 -- character , name of the module from where the log is registered<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 connector_name\u00a0\u00a0 -- character , name of the\u00a0 connector(sore)<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 model\u00a0\u00a0\u00a0 --- character , name of the model where error is reported<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 res_id\u00a0 -- int, resource where where is reported<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 syn_type\u00a0 -- character , operation type which cause the error ,import, export or delete<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0message\u00a0 -- text<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 state --- character<\/pre>\n<pre><\/pre>\n<p><p>&nbsp;<\/p>\n<p><pre>return\u00a0\u00a0 :\u00a0\u00a0\u00a0 True<\/pre>\n<\/li>\n<li>Once we are done with the function, we can initialise the class by using:<em>logger()\u00a0 <\/em>This will end all the coding we need in the main py file.<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"_i_logger_viewxml\"><\/span><a name=\"_Toc390791398\"><\/a>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 logger_view.xml<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ul>\n<li>This is the view file for OpenERP which defines what and how data will be visible to the user in front end<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul>\n<li><strong>STEP1<\/strong>: Define the views. We require 3 types of view for this module which are<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ol>\n<li>Tree : To list the logs<\/li>\n<\/ol>\n<p>In the tree view we require the following fields to give enough information to the user:<\/p>\n<p>&lt;field name=&#8221;log_date&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;module&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;connector&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;model_name&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;res_id&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;type&#8221;\/&gt;<\/p>\n<p>&lt;field name=&#8221;state&#8221;\/&gt;<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li>Form: To display the details of a particular logger<\/li>\n<\/ol>\n<p>In form view we need all the fields to be available<\/p>\n<ol>\n<li>Search : To search for logs in OpenERP<\/li>\n<\/ol>\n<p>In Search view, users should be able to search with date, type, state, store, module, and message. User should also be able to group the log with model name and resource where error is reported<\/p>\n<p>A sample search view will be as follows:<\/p>\n<pre>\u00a0 &lt;record id=\"log_search_view\" model=\"ir.ui.view\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"name\"&gt;Log - Search&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"model\"&gt;log.details&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"arch\" type=\"xml\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;search string=\"Logs\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"log_date\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"type\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"state\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"module\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"connector\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"model_name\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0&lt;field name=\"message\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;newline\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;group expand=\"0\" string=\"Extended...\" groups=\"base.group_extended\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"res_id\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/group&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;newline\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;group expand=\"0\" string=\"Group By...\" groups=\"base.group_extended\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;filter string=\"Model\" domain=\"[]\" context=\"{'group_by':'model_name'}\"\/&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/group&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/search&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/record&gt;<\/pre>\n<ul>\n<li><strong>STEP 2<\/strong>: Once the views are defined, the next step is to define the action which will instruct OpenERP as to what view is used first:<\/li>\n<\/ul>\n<ul>\n<li>\n<pre>&lt;record id=\"act_log_details\" model=\"ir.actions.act_window\"&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"name\"&gt;Logs&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"type\"&gt;ir.actions.act_window&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"res_model\"&gt;log.details&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"view_type\"&gt;form&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;field name=\"view_mode\"&gt;tree,form&lt;\/field&gt;<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/record&gt;<\/pre>\n<\/li>\n<li>In the action, <em>res_model<\/em> refers to the class reference used in python file\n<ul>\n<li><strong>STEP 3:<\/strong> Defining the Menus where user can see the log. Place that log inside <em>Settings &gt;Technical<\/em> menu<\/li>\n<\/ul>\n<p><em>\u00a0&lt;menuitem id=&#8221;menu_log_details&#8221; parent=&#8221;base.menu_custom&#8221; name=&#8221;log Details&#8221; sequence=&#8221;50&#8243;\/&gt;<\/em><\/p>\n<p><em>&lt;menuitem id=&#8221;menu_log_details_sub&#8221; parent=&#8221;menu_log_details&#8221; name=&#8221;log Details&#8221; action=&#8221;act_log_details&#8221; sequence=&#8221;5&#8243;\/&gt;<\/em><\/p>\n<p>Now, that we are done with the view file as well.<\/p>\n<\/li>\n<li>\n<h3><span class=\"ez-toc-section\" id=\"_i_init_py\"><\/span><a name=\"_Toc390791399\"><\/a>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 i.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __init__py<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li>All the python files used with the module is imported into the python <em>init<\/em><\/li>\n<li>All the class inside logger.py file is initialized by using:<\/li>\n<\/ul>\n<p><em>import logger <\/em><\/p>\n<h3><span class=\"ez-toc-section\" id=\"_ii_openerp_py\"><\/span><a name=\"_Toc390791400\"><\/a>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ii.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 __openerp__.py<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>&nbsp;<\/p>\n<ul>\n<li>This file provides all information about this module to <a href=\"http:\/\/www.confianzit.com\">OpenERP<\/a> and also specifies the cam files used<\/li>\n<\/ul>\n<\/li>\n<li>\n<pre># -*- coding: utf-8 -*-<\/pre>\n<pre>{<\/pre>\n<pre>\u00a0\u00a0\u00a0 'name': ' Logger',<\/pre>\n<pre>\u00a0\u00a0\u00a0 'version': '1.0',<\/pre>\n<pre>\u00a0\u00a0\u00a0 'category': 'tools',<\/pre>\n<pre>\u00a0\u00a0\u00a0 'sequence': 1,<\/pre>\n<pre>\u00a0\u00a0\u00a0 'summary': \"OpenERP Logger\",<\/pre>\n<pre>\u00a0\u00a0\u00a0 'description': \"\"\"<\/pre>\n<pre>This is a package developed for Logging\u00a0 error and warning from connector modules developed for openerp\u00a0 \\n<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \"\"\",<\/pre>\n<pre>\u00a0\u00a0\u00a0 'author': 'Confianz Global',<\/pre>\n<pre>\u00a0\u00a0\u00a0 'website': 'http:\/\/confianzit.com',<\/pre>\n<pre>\u00a0\u00a0\u00a0 'images': [],<\/pre>\n<pre>\u00a0\u00a0\u00a0 'data': [<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'log.xml',<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'security\/ir.model.access.csv',<\/pre>\n<pre>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ],<\/pre>\n<pre>\u00a0\u00a0\u00a0 'depends': [base'],<\/pre>\n<pre>\u00a0\u00a0\u00a0 'installable': True,<\/pre>\n<pre>\u00a0\u00a0\u00a0 'auto_install': False,<\/pre>\n<pre>\u00a0\u00a0\u00a0 'application': True,<\/pre>\n<pre>}<\/pre>\n<\/li>\n<li>Once all these files are packed, this can be moved to OpenERP&#8217;s <em>Addons<\/em> directory and will be available in the modules list to install.<\/li>\n<li><span style=\"color: #999999;\"><em>&#8211; Happy Coding!<\/em><\/span><\/li>\n<li><span style=\"color: #999999;\"><em><span>Choosing the right ERP for your business can be tricky, but we\u2019re here to help!\u00a0<\/span><a href=\"https:\/\/www.confianzit.com\/\" class=\"rank-math-link\">Confianz<\/a><span>\u00a0has experts ready to help optimize your business. Confianz Global Inc., the best Odoo ERP development company in US provides Odoo services such as\u00a0<\/span><a href=\"https:\/\/www.confianzit.com\/openerp-customization\" class=\"rank-math-link\">Odoo customization<\/a><span>, implementation,\u00a0<\/span><a href=\"https:\/\/www.confianzit.com\/odoo-support-maintenance\" class=\"rank-math-link\">Support &amp; Maintenance Services<\/a><span>\u00a0to fulfill all your business needs.<\/span><\/em><\/span><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][\/et_pb_column][et_pb_column type=&#8221;2_5&#8243; _builder_version=&#8221;3.25&#8243; custom_padding=&#8221;|||&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_code _builder_version=&#8221;4.9.4&#8243; _module_preset=&#8221;default&#8221; locked=&#8221;off&#8221; global_module=&#8221;2151&#8243;]<\/p>\n<div class=\"blog-floating-form\"><!-- [et_pb_line_break_holder] -->  <\/p>\n<h1><span class=\"ez-toc-section\" id=\"Talk_to_our_experts_now\"><\/span><!-- [et_pb_line_break_holder] -->    Talk to our experts now<!-- [et_pb_line_break_holder] -->  <span class=\"ez-toc-section-end\"><\/span><\/h1>\n<p><!-- [et_pb_line_break_holder] -->  \n<div class=\"wpcf7 no-js\" id=\"wpcf7-f1888-o1\" lang=\"en-US\" dir=\"ltr\">\n<div class=\"screen-reader-response\"><p role=\"status\" aria-live=\"polite\" aria-atomic=\"true\"><\/p> <ul><\/ul><\/div>\n<form action=\"\/cit-blog\/wp-json\/wp\/v2\/posts\/495#wpcf7-f1888-o1\" method=\"post\" class=\"wpcf7-form init\" aria-label=\"Contact form\" novalidate=\"novalidate\" data-status=\"init\">\n<div style=\"display: none;\">\n<input type=\"hidden\" name=\"_wpcf7\" value=\"1888\" \/>\n<input type=\"hidden\" name=\"_wpcf7_version\" value=\"5.8.6\" \/>\n<input type=\"hidden\" name=\"_wpcf7_locale\" value=\"en_US\" \/>\n<input type=\"hidden\" name=\"_wpcf7_unit_tag\" value=\"wpcf7-f1888-o1\" \/>\n<input type=\"hidden\" name=\"_wpcf7_container_post\" value=\"0\" \/>\n<input type=\"hidden\" name=\"_wpcf7_posted_data_hash\" value=\"\" \/>\n<input type=\"hidden\" name=\"_wpcf7_recaptcha_response\" value=\"\" \/>\n<\/div>\n<div class=\"form-block\" style=\"    background: #fff;\">\n\t<h3 style=\"    background: #0C2464;\n    border-bottom: 5px solid #cecece;\n    border-radius: 5px 5px 90px 90px;\n    margin: 0 auto;\n    text-align: center;\n    padding: 20px;\n    color: #fff;    margin-bottom: 15px;\"><span class=\"ez-toc-section\" id=\"Talk_To_Our_Experts_Now\"><\/span><b>Talk To Our Experts Now<\/b>\n\t<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\t<div style=\"padding:20px;\">\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-name\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-text wpcf7-validates-as-required your-name\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Name\" value=\"\" type=\"text\" name=\"your-name\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-email\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-email wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-email your-email\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Email\" value=\"\" type=\"email\" name=\"your-email\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"your-number\"><input size=\"40\" class=\"wpcf7-form-control wpcf7-tel wpcf7-validates-as-required wpcf7-text wpcf7-validates-as-tel your-number\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Phone Number\" value=\"\" type=\"tel\" name=\"your-number\" \/><\/span>\n\t\t<\/p>\n\t\t<p><span class=\"wpcf7-form-control-wrap\" data-name=\"message\"><textarea cols=\"40\" rows=\"10\" class=\"wpcf7-form-control wpcf7-textarea wpcf7-validates-as-required form-message\" aria-required=\"true\" aria-invalid=\"false\" placeholder=\"Message\" name=\"message\"><\/textarea><\/span>\n\t\t<\/p>\n\t<span class=\"wpcf7-form-control-wrap recaptcha\" data-name=\"recaptcha\"><span data-sitekey=\"6LfFkQATAAAAAIYlZ_UH9UozO-OLkpAaWPWx6QtM\" class=\"wpcf7-form-control wpcf7-recaptcha g-recaptcha\"><\/span>\r\n<noscript>\r\n\t<div class=\"grecaptcha-noscript\">\r\n\t\t<iframe loading=\"lazy\" src=\"https:\/\/www.google.com\/recaptcha\/api\/fallback?k=6LfFkQATAAAAAIYlZ_UH9UozO-OLkpAaWPWx6QtM\" frameborder=\"0\" scrolling=\"no\" width=\"310\" height=\"430\">\r\n\t\t<\/iframe>\r\n\t\t<textarea name=\"g-recaptcha-response\" rows=\"3\" cols=\"40\" placeholder=\"reCaptcha Response Here\">\r\n\t\t<\/textarea>\r\n\t<\/div>\r\n<\/noscript>\r\n<\/span>\n\t\t<div class=\"form-buttons\">\n\t\t\t<p><input class=\"wpcf7-form-control wpcf7-submit has-spinner\" type=\"submit\" value=\"Get a free quote\" \/>\n\t\t\t<\/p>\n\t\t<\/div>\n\t<\/div>\n<\/div><div class=\"wpcf7-response-output\" aria-hidden=\"true\"><\/div>\n<\/form>\n<\/div>\n<!-- [et_pb_line_break_holder] --><\/div>\n<p>[\/et_pb_code][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You might want to build a module for OpenERP\/Odoo for solving a specific problem or for sheer curiosity to build something. At Confianz we thought of helping you by coming up with a simple yet effective tutorial. OpenERP Logger for Connectors GENERAL DESCRIPTION TECHNICAL NAME OF THE MODULE LOGGER OVERVIEW This is a generic module [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"<h4><\/h4>\nYou might want to build a module for <strong>OpenERP\/<a href=\"https:\/\/www.odoo.com\">Odoo<\/a><\/strong> for solving a specific problem or for sheer curiosity to build something. At Confianz we thought of helping you by coming up with a simple yet effective tutorial.\n\n<a href=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/blog_6.jpg\"><img class=\"alignnone wp-image-504 \" src=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/blog_6.jpg\" alt=\"Open source ERP Module development tutorial \" width=\"466\" height=\"220\"><\/a>\n\n<!--more-->\n<h4>OpenERP Logger for Connectors<\/h4>\n<table width=\"673\">\n<tbody>\n<tr>\n<td width=\"217\"><a name=\"_Toc390791392\"><\/a><strong>GENERAL DESCRIPTION<\/strong><\/td>\n<td width=\"456\"><\/td>\n<\/tr>\n<tr>\n<td width=\"217\">TECHNICAL NAME OF THE MODULE<\/td>\n<td width=\"456\"><strong><em>LOGGER<\/em><\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"217\">OVERVIEW<\/td>\n<td width=\"456\">This is a generic module developed in order to log all the errors and warnings resulting from all the connectors built on <strong>OpenERP<\/strong> .<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">AIM<\/td>\n<td width=\"456\">The log should be visible only to an Administrative user, yet it should provide enough information to the Administrator\/ Development team to identify and fix any issues that occurs during import or export of data between <strong>OpenERP<\/strong> and other third party systems integrated with it.<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">ADVANTAGE<\/td>\n<td width=\"456\">\n<ul>\n \t<li>The advantage of this module is that it is not required to access FTP and check the error log file to analyze the error report.<\/li>\n \t<li>Hence, it becomes easy for non-technical users to identify all the errors or warnings that occurred in the system during the previous sync.<\/li>\n \t<li>This will prove to be very much of use in bulk import\/export operation. With the help of this module, the connectors are allowed to continue their action even if one the records have failed to import\/export, while user can still view the failed records.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">FUTURE ENHANCEMENTS EXPECTED<\/td>\n<td width=\"456\">\n<ul>\n \t<li><strong>ALERTS:<\/strong> Whenever an error is logged into this module, send an email notification consisting of the error report to the Administrator\/ Technical Team using a pre-defined email template.<\/li>\n \t<li><strong>TICKET CREATION &amp; ALLOCATION<\/strong>: As an error is logged, <strong>OpenERP<\/strong> will auto-create an issue ticket and assign a technician to it. Once that ticket is marked as \u2018<em>Resolved<\/em>\u2019, the logger removes the log entry corresponding to it.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td width=\"217\">DEVELOPMENT SYSTEM REQUIREMENTS<\/td>\n<td width=\"456\">\n<ul>\n \t<li>Server OS: Ubuntu 12.04 LTS<\/li>\n \t<li>Database : Postgres 2&nbsp; , PG ADmin lll<\/li>\n \t<li>Luggage : Python 2.7, XML<\/li>\n \t<li>IDE: Eclipse with Py Dev<\/li>\n \t<li>Bug Reporting Tool : Mantis Bug Tracker<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h5><a name=\"_Toc390791393\"><\/a>Development Strategy<\/h5>\n<h5><a name=\"_Toc390791394\"><\/a>1)&nbsp;&nbsp;&nbsp; Database Design<\/h5>\n<ul>\n \t<li>Only one new table is required for this module.<\/li>\n<\/ul>\n<table>\n<tbody>\n<tr>\n<td width=\"130\"><strong>Table name <\/strong><\/td>\n<td width=\"435\"><strong><em>logger<\/em><\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>Columns&nbsp; :<\/strong><\/td>\n<td width=\"435\"><\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>id&nbsp; <\/strong><\/td>\n<td width=\"435\">integer, primary key<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>Log_date<\/strong><\/td>\n<td width=\"435\">datetime<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>log_uid&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">integer , foreign key to res_users table<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>res_id&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">&nbsp;integer&nbsp;&nbsp; (holds the resource id where error is reported)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>model_name&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">character (16)&nbsp;&nbsp;&nbsp;&nbsp; (holds the name of the model )<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>&nbsp;connector&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">character&nbsp; (32)&nbsp; ( this will hold the name of the connector is the shop)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>module&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">character( 32)&nbsp;&nbsp; (holds the name of the module reported the error)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>message&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">text&nbsp;&nbsp; (actual error messages)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>'type'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/strong><\/td>\n<td width=\"435\">enum (import, export, delete)<\/td>\n<\/tr>\n<tr>\n<td width=\"130\"><strong>'state'&nbsp; <\/strong><\/td>\n<td width=\"435\">enum(info, error, warning)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n&nbsp;\n<h5><a name=\"_Toc390791395\"><\/a>1)&nbsp;&nbsp;&nbsp; <strong><a href=\"http:\/\/www.confianzit.com\/cit-blog\/open-source-erp-module\">OpenERP module development<\/a><\/strong><\/h5>\n<ul>\n \t<li>The module is to be developed with a folder name as ' logger'.<\/li>\n \t<li>The directory structure will be as follows:<\/li>\n<\/ul>\nSecurity\n\nir.model.access.csv\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp; Static<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Src<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; img<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; icon.png<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp; logger.py<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp; Logger_view.xml<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp;&nbsp; __ini<\/span>\n\n<span style=\"color: #800080;\">t__.py<\/span>\n\n<span style=\"color: #800080;\">&nbsp;&nbsp;&nbsp; __openerp__.py<\/span>\n<ul>\n \t<li>Security directory is used to specify the access controls for the class used with in the module.<\/li>\n \t<li>Static will be used to insert the module thumbnail icon, which will be displayed on the OpenERP module Kanban and form view.<\/li>\n<\/ul>\n<ul>\n \t<li>As an icon for this module, use the following PNG file sized 32*32<\/li>\n<\/ul>\n<a href=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/icon.png\"><img class=\"alignnone size-full wp-image-479\" src=\"http:\/\/www.confianzit.com\/cit-blog\/wp-content\/uploads\/2014\/09\/icon.png\" alt=\"icon\" width=\"159\" height=\"151\"><\/a>\n<ul>\n \t<li>Place this image file inside Static\/Src\/img folder as \u2018<em>png\u2019<\/em> so that OpenERP will automatically pick this as the thumbnail<\/li>\n \t<li>For this module, we will not use any Wizards (popups). Hence, the Wizard directory is not required.<\/li>\n<\/ul>\n<h4><a name=\"_Toc390791396\"><\/a>1)&nbsp;&nbsp;&nbsp; Files and Usage<\/h4>\n<h5><a name=\"_Toc390791397\"><\/a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logger.py<\/h5>\n<ul>\n \t<li>This is the main Python file where the class the all the python modules will be defined.<\/li>\n \t<li><strong>STEP 1:<\/strong> Import all the packages needed, by using the \u2018<em>import\u2019<\/em><\/li>\n<\/ul>\nIn this module, we will be using the following packages:\n\nFrom openerp.osv import osv, fields\n\n\/\/ ORM class used as the base class\n\nimport logging\n\n\/\/ logging is a class used in openerp for terminal and file logging\n\nimport time\n\n\/\/ time is a python class for operation on time\n\n&nbsp;\n<ul>\n \t<li><strong>STEP 2:<\/strong> Once all the packages are imported, declare the class as<\/li>\n<\/ul>\n&nbsp;\n\nclass logger(osv.osv):\n\n_name = 'logger'\n\n_description = 'Log details'\n\n&nbsp;\n<ul>\n \t<li>\n<pre><em>The first line specifies the name of the class \u2018<strong>logger<\/strong>\u2019. This class inherits from the base class osv.osv where the ORM functions ( create, write, unlink, etc.) are defined.&nbsp; <\/em><\/pre>\n<\/li>\n \t<li>\n<pre><em>_name is an attribute of ORM class which will be used as a reference to a class within OpenERP<\/em><\/pre>\n<\/li>\n \t<li>\n<pre><em>In the XML files, this reference will be used to specify this class. In OpenERP, this is called a 'model' (i.e. an ORM class ) <\/em><\/pre>\n<\/li>\n \t<li>\n<pre><em>_ description is used to give a small deception to that model by the developer <\/em><\/pre>\n<\/li>\n \t<li><strong>STEP 3:<\/strong> Define the columns within the <em>attribute _columns<\/em>, which is a dictionary. OpenERP will pick the elements inside the dictionary and create them as columns inside the database table automatically.<\/li>\n<\/ul>\n<pre style=\"padding-left: 30px;\">_columns = {<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'log_date': fields.datetime('Time', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'log_uid': fields.many2one('res.users', \"User\"),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'res_id': fields.integer('Ressource id', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'connector':fields.char('Connector', size=156, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'model_name': fields.char('Model name', size=64, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'message': fields.text('Message', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'type':fields.selection([('import','Import'),('export','Export'),('delete','Delete'),],'Action', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'state':fields.selection([('info','Info'),('warning','Warning'),('error','Error')],'State', readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'module':fields.char('Module', size=64, readonly=True),<\/pre>\n<pre style=\"padding-left: 30px;\">&nbsp;&nbsp;&nbsp; }<\/pre>\n<ul>\n \t<li>\u2018<em>fields<\/em>\u2019&nbsp; is a class in ORM which defines the type and other attributes as a readonly, size etc. of the columns .Here we can keep all fields as <em>readonly<\/em> as log should be created by the system and not manually by the user.\n<ul>\n \t<li>Now we can also specify the log_date as \u2018Time\u2019 by default by using the <em>_default<\/em> attribute in the ORM<\/li>\n<\/ul>\n_defaults = {\n\n'log_date': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S')\n\n}\n<ul>\n \t<li>Next , we need the function which the connectors can use to register the log. This function will be named as: <em>register_log<\/em><\/li>\n<\/ul>\n&nbsp;\n<pre>Method : register_log<\/pre>\n<pre>Argument s&nbsp;&nbsp; :<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self&nbsp;&nbsp;&nbsp; --&nbsp; self (this) object<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cr&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp; Database cursor object<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; uid&nbsp;&nbsp;&nbsp;&nbsp; - id of the logged in user<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; module&nbsp; -- character , name of the module from where the log is registered<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connector_name&nbsp;&nbsp; -- character , name of the&nbsp; connector(sore)<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; model&nbsp;&nbsp;&nbsp; --- character , name of the model where error is reported<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res_id&nbsp; -- int, resource where where is reported<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; syn_type&nbsp; -- character , operation type which cause the error ,import, export or delete<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;message&nbsp; -- text<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state --- character<\/pre>\n<pre><\/pre>\n\n\n<pre>return&nbsp;&nbsp; :&nbsp;&nbsp;&nbsp; True<\/pre>\n<\/li>\n \t<li>Once we are done with the function, we can initialise the class by using:<em>logger()&nbsp; <\/em>This will end all the coding we need in the main py file.<\/li>\n<\/ul>\n<h4><a name=\"_Toc390791398\"><\/a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; logger_view.xml<\/h4>\n<ul>\n \t<li>This is the view file for OpenERP which defines what and how data will be visible to the user in front end<\/li>\n<\/ul>\n&nbsp;\n<ul>\n \t<li><strong>STEP1<\/strong>: Define the views. We require 3 types of view for this module which are<\/li>\n<\/ul>\n&nbsp;\n<ol>\n \t<li>Tree : To list the logs<\/li>\n<\/ol>\nIn the tree view we require the following fields to give enough information to the user:\n\n&lt;field name=\"log_date\"\/&gt;\n\n&lt;field name=\"module\"\/&gt;\n\n&lt;field name=\"connector\"\/&gt;\n\n&lt;field name=\"model_name\"\/&gt;\n\n&lt;field name=\"res_id\"\/&gt;\n\n&lt;field name=\"type\"\/&gt;\n\n&lt;field name=\"state\"\/&gt;\n\n&nbsp;\n<ol>\n \t<li>Form: To display the details of a particular logger<\/li>\n<\/ol>\nIn form view we need all the fields to be available\n<ol>\n \t<li>Search : To search for logs in OpenERP<\/li>\n<\/ol>\nIn Search view, users should be able to search with date, type, state, store, module, and message. User should also be able to group the log with model name and resource where error is reported\n\nA sample search view will be as follows:\n<pre>&nbsp; &lt;record id=\"log_search_view\" model=\"ir.ui.view\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"name\"&gt;Log - Search&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"model\"&gt;log.details&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"arch\" type=\"xml\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;search string=\"Logs\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"log_date\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"type\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"state\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"module\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"connector\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"model_name\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;field name=\"message\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;newline\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;group expand=\"0\" string=\"Extended...\" groups=\"base.group_extended\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"res_id\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/group&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;newline\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;group expand=\"0\" string=\"Group By...\" groups=\"base.group_extended\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;filter string=\"Model\" domain=\"[]\" context=\"{'group_by':'model_name'}\"\/&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/group&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/search&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/record&gt;<\/pre>\n<ul>\n \t<li><strong>STEP 2<\/strong>: Once the views are defined, the next step is to define the action which will instruct OpenERP as to what view is used first:<\/li>\n<\/ul>\n<ul>\n \t<li>\n<pre>&lt;record id=\"act_log_details\" model=\"ir.actions.act_window\"&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"name\"&gt;Logs&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"type\"&gt;ir.actions.act_window&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"res_model\"&gt;log.details&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"view_type\"&gt;form&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;field name=\"view_mode\"&gt;tree,form&lt;\/field&gt;<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;\/record&gt;<\/pre>\n<\/li>\n \t<li>In the action, <em>res_model<\/em> refers to the class reference used in python file\n<ul>\n \t<li><strong>STEP 3:<\/strong> Defining the Menus where user can see the log. Place that log inside <em>Settings &gt;Technical<\/em> menu<\/li>\n<\/ul>\n<em>&nbsp;&lt;menuitem id=\"menu_log_details\" parent=\"base.menu_custom\" name=\"log Details\" sequence=\"50\"\/&gt;<\/em>\n\n<em>&lt;menuitem id=\"menu_log_details_sub\" parent=\"menu_log_details\" name=\"log Details\" action=\"act_log_details\" sequence=\"5\"\/&gt;<\/em>\n\nNow, that we are done with the view file as well.<\/li>\n \t<li>\n<h3><a name=\"_Toc390791399\"><\/a>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; i.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __init__py<\/h3>\n<ul>\n \t<li>All the python files used with the module is imported into the python <em>init<\/em><\/li>\n \t<li>All the class inside logger.py file is initialized by using:<\/li>\n<\/ul>\n<em>import logger <\/em>\n<h3><a name=\"_Toc390791400\"><\/a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ii.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __openerp__.py<\/h3>\n&nbsp;\n<ul>\n \t<li>This file provides all information about this module to <a href=\"http:\/\/www.confianzit.com\">OpenERP<\/a> and also specifies the cam files used<\/li>\n<\/ul>\n<\/li>\n \t<li>\n<pre># -*- coding: utf-8 -*-<\/pre>\n<pre>{<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'name': ' Logger',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'version': '1.0',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'category': 'tools',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'sequence': 1,<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'summary': \"OpenERP Logger\",<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'description': \"\"\"<\/pre>\n<pre>This is a package developed for Logging&nbsp; error and warning from connector modules developed for openerp&nbsp; \\n<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \"\"\",<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'author': 'Confianz Global',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'website': 'http:\/\/confianzit.com',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'images': [],<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'data': [<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'log.xml',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'security\/ir.model.access.csv',<\/pre>\n<pre>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ],<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'depends': [base'],<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'installable': True,<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'auto_install': False,<\/pre>\n<pre>&nbsp;&nbsp;&nbsp; 'application': True,<\/pre>\n<pre>}<\/pre>\n<\/li>\n \t<li>Once all these files are packed, this can be moved to OpenERP's <em>Addons<\/em> directory and will be available in the modules list to install.<\/li>\n \t<li><span style=\"color: #999999;\"><em>- Happy Coding!<\/em><\/span><\/li>\n<\/ul>\n&nbsp;\n\n&nbsp;","_et_gb_content_width":"","footnotes":""},"categories":[1],"tags":[60,61,32,62],"_links":{"self":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/495"}],"collection":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/comments?post=495"}],"version-history":[{"count":15,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/495\/revisions"}],"predecessor-version":[{"id":2324,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/posts\/495\/revisions\/2324"}],"wp:attachment":[{"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/media?parent=495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/categories?post=495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.confianzit.com\/cit-blog\/wp-json\/wp\/v2\/tags?post=495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}