tag:blogger.com,1999:blog-37971053622009186762024-03-10T08:35:20.646+00:00OpenERP Management SystemDaniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-3797105362200918676.post-17602229054242859712013-03-20T12:16:00.002+00:002013-03-20T12:18:25.579+00:00Workaround for Kettle Steps to work with OpenERP 7The <a href="http://openerpmanagementsystem.blogspot.pt/2012/12/openerp-steps-for-pentaho-kettlepdi.html">Kettle OpenERP Output Step</a> currently doesn't work with v7.<br />
<br />
The
problem seems to be that OpenERP v7 requires the ID to exist if
specified, and the Output Step sends an ID 0 for new records. This does not work with the v7 ORM load method:<br />
<br />
<span style="font-family: courier new,monospace; font-size: small;">Failed to commit batch: <br />
Line 1 : Unknown database identifier '0'<br />(...)<br />Caused by: com.debortoliwines.openerp.<wbr></wbr>api.OpeneERPApiException: Line 1 : Unknown database identifier '0'</span><br />
<br />
<br />
A workaround is to modify the BaseModel object, _convert_records
function, so it that a zero ID is considered equivalent to an empty id. Here is the diff of the fix if you want to apply it yourself:<br />
<br />
<div>
</div>
<div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">--- openerp/osv/orm.py.orig 2013-03-20 22:21:17.892445229 +1100</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">+++ openerp/osv/orm.py 2013-03-20 22:05:12.474594534 +1100</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">@@ -1499,7 +1499,9 @@ class BaseModel(object):</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> except ValueError:</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> # in case of overridden id column</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> dbid = record['.id']</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">- if not self.search(cr, uid, [('id', '=', dbid)], context=context):</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">+ if dbid == 0:</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">+ dbid = False</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;">+ elif not self.search(cr, uid, [('id', '=', dbid)], context=context):</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> log(dict(extras,</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> type='error',</span></div>
<div>
<span style="font-family: courier new, monospace; font-size: small;"> record=stream.index,</span></div>
<div>
</div>
<div>
</div>
<div>
<br />
<br />
<span style="font-family: inherit;"><span style="font-size: small;">A <a href="https://code.launchpad.net/~dreis-pt/openobject-server/fix-kettle-steps-v7">branch with the change</a> is also available in Launchpad.</span></span></div>
</div>
Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-30549640491381852632012-12-11T10:12:00.002+00:002012-12-11T10:12:28.185+00:00OpenERP steps for Pentaho Kettle/PDI<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJh14Q-e1k7p7XtpXy22gq-p8lhJqMW_UB8a4wxqkEVZGF-cUSCRU-yNVNY7un4QrVguK_lUcJ8mI6OCULAyYpEAmM9G2xXKZLIStOiOSIRNq6aIsJXGCmErtcMcAxwP7VTdeTRE7Y8X2c/s1600/Snap+2012-12-11+at+09.34.14.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="205" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJh14Q-e1k7p7XtpXy22gq-p8lhJqMW_UB8a4wxqkEVZGF-cUSCRU-yNVNY7un4QrVguK_lUcJ8mI6OCULAyYpEAmM9G2xXKZLIStOiOSIRNq6aIsJXGCmErtcMcAxwP7VTdeTRE7Y8X2c/s320/Snap+2012-12-11+at+09.34.14.png" width="320" /></a></div>
Pentaho Kettle / PDI is a powerful tool to transfer data between systems.<br />
<br />
If you're running OpenERP in together with other applications, and need them to share data, this should be the first place to look at. Data is extracted using "input steps", transformed and then loaded using "output steps".<br />
<br />
Kettle has specialized steps for OpenERP, that interact with the OpenERP server in the proper way - through the XML-RPC API.
Unfortunately these steps are not yet available in the stable version.<br />
<br />
You try them out using the <a href="http://ci.pentaho.com/view/Data%20Integration/job/Kettle/">latest development version</a>.
The development versions, however, are not well suited for usage in a production environment. Wouldn't it be nice if you could install these OpenERP steps in a Kettle stable version?<br />
<br />
Well, I gave a try at this, and got them working with the 4.3.0-stable version.
Here's the recipe:<br />
<br />
Download the trunk version and copy the following files to the stable version:<br />
<ul>
<li>from <span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;">\data-integration\plugins\kettle-openerp-plugin\*</span></span>, and </li>
<li>from <span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;">\data-integration\libext\webservices</span></span>, the files:</li>
<ul>
<li><span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;">ws-commons-util-1.0.2.jar</span></span> </li>
<li><span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;">xmlrpc-client-3.1.3.jar</span></span>, and <span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;"> </span></span></li>
<li><span style="background-color: #eeeeee;"><span style="font-family: "Courier New",Courier,monospace;">xmlrpc-common-3.1.3.jar</span></span>. </li>
</ul>
</ul>
Now (re)start Spoon and a "!BaseStep.Category.OpenERP!" will be available containing three new steps: <a href="http://wiki.pentaho.com/display/EAI/OpenERP+Object+Delete">Delete</a>, <a href="http://wiki.pentaho.com/display/EAI/OpenERP+Object+Input">Input </a>and <a href="http://wiki.pentaho.com/display/EAI/OpenERP+Object+Output">Output</a>.<br />
<br />
Note that for some reason the "Test" button in the "Database Connection" dialog doesn't work correctly: it reports an error when testing the OpenERP server connection, even though the connection is correct. I believe that this is a <a href="http://jira.pentaho.com/browse/PDI-6768">bug that has been fixed</a> in later development branches.<br />
<br />
A big advantage for using the OpenERP API instead of the direct access to the database tables is the requests go through the ORM, so you get improved data consistency and take advantage of the ORM's <span style="font-family: "Courier New",Courier,monospace;">create()</span> and <span style="font-family: "Courier New",Courier,monospace;">write()</span> logic, and model default values.<br /><br />On the downside, these steps don't handle XML Ids, only database (integer) ids, so you need to set your own strategy to identify records, such as using "reference" or "code" fields. If your record identification relies on XML Ids, then <span style="font-family: "Courier New",Courier,monospace;">import_data()</span> base tools, such as <a href="http://openerpmanagementsystem.blogspot.pt/2012/11/pushing-data-into-openerp.html"><span style="font-family: "Courier New",Courier,monospace;">import_sqlpush</span></a>, may still be a good option.<br />
Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com11tag:blogger.com,1999:blog-3797105362200918676.post-3382194070700169862012-11-02T09:12:00.000+00:002012-12-11T10:12:52.373+00:00Pushing data into OpenERP<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWfcKRNjys6sdlDOJit0hgmgN90O_g0zCP4rwWiOYcgOZ5Sqg4-_ofOIxfAygE0KeK4-CXyU9s09oAIhtXRwYkSOvYbrFAPJcGzUzNuMmfv5QBDx2mYpxuZZ9OlB3MSfthSgKUZyJp0F4M/s1600/pushsql.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="100" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgWfcKRNjys6sdlDOJit0hgmgN90O_g0zCP4rwWiOYcgOZ5Sqg4-_ofOIxfAygE0KeK4-CXyU9s09oAIhtXRwYkSOvYbrFAPJcGzUzNuMmfv5QBDx2mYpxuZZ9OlB3MSfthSgKUZyJp0F4M/s320/pushsql.png" width="320" /></a></div>
The PushSQL module allows external apps to export data to OpenERP properly (through the ORM) just by using INSERT SQL statements.<br />
<br />
The motivation for this came from a project where an ETL service was responsible for handling synchronization of data (such as departments, customers and contracts) across several databases and applications.<br />
<br />
The ETL tool didn't have a simple way to make XML-RPC calls, and writing directly to OpenERP's tables is not a good solution.<br />
<br />
This was solved using a relatively simple "hybrid" solution. The PushSQL module provides a database table for external apps to write data to imported to OpenERP, using plain SQL INSERT statements. A scheduled job regularly looks for new rows in this table and processes them, making the intended changes to OpenERP data.<br />
<br />
The table , <span style="font-family: "Courier New",Courier,monospace;">import_pushsql</span>, has two mandatory columns: <span style="font-family: "Courier New",Courier,monospace;">model</span> and <span style="font-family: "Courier New",Courier,monospace;">data</span>. The first is the target model, such as <span style="font-family: "Courier New",Courier,monospace;">res.partner</span>. The second contains the data to import, using the format for CSV files, but using TAB instead of comma as the column separator.<br />
<br />
For example, using PSQL:<span style="font-family: "Courier New",Courier,monospace;"></span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"></span></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">INSERT INTO import_pushsql (model, data) VALUES ('res.partner', E</span></span><b>'id</b><span style="color: blue;">\t</span><b>name</b><span style="color: blue;">\t</span><b>ref</b></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">\n</span><b>res_partner_XXX</b><span style="color: blue;">\t</span><b>Demo Customer</b><span style="color: blue;">\t</span><b>XXX'</b></span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">) </span></span></span><br />
<br />
Or, if using SQL Server: <br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"></span></span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">INSERT INTO import_pushsql (model, data) VALUES ('res.partner', </span></span></span><br />
<span style="font-family: "Courier New",Courier,monospace;"><b>'id' </b><span style="color: blue;">+char(9)+ </span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"></span></span><b>'name</b></span><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b>' </b></span></b><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">+char(9)+</span></span><b><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"></span></span><b> '</b></span></b><span style="color: blue;"></span><b>ref</b></span><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b>'</b></span></b><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"> +char(10)+<b> </b></span></span><b><span style="font-family: "Courier New",Courier,monospace;"><b>'</b></span></b></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"></span><b>res_partner_XXX</b></span><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b>' </b></span></b></span></b><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">+char(9)+ </span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"></span></span></span></span><b><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b>'</b></span></b></span></b><span style="color: blue;"></span><b>Demo Customer</b></span><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b>' </b></span></b></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"></span></b><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">+char(9)+</span></span><b><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"></span></span></span></b></span></span></span><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;"><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><b><span style="font-family: "Courier New",Courier,monospace;"><b> '</b></span></b></span></span></b></span></span></span><b>XXX'</b><br />
<span style="font-family: "Courier New",Courier,monospace;"><span style="font-family: "Courier New",Courier,monospace;"><span style="color: blue;">) </span></span></span><br />
<br />
The scheduled action uses this to run a standard <a href="http://doc.openerp.com/v6.0/developer/2_5_Objects_Fields_Methods/methods.html#osv.osv.osv.import_data"><span style="font-family: "Courier New",Courier,monospace;">import_data</span></a> ORM method, writes the result into the <span style="font-family: "Courier New",Courier,monospace;">log</span> column, and changes the <span style="font-family: "Courier New",Courier,monospace;">state</span> to <span style="font-family: "Courier New",Courier,monospace;">'done'</span> if successful, or <span style="font-family: "Courier New",Courier,monospace;">'cancel'</span> if an error was found.<br />
<br />
Compared to the "pull" approach used by the <a href="http://openerpmanagementsystem.blogspot.pt/2012/09/import-odbc-modules-steps-up.html"><span style="font-family: "Courier New",Courier,monospace;">import_odbc</span></a> module, this "push" approach can provide a few advantages: <br />
<ul>
<li> No need to install other database clients and middleware in OpenERP's server.</li>
<li>It uses less resources on OpenERP server, because there is no need to connect to other servers.</li>
<li>Event driven data sync, where an action in another system immediately triggers a write on OpenERP that can be processed within a few minutes.</li>
</ul>
There is also an obvious disadvantage: the process exporting the data does not have an immediate visibility on the outcome of the OpenERP transaction . There are ways to provide this feedback, but it's not immediate. <br />
<br />
Overall, the PushSQL module can provide a very simple and straighforward way for business apps to safely send data to OpenERP, in scenarios where using the API is not an option or would be too cumbersome.<br />
<br />
The <span style="font-family: "Courier New",Courier,monospace;">import_pushsql</span> can be downloaded either from <a href="http://apps.openerp.com/addon/8374">OpenERP Apps</a> or from <a href="http://bazaar.launchpad.net/~dreis-pt/reis-openerp-addons/trunk/files/head:/import_sqlpush/">Launchpad</a> using:<span style="font-family: "Courier New",Courier,monospace;"> bzr branch lp:reis-openerp-addons</span><br />
<br />
<br />Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com7tag:blogger.com,1999:blog-3797105362200918676.post-10534092962525410082012-09-19T10:02:00.000+01:002012-10-11T23:25:18.436+01:00Import ODBC module steps upThe <a href="http://openerpmanagementsystem.blogspot.pt/2012/05/importing-data-from-odbc-sources.html"><span style="font-family: "Courier New",Courier,monospace;">import_odbc</span></a> module for OpenERP was recently improved and moved to the <a href="https://launchpad.net/openobject-extension">OpenObject Extension</a> community project. the original module is now split in two: <span style="font-family: "Courier New",Courier,monospace;">base_external_dbsource</span> and <span style="font-family: "Courier New",Courier,monospace;">import_odbc</span>.<br />
<br />
The <span style="font-family: "Courier New",Courier,monospace;">import_odbc</span> code was refactored, but keeps the same funcionality as before. Documentation was improved and some examples are provided out of the box. <br />
<br />
The <span style="font-family: "Courier New",Courier,monospace;">base_external_dbsource</span> was created to isolate the logic for connecting to external databases and executing SQL queries. It's used by <span style="font-family: "Courier New",Courier,monospace;">import_odbc</span>, but it also enables other modules to fetch foreign data on the fly.<br />
<br />
Additionally, the connection types supported were extended. Support for ODBC and Oracle native connections is kept, and support for other native connections was added:<br />
<ul><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6DlS-Je64ycuoxd4oX3w8_ExFd0C_sRTTEcSty7XsFjtojkUFG1SfFgTand9V7oKYHKFZsP0fY8RpchvmyHxLm995yoA9W3AdGPebKUmXIGt9-FIj6MT9RhRfyAJWI4FgGb7GqWD9CIux/s1600/Snap+2012-09-19+at+09.52.55.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" height="160" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6DlS-Je64ycuoxd4oX3w8_ExFd0C_sRTTEcSty7XsFjtojkUFG1SfFgTand9V7oKYHKFZsP0fY8RpchvmyHxLm995yoA9W3AdGPebKUmXIGt9-FIj6MT9RhRfyAJWI4FgGb7GqWD9CIux/s320/Snap+2012-09-19+at+09.52.55.png" width="320" /></a>
<li>MS SQL Server</li>
<li>MySQL</li>
<li>PostgreSQL</li>
<li>SQLite</li>
</ul>
With this evolution, it would be more fair to name the module as "import_sql" instead of the "import_odbc", but the name was kept unchanged to avoid confusing current users.<br />
<br />
You can get the latest version of these modules from the OpenObject Extension <a href="https://code.launchpad.net/%7Eextra-addons-commiter/openobject-extension/trunk">trunk branch</a>:<br />
<div style="font-family: "Courier New",Courier,monospace;">
bzr branch lp:openobject-extension</div>
<br />
Share you experiences and feature wishlists with us!<br />
<br />Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com4tag:blogger.com,1999:blog-3797105362200918676.post-41460908636431498202012-09-14T17:55:00.002+01:002012-09-19T10:05:16.990+01:00Using codes to search and enter data in OpenERP formsUsing codes to refer to entities, such as customers or employees, is a common practice, and widely used in ERPs. To users familiar with this method it's natural to have the code displayed alongside with the description, and to enter data in a form field by directly typing a code.<br />
<br />
This feature can be easilly added to OpenERP using the <span style="font-family: "Courier New",Courier,monospace;">refcodes</span> family of modules, available in <a href="https://launchpad.net/reis-openerp-addons">Launchpad</a>. For example, in the HR module an employee selection list might look like this:<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicuS8Zb3aslKtb0vIPJvs5GOjxFFI9zT5lNp5rkBfhuhNxuccOSVW2eiEeyKY-wMyiVie8m5dyFc_KBFTvVUwyB6RDlb9tj98cLItc4GnVT-YFAh_6u3vzpj-jGw1H7MupHizXYNLAUmNg/s1600/refcode_demo.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicuS8Zb3aslKtb0vIPJvs5GOjxFFI9zT5lNp5rkBfhuhNxuccOSVW2eiEeyKY-wMyiVie8m5dyFc_KBFTvVUwyB6RDlb9tj98cLItc4GnVT-YFAh_6u3vzpj-jGw1H7MupHizXYNLAUmNg/s1600/refcode_demo.png" /></a></div>
Have fun.Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-76053052412638646332012-07-19T15:41:00.000+01:002012-07-19T15:41:34.518+01:00Trigger-like Automated ActionsOpenERP's <a href="http://apps.openerp.com/addon/713?filter=%7B%22order_by%22%3A+%22title%22%2C+%22author%22%3A+28%7D&page=1">Automated Actions</a> is a module usually associated with the CRM modules, allowing to <a href="http://doc.openerp.com/v6.1/book/2/3_CRM_Contacts/opport.html#planning-your-next-actions">automate sales process steps,</a> without the need to write Python code.<br />
<br />
Each automated action rule operates on an OpenERP model, any model. It's behaviour is defined through three tabs:<br />
<ul>
<li><b>Conditions</b> tell when the rule is fired.</li>
<li><b>Actions</b> tell what operations should be done, like setting a specific user as Responsible person, or running a Server Action.</li>
<li><b>E-mail</b> actions allows to define e-mail messages to be sent .</li>
</ul>
<br />
Conditions can be activated at scheduled moments. This is the sole purpose of the "Conditions on Time" section. The scheduler action evaluates these conditions to decide what rules to trigger. This allows you to configure actions like "send an e-mail reminder two days after last action date".<br />
<br />
<br />
The remaining conditions are evaluated immediately when a record is saved. This allows you to configure actions like "send an e-mail when state is changed to In Progress".<br />
<br />
<br />
While you get the feeling of having a lot of potential to easily customize a customer's very specific business rules, actually the module reveals to fall short on the expectations.<br />
For instance, it's not possible to create conditions for:<br />
<ul>
<li>When a new Issue is created, sending an e-mail informing the new Issue;</li>
<li>When the Responsible is changed, sending an e-mail informing the new responsible person.</li>
</ul>
Also, the e-mail actions definition is very confusing and limited. The e-mail Subject line is not configurable, and the message body can only use a small list of keyword to include data from the document.<br />
<br />
The <b><a href="http://apps.openerp.com/addon/7738"><span style="font-family: "Courier New",Courier,monospace;">reis_base_action_rule_triggers</span> module</a> </b>overcomes these limitations and unlocks a lot of the power of the standard module. This is done through two simple additions:<br />
<ul>
<li>Conditions can be defined by an "Evaluated expression", that can work on record's old and new values.</li>
<li>Actions can send an e-mail using v6.1 Email templates, a lot more powerful than the "e-mail actions" options, making them obsolete.</li>
</ul>
In the condition expressions some variables are available (inspiration came from Oracle's database triggers):<br />
<ul>
<li><span style="font-family: "Courier New",Courier,monospace;">inserting</span>, <span style="font-family: "Courier New",Courier,monospace;">creating</span>: boolean indicating it's a new record is being created;</li>
<li><span style="font-family: "Courier New",Courier,monospace;">updating</span>, <span style="font-family: "Courier New",Courier,monospace;">writing</span>: boolean indicating it's an existing record being changed;</li>
<li><span style="font-family: "Courier New",Courier,monospace;">new</span>: a dictionary with all the values after the record is changed;</li>
<li><span style="font-family: "Courier New",Courier,monospace;">old</span>: a dictionary with all the values before the record was changed;</li>
<li><span style="font-family: "Courier New",Courier,monospace;">changed</span>: a dictionary with only the values that actually changed, even if rewritten (empty if not updating);</li>
<li><span style="font-family: "Courier New",Courier,monospace;">obj</span>: browseable record object, allowing dot notation, with the new/changed record.</li>
</ul>
Here are some real examples used in a production environment for the Project Issue module:<br />
<br />
<br />
<i>New issue is created, or is reactivated:<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;"></span></i><br />
<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;">inserting or changed.get('state') == 'draft'</span><br />
<br />
<br />
<i>Issue is closed or cancelled:</i><br />
<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;">changed.get('state') in ('done', 'cancel')</span><br />
<br />
<br />
<i>Issue's Responsible changed:</i><br />
<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;">old.get('user_id') and new.get('user_id') </span><br />
<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;">and old.get('user_id') != new.get('user_id') </span><br />
<span style="background-color: #eeeeee; font-family: "Courier New",Courier,monospace;">and not new.get('date_open') #date_open is written only by Open issue</span><br />
<br />
I hope this turn out useful to more people, and would love to hear about your experience with this module.Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com6tag:blogger.com,1999:blog-3797105362200918676.post-74054417989972120232012-07-04T16:39:00.002+01:002012-07-04T16:39:44.971+01:00How to: allow Project Users to record Time on Tasks for anyoneIf you have <span style="font-family: "Courier New",Courier,monospace;">hr_timesheet</span> installed, users also in the Employee group will only be able to record time on tasks for themselves. If you need Project Users or Managers to be able to record time for other persons, just add the following Record Rule:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglXNK9Rf8QZD4AREMr1-eURX88crziHzKmxysjmailmrkWGJLaFrES0YR9ZrLldgZAfY49n-9AeRdgg-1olpZ4yH-Od06za_J5d1pdmzV4701MAE-MurznTLZ7jFWU2r3LN8joLYL91aWG/s1600/Snap+2012-07-04+at+16.34.11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="202" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglXNK9Rf8QZD4AREMr1-eURX88crziHzKmxysjmailmrkWGJLaFrES0YR9ZrLldgZAfY49n-9AeRdgg-1olpZ4yH-Od06za_J5d1pdmzV4701MAE-MurznTLZ7jFWU2r3LN8joLYL91aWG/s320/Snap+2012-07-04+at+16.34.11.png" width="320" /></a></div>
<br />
<span id="goog_874825140"></span><span id="goog_874825141"></span>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-44049424216921562912012-06-26T10:08:00.000+01:002012-06-26T10:27:48.727+01:00An OpenERP Apps and dependencies installerWhile the <a href="http://apps.openerp.com/">apps.openerp.com</a> site provides access to community modules, there is no way to automatically download a module and all it's dependencies. The problem is even worse if the dependency modules are hosted in different branches.<br />
<br />
For this, I created a tool to assist in downloading a module and all it's dependencies, in a way similar to Python's<span style="background-color: white;"> </span><span style="background-color: white; font-family: "Courier New",Courier,monospace;">pip</span><span style="background-color: white;"> or Ubuntu's </span><span style="background-color: white; font-family: "Courier New",Courier,monospace;">apt-get</span><span style="background-color: white;">.</span><br />
<br />
Here is a quick-start demo:<br />
<br />
First, position your command line on your target "addons" directory. For demonstration purposes, let's use a temporary location:<br />
<br />
<span style="color: blue; font-family: "Courier New",Courier,monospace;">mkdir /tmp/addons</span><br />
<span style="color: blue; font-family: "Courier New",Courier,monospace;">cd /tmp/addons</span><br />
<br />
Now install the "apps" tool and specify the OpenERP version you are working with:<br />
<br />
<span style="color: blue; font-family: "Courier New",Courier,monospace;">bzr checkout --lightweight lp:~dreis-pt/+junk/apps</span><br />
<span style="color: blue; font-family: "Courier New",Courier,monospace;">apps/init 6.1</span><br />
<br />
Finally, use "apps/get" to download the modules you need. The tool will search in an index for their branch location, download and copy to the current addons directory. Let's try it with two different asterik related modules:<br />
<br />
<span style="color: blue; font-family: "Courier New",Courier,monospace;">apps/get asterisk_click2dial asterisk360</span><br />
<br />
The apps/get command depends on pre-genererated index files. The program to generate these indexes is also provided, but that's a long running operation, ment to be regularly executed by a server.<br />
<br />
I know there are a lot of things to improve, but the current version is perfectly usable. I feel this could be an important tool for the community, so comments would be very welcome.Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-72579265910587290262012-05-21T22:17:00.000+01:002012-05-21T22:17:16.296+01:00Connect to SQL Server from UbuntuConnecting an Ubuntu box to a MS SQL Server can by achieved through the <a href="http://www.freetds.org/">FreeTDS</a> ODBC driver.<br />
<br />
Here goes a small recipe to install it:<br />
<br />
<div style="font-family: "Courier New",Courier,monospace;">
sudo apt-get update</div>
<div style="font-family: "Courier New",Courier,monospace;">
sudo apt-get install tdsodbc</div>
<div style="font-family: "Courier New",Courier,monospace;">
</div>
<div style="font-family: "Courier New",Courier,monospace;">
sudo apt-get install unixodbc unixodbc-dev</div>
<div style="font-family: "Courier New",Courier,monospace;">
sudo apt-get install python-setuptools</div>
<div style="font-family: "Courier New",Courier,monospace;">
sudo easy_install pyodbc</div>
<div style="font-family: "Courier New",Courier,monospace;">
</div>
<div style="font-family: "Courier New",Courier,monospace;">
sudo echo -e "[FreeTDS]\nDriver=/usr/lib/odbc/libtdsodbc.so" >> /etc/odbcinst.ini</div>
<br />
Now you can open a Python interpreter and <a href="http://code.google.com/p/pyodbc/wiki/GettingStarted">test the connection using pyodbc</a>.<br />
This may speed you up if you're trying to <a href="http://openerpmanagementsystem.blogspot.pt/2012/05/importing-data-from-odbc-sources.html">import SQL Server data to OpenERP.</a><br />
<br />Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-76054430904341661592012-05-17T10:37:00.003+01:002012-05-17T10:37:32.047+01:00Importing data from ODBC sources<br />
With the <span style="font-family: 'Courier New', Courier, monospace;">import_odbc</span> OpenERP you can import data directly from other databases, such as Oracle or SQL Server, and schedule them to run regularly. Usage examples are to automatically update Customer data from a CRM app or Employee data from a HRIS/Payroll app.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX5MPYWNViFiqlk7AR4FTEO-mImSJS-v1pJrcq7binbiZG1mm3z75v2rF4ASP56QIJKZQYMAqUyl2Q1lNjTHyCvTWjclx-dCNGBtf5DbR7bkQgj20Tmthk-CqFsCyrlLMukVRezVYpZtFs/s1600/Snap+2012-05-17+at+10.03.51.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhX5MPYWNViFiqlk7AR4FTEO-mImSJS-v1pJrcq7binbiZG1mm3z75v2rF4ASP56QIJKZQYMAqUyl2Q1lNjTHyCvTWjclx-dCNGBtf5DbR7bkQgj20Tmthk-CqFsCyrlLMukVRezVYpZtFs/s400/Snap+2012-05-17+at+10.03.51.png" width="400" /></a></div>
<br />
The import is done using the standard <span style="font-family: 'Courier New', Courier, monospace;">import_data()</span> ORM method, used when importing data through the user interface. So, it benefits from all its features, including relationship reconnecting (<span style="font-family: 'Courier New', Courier, monospace;">:id</span> or <span style="font-family: 'Courier New', Courier, monospace;">/id</span> columns).<br />
<br />
Each import has a SQL statement used to build the equivalent for an import file. The column titles are given by the SQL's column names.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimyZOzgZvq_mPOOGikdrWNET1FMox_8uwJZxuOfqCtj1zh-7bN2JnEU_oube_wClCs5UWFFKXx8gEHompQqIrzvKXMjXp1zkkrG70upBEXFY5Eqej6NO7KwLIu_pR3NfWtwpLkPwWFbFzA/s1600/Snap+2012-05-17+at+10.02.46.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="271" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimyZOzgZvq_mPOOGikdrWNET1FMox_8uwJZxuOfqCtj1zh-7bN2JnEU_oube_wClCs5UWFFKXx8gEHompQqIrzvKXMjXp1zkkrG70upBEXFY5Eqej6NO7KwLIu_pR3NfWtwpLkPwWFbFzA/s400/Snap+2012-05-17+at+10.02.46.png" width="400" /></a></div>
<br />
The first column in the SQL should provide a unique identifier for each record, and will be used to build it's xml_id. This id allows subsequent imports to update previously imported rows, instead of duplicating them. The xml_is is built using the form <span style="font-family: 'Courier New', Courier, monospace;">[MODEL_ID]_id_[UQ_ID]</span>. For example: <span style="font-family: 'Courier New', Courier, monospace;">product_product_id_9999</span>. This is important to remember when importing several tables with relationships between them. Columns titled "None" are ignored, so if you don't need to write the unique id to OpenERP, you can name the SQLs first column as "None".<br />
<br />
For example, to keep the Products table updated with a product list in another company database, the SQL would look like this:<br />
<span style="font-family: 'Courier New', Courier, monospace;">SELECT ID as "None", PRODUCT_CODE as "ref", PRODUCT_NAME as "name", 'product_category_id_'+CATEGORY_ID as "categ_id/id"</span><br />
<span style="font-family: 'Courier New', Courier, monospace;">FROM T_PRODUCTS </span><br />
<span style="font-family: 'Courier New', Courier, monospace;">WHERE DATE_CHANGED >= ? </span><br />
<br />
The "?" is replaced by the last successful sync date. This date is updated after each successfull import run.<br />
This way it's possible to import only the rows changed since last execution, so you can schedule frequent low-volume imports.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4voEITGSXg23zcOo0FBDFy8kl_kAdGpmjeu-1ET_o9jP1xPjoshLrOxkjFAGpayaVmF2mmavbQuLOidZNnZbRTeTyHt5dHFWex6iB-ym4CyvGTyljAgz5Wv2HMJDECUPzQwiX6wQkoGCl/s1600/Snap+2012-05-17+at+10.05.50.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="147" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4voEITGSXg23zcOo0FBDFy8kl_kAdGpmjeu-1ET_o9jP1xPjoshLrOxkjFAGpayaVmF2mmavbQuLOidZNnZbRTeTyHt5dHFWex6iB-ym4CyvGTyljAgz5Wv2HMJDECUPzQwiX6wQkoGCl/s400/Snap+2012-05-17+at+10.05.50.png" width="400" /></a></div>
<br />
Recently a feature was added to be able to tolerate to errors when trying to reconnect relationships. Using the previous example, if the product supplier's xml_id is not found, the product import would fail. But if you activate the "Ignore relationship errors" flag, the import would be retried without the "product_category_id/id" column, importing the product with an empty Category field.<br />
<br />
You can find the <span style="font-family: 'Courier New', Courier, monospace;">import_odbc</span> module in Launchpad's branch:<br />
<span style="font-family: 'Courier New', Courier, monospace;">lp:~dreis-pt/addons-tko/reis</span>.<br />
<br />Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0tag:blogger.com,1999:blog-3797105362200918676.post-55998467246623013722012-03-02T18:16:00.001+00:002012-09-21T08:58:19.683+01:00Webkit reports in a X-less server<br />
<div lang="zxx">
If you try to run webkit reports in linux system
without an X-server (no system GUI), you will probably get error
message. This can be caused by the wkhtmltopdf library, used by
Webkit report to convert HTML into PDF, because needs to use an
X-server to do the conversion.</div>
<div lang="zxx">
To can confirm if this is your problem with this:<br />
<span style="font-family: 'Courier New',Courier,monospace;"># echo test>in.txt; wkhtmltopdf in.txt out.pdf</span></div>
<div lang="zxx">
<span style="font-family: 'Courier New',Courier,monospace;">wkhtmltopdf: cannot connect to X server</span><br />
<b><br /></b>
<b>A </b><a href="http://stackoverflow.com/questions/3713004/help-installing-static-binary-for-wkhtmltopdf">workaround</a> to this is to install the static
version of the wkhtmltopdf
library, (more details info on
). The procedure, using a root account, is this:</div>
<pre class="western" lang="zxx"><span style="font-family: 'Courier New',Courier,monospace;"><span style="color: black;"># apt-get update</span>
<span style="color: black;"><span lang="zxx"># apt-get remove wkhtmltopdf</span></span>
<span style="color: black;"><span lang="zxx"># apt-get install openssl build-essential xorg libssl-dev</span></span>
<span style="color: black;"><span lang="zxx"># cd /tmp</span></span>
<span style="color: black;"><span lang="zxx"># wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2 </span></span>
<span style="color: black;"><span lang="zxx"># tar xvjf wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2</span></span>
<span style="color: black;"><span lang="zxx"># chown root:root wkhtmltopdf-i386</span></span>
<span style="color: black;"><span lang="zxx"># mv wkhtmltopdf-i386 /usr/bin/wkhtmltopdf</span></span>
<span style="color: black;"><span lang="zxx"># rm wkhtmltopdf-0.11.0_rc1-static-i386.tar.bz2</span></span></span>
</pre>
<div lang="zxx">
<br />
Now test it again. You should get this output:</div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">#
echo test>in.txt; wkhtmltopdf in.txt out.pdf</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Loading
pages (1/6)</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Counting
pages (2/6)</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Resolving
links (4/6)</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Loading
headers and footers (5/6)</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Printing
pages (6/6)</span></div>
<div lang="zxx">
<span style="color: black; font-family: 'Courier New',Courier,monospace;">Done</span></div>
<div lang="zxx">
<br />
Remeber
you must provide the path to wkhtmltopdf in the Company form (at
Settings/Administration » Companies » Companies » Webkit tab »
Webkit Executable Path). Usualy it's <span style="font-family: 'Courier New',Courier,monospace;">/usr/bin/wkhtmltopdf</span>, but you
can confirm that with this command:</div>
<pre class="western" lang="zxx"><span style="color: black; font-family: 'Courier New',Courier,monospace;"># which wkhtmltopdf</span></pre>
Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com1tag:blogger.com,1999:blog-3797105362200918676.post-80655725861628206812012-02-02T13:57:00.000+00:002012-07-19T10:03:25.512+01:00Configuring LDAP authentication with Active Directory<br />
First install the python-ldap library:<br />
<span style="font-family: 'Courier New',Courier,monospace;">[sudo] apt-get install python-ldap</span><br />
<br />
Then install OpenERP's <span style="font-family: 'Courier New',Courier,monospace;">user_ldap</span> module.<br />
Go to Administration » Companies, select your company, find the "Configuration" tab, and on the "LDAP Configuration" box click "New" to add a LDAP configuration.<br />
<br />
Complete the requested information:<br />
<ul>
<li><b>LDAP Server address</b>:<span style="font-family: 'Courier New',Courier,monospace;"> your.adserver.address</span></li>
<li><b>LDAP Server port</b>: <span style="font-family: 'Courier New',Courier,monospace;">3268</span></li>
<li><b>LDAP binddn</b>: <span style="font-family: 'Courier New',Courier,monospace;">your-domain\a-username</span></li>
<li><b>LDAP password</b>: your<span style="font-family: 'Courier New',Courier,monospace;">-password</span></li>
<li><b>LDAP base</b>: <span style="font-family: 'Courier New',Courier,monospace;">DC=your-domain,DC=local</span></li>
<li><b>LDAP filter</b>: <span style="font-family: 'Courier New',Courier,monospace;">sAMAccountName=%s</span></li>
<li><b>Create User</b>: Yes</li>
<li><b>Model User</b>: Your template user</li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicF3VI5YeyTBvXjOlHq4HZdmVOAVv3KFEIODo-R8S9j55NcI7Xd8kk2OBwYBiM8ofPfcbmYKjZQ7tfwDkmxTBs9V-w_MImYn4fXy1Sm-aMdG_iMZyLk4DyKZBJDbKls8_MszwbH4ZK-cZo/s1600/Openerp-LDAP.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="268" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEicF3VI5YeyTBvXjOlHq4HZdmVOAVv3KFEIODo-R8S9j55NcI7Xd8kk2OBwYBiM8ofPfcbmYKjZQ7tfwDkmxTBs9V-w_MImYn4fXy1Sm-aMdG_iMZyLk4DyKZBJDbKls8_MszwbH4ZK-cZo/s400/Openerp-LDAP.png" width="400" /></a></div>
<br />
The parameters <span style="font-family: 'Courier New',Courier,monospace;">bindn</span> and <span style="font-family: 'Courier New',Courier,monospace;">password</span> can be ignored if the AD server is configured to allow anonymous connections. In this case, we preferred to create a generic user to connect to the AD.<br />
<br />
When someone tries to login to OpenERP for the first time, it's full name is retrieved from the AD and a new Openerp user is created copying from the template user. So, this template user should have assigned default access groups for everyone in the domain.<br />
<br />
You might need to adjust some of these setting to your specific AD structure. I found <a href="http://www.ldapadministrator.com/info_softerra-ldap-browser.htm">Softerra's free LDAP browser</a> to be useful to explore the AD structure, or just to test the LDAP configuration parameters.<br />
<div>
<br /></div>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com9tag:blogger.com,1999:blog-3797105362200918676.post-18933514038611773412012-02-02T08:55:00.000+00:002012-02-10T18:15:56.198+00:00OpenERP easy installation using SISalp's xoe script<a href="http://sisalp.fr/">SISalp</a> has developed a script to automate OpenERP server installation, and was kind enough to share it to the public with GPL license. Let's use it to build an OpenERP server based on a clean <a href="http://www.turnkeylinux.org/lapp">Turnkey LAPP appliance</a>.<br />
<br />
<b>First, update the virtual machine's system.
</b><br />
After installing the virtual machine, which should be pretty straightforward, you might want to update the system. Be aware that there is a <a href="http://www.turnkeylinux.org/forum/support/20100928/tkl-lucid-core-apt-get-upgrade-freeze-installing-udev-151-121">known issue</a> with the <code><span style="font-family: 'Courier New', Courier, monospace;">udev</span></code> library, causing the update of Turnkey appliances process to freeze. To avoid it you should do the update using:<br />
<span style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
<span style="font-family: 'Courier New', Courier, monospace;">apt-get update</span><br />
<code><span style="font-family: 'Courier New', Courier, monospace;">
echo udev hold|dpkg --set-selections<br />
apt-get upgrade<br />
</span></code><br />
<b><br /></b><br />
<b>Second, install OpenERP, using SISalp's XOE script.</b><br />
Following the <a href="https://docs.google.com/document/d/1lKIHZcc3TFOUrjQebQ-sVyQ000mIv9gkxJSbCt0JQjE/edit?hl=fr&pli=1">instructions</a>, logged in as <span style="font-family: 'Courier New', Courier, monospace;">root</span>, execute:<br />
<br />
<span style="font-family: 'Courier New', Courier, monospace;">cd /usr/local/bin</span><br />
<code><span style="font-family: 'Courier New', Courier, monospace;">wget http://download.sisalp.net/install_xoe</span></code><br />
<code><span style="font-family: 'Courier New', Courier, monospace;">chmod 755 install_xoe</span></code><br />
<code><span style="font-family: 'Courier New', Courier, monospace;">./install_xoe</span></code><br />
<br />
And that's it.<br />
<br />
The script will create the PostgreSQL database, install the application server, the web server and register them as services. The monitoring and management of the servers can be done through the <code>xoe</code> utility. For example, use <code>xoe --status</code> to check which services are running.<br />
<br />
I find very interesting the ability to setup and manage other servers, for training and testing purposes.
The documentation also mentions the possibility of setting up backups and e-mail alerts to the system administrator.
The tool is rich in features, but it would be nice to have a little more documentation available, such as a good guide for all these functions.<br />
<br />
<i>EDIT: install_xoe_openerp is deprecated - <b>install_xoe</b> should be used instead.</i>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com3tag:blogger.com,1999:blog-3797105362200918676.post-48047050633992981352011-12-12T10:17:00.001+00:002012-02-02T08:28:28.047+00:00Debugging in Python and OpenERP<br />
<b>Python debugger</b><br />
Python provides a library for debugging called <span style="font-family: 'Courier New', Courier, monospace;">pdb</span>.To use it, import the <span style="font-family: 'Courier New', Courier, monospace;">pdb</span> module and add <span style="font-family: 'Courier New', Courier, monospace;">pdb.set_trace()</span> at the line you want to start debugging.<br />
When execution reaches that point, the console will prompt you for interactive debugging commands.<br />
The most important are:<br />
<ul>
<li><span style="font-family: 'Courier New', Courier, monospace;">(n)ext</span>, to step over to the next command.</li>
<li><span style="font-family: 'Courier New', Courier, monospace;">(l)ist</span>, to display the code around your current position.</li>
<li><span style="font-family: 'Courier New', Courier, monospace;">(p)rint</span>, to look into variables or test expressions.</li>
<li><span style="font-family: 'Courier New', Courier, monospace;"><span style="font-family: 'Courier New', Courier, monospace;">(pp)rint</span><span style="font-family: 'Times New Roman';">, to pretty print expressions or variables. Useful for lists and dictionaries.</span></span></li>
<li><span style="font-family: 'Courier New', Courier, monospace;">(c)ontinue</span> running the rest of the code</li>
</ul>
You can also step in and out of subroutines:<br />
<ul>
<li><span style="font-family: 'Courier New', Courier, monospace;">(s)tep</span> into the subroutines, used instead of (n)</li>
<li><span style="font-family: 'Courier New', Courier, monospace;">(r)eturn</span>, continues until the end of the current subroutine</li>
</ul>
Try it out using this <a href="https://gist.github.com/1442918.js">script</a>:<br />
<br />
<script src="https://gist.github.com/1442918.js">
</script>
<br />
<br />
For more details on pdb visit <a href="http://docs.python.org/library/pdb.html">http://docs.python.org/library/pdb.html</a>.<br />
<br />
<b>Debugging using Spyder IDE</b><br />
<a href="http://code.google.com/p/spyderlib/">Spyder</a> allows you to debug your programs without having to add the pdb module to your code, using the <span style="font-family: 'Courier New', Courier, monospace;">Run » Debug</span> menu command. You can set breakpoints in the editor windows and follow the next statement to be executed, highlighted in sync with the pdb console. The variable explorer window also helps you to inspect variables values at run time.<br />
<br />
However, the execution control is done through console commands. Fortunately Spyder integrates with <a href="http://winpdb.org/">winpdb</a>. If you install this, you will be able to control the step-by-step debug execution through a graphical window.<br />
<br />
<br />
<b>Debugging the OpenERP server</b><br />
The simplest way to debug the OpenERP server is using it's native debug mode. To activate it you need to add the --debug option when starting the server. With this, it will go into (pdb) command mode when an exception is found. This is why it's important to be familiar with the pdb commands.<br />
<br />
You can also import pdb and add pdb.set_trace() command to the specific module you want to examine. The set_trace() will open a (pdb) command line in the console, even is the server is not in debug mode, and you can examine the variables in memory (with print) and step into the next commands.<br />
<div>
<br /></div>
<br />
<div style="margin-bottom: 0cm;">
</div>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com1tag:blogger.com,1999:blog-3797105362200918676.post-1703030449948042142011-12-06T10:45:00.000+00:002012-02-01T14:43:51.810+00:00Setting up the development environmentWith the server files available through a file sharing service, you just need to edit them with your favourite editor. A good option on Windows is <a href="http://notepad-plus-plus.org/">Notepad++</a>.<br />
<br />
For Pyhton development it's advisable to have a good IDE, and there are several <a href="http://wiki.python.org/moin/IntegratedDevelopmentEnvironments">options available</a>. <a href="http://code.google.com/p/spyderlib/">Spyder</a> can be a good option. It provides features like code tree outline, selected text highlighting, automatic code analysis function, and a step-by-step debugger (with winpdb).<br />
<br />
Changes to module's Python code require a server restart in order to reload it to memory. You will find running the server manually from the terminal to be more flexible and practical when developing modules.<br />
To do this, stop the openerp-server service and manually start an instance, as in the example below. You can then follow the log in the web-console's window:<br />
<br />
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: #e8e800; font-family: 'DejaVu Sans Mono';">root@openerp </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">~</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';"># service openerp-server stop
</span><span lang="DE"><o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">Stopping openerp-server: openerp-server.
<o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: #e8e800; font-family: 'DejaVu Sans Mono';">root@openerp </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">~</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';"># su openerp
<o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="font-family: 'DejaVu Sans Mono';"><span class="Apple-style-span" style="color: white;">openerp@openerp:/root$ cd /opt/openerp/ </span></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">openerp@openerp:~$ server/bin/openerp-server.py
--config=openerp-server.conf --log-level=debug</span><br />
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';"><br /></span><br />
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:OpenERP version -
6.0.3 </span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:addons_path -
/opt/openerp/server/bin/addons <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:database hostname -
localhost <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:database port -
5432 <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:database user -
openerp <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,523][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:initialising
distributed objects services <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,665][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:psycopg2:installed. Logging
using Python logging module <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,666][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered an
exported service: db <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,666][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered an
exported service: common <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,667][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered an
exported service: object <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,667][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered an
exported service: wizard <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,667][?] </span><span lang="DE" style="color: #5c5cff; font-family: 'DejaVu Sans Mono';">DEBUG</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered an exported
service: report <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,684][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:starting HTTP
service at 0.0.0.0 port 8069 <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,686][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:starting HTTPS
service at 0.0.0.0 port 8071 <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,686][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:Registered
XML-RPC over HTTP <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,687][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:web-services:starting NET-RPC
service at 0.0.0.0 port 8070 <o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,687][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:Starting 3
services
<o:p></o:p></span></div>
<div class="PreformattedText" style="background: black; mso-pagination: widow-orphan;">
<span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">[2011-12-06 09:34:45,688][?] </span><span lang="DE" style="color: lime; font-family: 'DejaVu Sans Mono';">INFO</span><span lang="DE" style="color: white; font-family: 'DejaVu Sans Mono';">:server:OpenERP server is
running, waiting for connections...<o:p></o:p></span></div>
<br />
<div style="margin-bottom: 0cm;">
If the server fails to start, it may be that there is still an instance running. If that's the case you can solve it by killing the process. List the OpenERP running processes, find the process ID and kill it: On the terminal type:<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">ps aux|grep openerp-server<br />sudo kill -9 [PID]</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"><br /></span><br />
Running openerp-server with the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">--help</span> option will present you all the options available.<br />
In certain cases you may want to set the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">--log-level</span> to <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">debug_rpc</span> or to <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">debug_answer</span> to get more detail on the client-server interactions.<br />
And adding the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">--debug</span> option allows you to enter Python's debugger (pdb) when an exception is raised.<br />
To restart the server, press <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">CTRL+C</span> and execute the start command again. Note that there is no need exit and re-login the client sessions, because they are stateless.<br />
<br /></div>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com1tag:blogger.com,1999:blog-3797105362200918676.post-85400893744636469032011-12-05T21:57:00.001+00:002012-02-01T14:34:51.246+00:00Installing an OpenERP applianceFor serious work with OpenERP the server should be installed in Linux<br />
We'll assume that will want to have your work environment hosted on Windows.<br />
<br />
This can be achieved by running the OpenERP server on a Linux virtual machine.<br />
In broad steps, you should:<br />
<br />
<ul>
<li>Install <a href="http://www.vmware.com/products/player/overview.html">VMWare Player</a>; as an alternative you may try <a href="https://www.virtualbox.org/">Virtual Box</a>.</li>
<li>Download and install the <a href="http://www.turnkeylinux.org/postgresql">Turnkey PostgreSQL appliance</a>.</li>
<li>Using the appliance's web console, install the OpenERP server and web client from the sources, following <a href="http://www.theopensourcerer.com/2011/04/19/how-to-install-openerp-6-on-ubuntu-10-04-lts-server-part-1/">"The Open Sourcer's" instructions</a>.It's recommended to use the a stable branch (6.0 at the time of writing) and to install as services. </li>
</ul>
<br />
In order to have easy acces to the server files, like addons folders and log files, you should also install <a href="http://www.samba.org/">Samba</a>, the file sharing service. Share the <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">/opt/openerp</span> folder, where all your OpenERP should be stored.<br />
<br />
If you configure the log file to be written there, you can then follow it on your Windows host, using a log file viewer like <a href="http://www.baremetalsoft.com/baretail/">BareTail</a>. <br />
<br />
The result is a very portable server with a memory footprint below 300 kb.<br />
<div>
All you need to do to start working is to start the virtual machine, check the IP address assigned to it, and point your browser at the corresponding 8080 port. Point Windows Explorer to <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">\\IPAddress</span> and you will access the servers files. Open the log in your log viewer and you will be following the server messages.</div>Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com4tag:blogger.com,1999:blog-3797105362200918676.post-20232095477375019652011-12-05T18:00:00.000+00:002012-02-01T13:44:33.415+00:00A roadmap for OpenERP implementationWelcome!<br />
<br />
I'll be embracing OpenERP as the platform for the development of business applications.
The product has a learning curve, but I'm betting that in the long run it will pay for effort.
I'm thankful for the help provided by other developer's blogs, so I decided to also share with others my results and solutions. <br />
I am starting small, but I have ambitious plans for my OpenERP deployment.
The first deliverable will be an issue management application, for a technical service management business unit.<br />
<br />
Initial roadmap:<br />
* Set up development environment: app server, programming tools and IDE.<br />
* Design solution proof of concept, selecting and configuring standard modules.<br />
* Extend standard modules to address specific needs.<br />
* Prepare proof of concept for technical requirements: Active Directory integration, e-mail notifications to customers, SQL Server data import.<br />
<br />
I'll be posting as long as I get something useful to share.<br />
<br />
<br />Daniel Reishttp://www.blogger.com/profile/04135640072719248565noreply@blogger.com0