Archive

Posts Tagged ‘Ubuntu’

Securing your system

Quick post of a script worth using. If your openerpserver is running on a Linux server, this server should be secured. Linux is a more secure server than Windows, but still is vulnerable to attacks. If you are new to the security field in Linux, there is a tool you should try, Bastille Unix. If you are using an

Ubuntu distribution, you can install this tool with the following command:

# sudo apt-get install bastille

After running the command bastille, you will see a wizard like window interface which will guide you through the different steps of hardening your system. These steps involve setting file permissions, disabling FTP, Firewall, Printing, disabling unnecesary services and accounts. Not only this is a very good tutorial on Linux security, but also a tool for hardening your system.

Be aware that your security obligations do not end here, this is just a very good first step.

Cheers,

Advertisements

Squid, CherryPy and OpenERP

Squid (software)

Image via Wikipedia

This is going to be quick…

Squid and CherryPy (therefore the web client of OpenERP) do not get along pretty well. Reason being CherryPy expects to know the originating URL by reading the http “X-Forwarded-Host” header. The only reverse proxies that add this header are Apache (mod_proxy) and Lighttp. This does not happen with Squid. Actually it does, but this information is published under the variable “Origin”. The result is in order to integrate CherryPy with Squid, you need to modify a little bit the CherryPy code.

In the file lib/ctools.py, located under the root of CherryPy (v3) you can find the proxy function. Just by setting the input variable of the “local” function, which is set by default in “X-Forwarded-Host”, to “Origin” is enough. And doing so you will be able to save a lot of time (in my case 4 hours) and trouble.

You might wonder why you need this, just in case you need to work  with OpenERP behind a reverse proxy like Squid.

Cheers!

Importing products with web-services in OpenERP

Python logo

Image via Wikipedia

Yesterday someone at the OpenERP forum asked me for an example of how to import product data into OpenERP, so here it is, below you will find an example of a Python script for loading basic product data.

#!/usr/bin/env python
# coding: utf-8

import xmlrpclib
import csv

username = ‘admin’ #the user
pwd = ‘pwd_admin’ #the password of the user
dbname = ‘blog_db’ #the database

# Get the uid
sock_common = xmlrpclib.ServerProxy (‘http://localhost:8069/xmlrpc/common’)
uid = sock_common.login(dbname, username, pwd)

#replace localhost with the address of the server
sock = xmlrpclib.ServerProxy(‘http://localhost:8069/xmlrpc/object’)

#load categories first
filename = “categories.csv”
reader = csv.reader(open(filename,”rb”))
for row in reader:
category = {
‘name’: row[1],
‘active’: True,
}
category_id = sock.execute(dbname, uid, pwd, ‘res.partner.category’, ‘create’, category)
print category_id

print “End categories load”

filename = “product_template.csv”
reader = csv.reader(open(filename,”rb”))
for row in reader:
product_template = {
‘name’: row[0].rstrip(),
‘supply_method’:’produce’,
‘standard_price’:1,
‘mes_type’:’fixed’,
‘uom_id’:1,
‘uom_po_id’:1,
‘type’:’product’,
‘procure_method’:’make_to_stock’,
‘cost_method’:’standard’,
‘categ_id’:1}
template_id = sock.execute(dbname, uid, pwd, ‘product.template’, ‘create’, product_template)
print template_id

product_product = {
‘product_tmpl_id’:template_id,
‘default_code’: row[0].rstrip(),
‘active’: True,
}
product_id = sock.execute(dbname,uid,pwd,’product.product’,’create’,product_product)
print product_product

print “End product load”

This is a simple script you can execute from the command line. In summary, first you need to create the categories and then you need to create the product.template objects and product.product objects. If you have any question about this, please let me know.

Cheers!

OpenERP and E-Commerce

Shield logo for Ubercart project

Image via Wikipedia

Last week a client asked me if OpenERP had an E-Commerce solution, and she was disappointed when I said no. But she was glad when I explained her why it was already integrated with existing open-source e-commerce solutions, such as Magento. And I wanted to share my thoughts on this, since some people keep asking for integrated e-commerce functionality (as well as business intelligence functionality).

To the best of my knowledge, to this day OpenERP already has connectors to Magento Commerce and Joomla. Does not have connectors to Drupal (Ubercart and Drupal Commerce projects) but I expect OpenERP to have those connectors soon since the Drupal community is growing fast (actually I am really tempted to develop a connector to Drupal Commerce but first I need a project to fund the development, and I need the time. Plus, Drupal Commerce first has to release an stable release). Which means, you can install your e-commerce solution, and integrate it with OpenERP.

What areas do you have to integrate? The product catalog comes to my mind (and the ability to manage multiple pictures per product). Then the sales orders, invoices, price lists and the delivery and inventory information. Those are the information items that should be available to the e-commerce solution, in order to make it work properly. Then the customer information, such as credit limits and order history. Lots of information that needs to be pulled from OpenERP.

OK, now why it is not a good idea for OpenERP to be a full-fledge e-commerce solution. Because the ERP and MRP problems are big enough. That’s why. E-Commerce is a different beast on its own, that demands other skills. Such as having the ability to make the page look good and the capability of implementing a design in your page. Plus, the page needs to be optimized for search, and the e-commerce solution needs to manage content the way a CMS does. That is quite an stretch for an ERP system. Ah! Have I mentioned that e-commerce packages need to integrate with payment gateways and sometimes need to be multi-lingual?

At the end of the day, the OpenERP community is not big enough to justify the development of an e-commerce solution on its own, and the e-commerce packages around already do an outstanding job. We will be much better off focusing on the development of the integration connectors, rather than developing an e-commerce solution from the ground-up.

Cheers,

Loading data in OpenERP with XML-RPC Web services

Architectural elements involved in the XML-RPC.

Image via Wikipedia

Loading data from an external source into OpenERP is quite straight-forward. Before trying ETL tools (such as Talend and Kettle), you should try two things first. Understand OpenERP’s object model (you can do it in the customization menu or by reading the code), and then try it with Python.

Trying the data load with Python is quite easy. First, open the Python prompt. Then try an example, the best example is OpenERP’s XML-RPC Web services documentation itself. I mean, start your openerp-server, then line by line try the example. You will see how it works and how easy it is to load data with web services. Then, I would suggest reading the CSV Python module documentation, which explains how to read a CSV file. After that, you only need to put the pieces together, create a Python program that reads the information from a CSV file (which was exported from LibreOffice) and then l0ad that data into OpenERP with web services.

Cheers,

openerp-server 5.0 and Python 2.7

Ubuntu Inside

Image by Kordite via Flickr

After upgrading Ubuntu to 11.04 I found the nasty surprise that openerpserver 5.0 could not create a new database because it threw the following error message:

ValueError: opcode JUMP_IF_FALSE_OR_POP not allowed (u’auto_picking and test_auto_picking()’)

After doing some quick research with Google, I found the following bug that is already fixed in openerp-server v6:

https://bugs.launchpad.net/openobject-server/+bug/673773

Since upgrading to openerp v6 at this time is not an option for me, I only needed to make a slight change to make openerp-server work with Python 2.6. I already had python 2.6 installed in my Ubuntu system, which I could check with the following command:

gustavo@gustavo-laptop:/usr/bin$ python2.6
Python 2.6.6 (r266:84292, Mar 25 2011, 19:36:32)
[GCC 4.5.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

Then I changed the openerp-server command at my /usr/local/bin directory. I only needed to change the

exec /usr/bin/python ./openerp-server.py $@

line to

exec /usr/bin/python2.6 ./openerp-server.py $@

And that is all I needed to do to get my system back to work

Cheers!

OpenERP Argentinian Localization

February 4, 2011 4 comments
Mate (an herbal beverage) in a traditional gourd

Image via Wikipedia

The OpenERP / TinyERP localization started long time ago, in 2005 by Thymbra (http://www.thymbra.com)

Thymbra started the OpenERP localization for Argentina, and has developed the electronic invoicing module, among other things, making it public since the very beginning.

OpenUnit also developed other modules for the localization for Argentina, and made them public in the past weeks.

Nowadays a group of local argentinian developers are working  on testing the existing modules and documenting them. The modules are for version 5.0 but soon we will start working on the upgrade to OpenERP 6.0.

The modules of the argentinian localization can be found at:

https://code.launchpad.net/~openerp-argentina/openerp-argentina/trunk

The order at which they are installed is as follows:

  1. Report Openoffice
  2. Report_openoffice_helper
  3. Purchase
  4. Sale
  5. ou_account
  6. ou_account_partner
  7. ou_account_document
  8. ou_account_invoice_menu
  9. ou_account_payment
  10. ou_account_checkbook

Before you install the modules, you should un-install the account_payment module.

The method for installing the modules can be found at:

http://doc.openerp.com/v6.0/book/1/1_2_Guided_Tour/1_2_Guided_Tour_install_functionality.html

You can find further information in the OpenERP Argentina Wiki.

Further changes are on the way and changes to the current document are very likely. I just wanted to keep you updated on the developments of the OpenERP argentinian community, and in case you want to test or use these modules, you are more than welcome.

Cheers!