Archive

Posts Tagged ‘PostgreSQL’

How to debug your OpenERP modules

Debugging your OpenERP modules is quite straightforward, as long as you know basic Python programming. Just insert the following line in your

English: Python logo Deutsch: Python Logo

Image via Wikipedia

module:

import pdb;pdb.set_trace()

Then restart your openerp-server with the —debug option

# openerp-server –debug

Then monitor your server console. You will see your server stop and show you a command line prompt where you will be able to debug your program.
You will find further information in the Python documentation website.

Automated actions in OpenERP

December 28, 2011 Leave a comment

In OpenERP, as in any other ERP or system, you need to perform certain tasks regularly. Tasks such as performing a backup, calculating ABC categories, running the MRP planner, etc. How do you get this done in OpenERP? It’s quite easy and you don’t need your server administrator to get this done. Scheduling tasks in OpenERP is done via the Scheduled Actions in the Administration > Configuration > Scheduler menu.
Scheduled Actions view
In this section, you will be able to create new actions. So click on the New button in the view.

After clicking New you will see a form that allows you to enter information in two tabs, an Information tab and a Technical tab. In the first tab you will be able to enter the name of the action, whether it is active or not, and how regularly it is executed. In the technical tab, and you might need a programmer help for this, you have to enter the name of the object that will run the action; along with the function to schedule and its arguments. This is the tricky part of scheduling an action, since you need to get into the details of how the system works and you will need your programmer to dig into the object code. But it is worth it, once you understand how this works, you will be able to get many things accomplished.

Logging from your OpenERP module

December 27, 2011 Leave a comment

I always wondered how to, in the OpenERP web client, show those informational messages in the top of the web client. Messages such as ‘PO/00001 created’. They are very informational for users.

Well… reading a presentation on the differences between OpenERP v5 and v6 I found that one of the additions was the self.log function which, as its name implies, logs a message to the audit logs (which can be accessed at Administration/Audit/Logs) and the Administration Dashboard (which can be accessed at Administration/Reporting/Dashboard/Administration Dashboard).

The function has the following syntax:

self.log(cr, uid, st.id, _(‘Statement %s is confirmed, journal items are created.’) % (st_number,))

The function returns the id of the entry created in the res_log table (or res.log business object) and takes the message to log and the context as parameters

Cheers!

Checking lead-times in OpenERP

December 23, 2011 Leave a comment

In case you need to check your suppliers’ lead-times in OpenERP, it is quite easy. You need to go to Warehouse > Reporting >  Movement Analysis. You will be able to see a view where you can filter by partner, product, location and other attributes the planned lead-time and execution lead-time. This is a great report for checking the accuracy of lead-times.

Movement Analysis View in OpenERP

Movement Analysis View

Deleted records in OpenERP

December 21, 2011 Leave a comment
The blue/white elephant logo of the PostgreSQL...

Image via Wikipedia

Sooner or later you will find yourself with pgAdmin (or any other query tool) querying the OpenERP database in order to pull statistical information. It happens, and it is a healthy sign of your OpenERP implementation.

Something you need to keep in mind is how OpenERP “deletes” its records. It does not physically remove them. It just marks them as deleted. And it does so with the active field in the table. This field, which happens to be a boolean field, if true indicates that the record is not deleted. Otherwise you should not take the record into account in your queries.

Cheers!

Server security in OpenERP

CD cover for Debian GNU/Linux version 4, code ...

Image via Wikipedia

Sooner or later you have to address security in your OpenERP installation. For many reasons, the sooner you do that the better it is. The later you address security in OpenERP, the more money you lose (in those cases you start working on security after you had the problem, which means you are losing money).

What is the cost of not taking care of security? When you have security problems, your company is stopped (employees can not print invoices, customers can not place their sales orders, sales reps can not make their calls, you can not procure your supplies, and the list goes on and on). So put a number to those days. That is the value of security.

How do you start? The first thing to keep in mind is your server.  No matter what the application you are running in your server, whether it is a website or OpenERP, you have to secure the server. Most of the people I met run their OpenERP systems in Debian and Ubuntu (two popular Linux distributions). Some people do so in their own servers, some people host their systems in a VPS (such as Linode). Either way, again, you have to secure your server.

I will concentrate on Debian and Ubuntu (otherwise this is going to be a very long post). I will not cover Windows and will not get into the OpenERP security system. I will leave that for later. This is not a Linux security course, this post is intended to give you pointers to places where you can start working on the security of your system. Also, this does not cover Postgresql security.

First thing you have to do is to secure your server against intrusion. If your server is connected to the internet, your server is a target. Plain and simple as that.  How do you get started? This is a link to a great introduction on Linux security:

http://www.tldp.org/HOWTO/Security-Quickstart-HOWTO/

If you are using a Debian or Ubuntu distribution, you should read the Securing Debian Manual. And if you are running Ubuntu, don’t forget to check the Ubuntu Security Documentation (you should complement it with the Debian security manual).

Those are some pointers to places where you can get information on how to get started on securing your Linux server. Securing it against intrusion is extremely important, and should be one of your first items in your agenda. Again, if your server is connected to the Internet, your server is a target. And most of us can not afford to stop operations because our server was attacked by hackers.

Cheers!

First steps with OpenERP in Argentina

December 13, 2010 Leave a comment
A screenshot of the GTK client of OpenERP 5.0....

Image via Wikipedia

The past week I installed and configured an ERP system for a client in Argentina. This client is analyzing and testing this system in order to implement it later. The ERP system is OpenERP, formerly known as TinyERP. This system was developed by OpenERP S.A. and is licensed under the AGPL license. If you would like to get more information on the business model for this company, you can check it out at its website. Enough with the presentation, let’s jump to the system installation.

OpenERP is already available in the Debian and Ubuntu repositories. You can find it at the unstable version of Debian. Ubuntu already has it in its packages. If your server is Debian or Ubuntu, you can do an

$ apt-get install openerp-server

in order to install it. Otherwise I recommend downloading and installing the server from the source code.

To the best of my knowledge this tool needs Python-2.5 or Python 2.6 (I tried both versions, the first one on a Debian server and the latter on an Ubuntu server) and the PostgreSQL database. Once the server is installed, you have to prepare the database. This is done by creating a postgresql user and creating a database. This is necessary, otherwise Postgresql users will not be able to connect to the system.

After installing the server, you need to install a client to use the system. OpenERP has two clients: openerp-client, which is based on GTK and openerp-web which is based on HTML. Both connect through Socket and XML-RPC to the openerp-server. The first client can be downloaded from the Debian/Ubuntu repositories with the following command:

$ apt-get install openerp-client

whereas the web client can be installed with easy_install (these are the instructions for configuring and installing it http://doc.openerp.com/install/linux/web/index.html)

After installing the client, you have to configure the system tables and the system itself. You can do that with both clients in the “Create Database option”.

The most confusing part in the installation procedure is how to configure Postgresql. To make the story short, we ended up with five users:

  • the Linux admin user
  • the Postgresql admin user
  • the openerp admin user
  • the openerp database user
  • and the openerp user itself

Keep in mind that the postgresql and the openerp database user do not require password! That is the default configuration.

After configuring the database, you need to install the local modules for your country (in this case, Argentina). I did so by installing the argentina modules which can be found at Launchpad. In order to install these modules, you have to install the launchpad tools. We install them first and then we download the argentinian localization mdoule

$ sudo aptitude install bzr

$ bzr branch lp:openerp-argentina

This last step downloads these modules to the current directory. You should copy them to the modules directory in your openerp installation and enable them. But I will cover this in a later post.

Cheers!