O'Reilly logo

Odoo Development Cookbook by Daniel Reis, Alexandre Fayolle, Holger Brunn

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Producing server logs to help debug methods

Server logs are helpful when trying to figure out what has been happening at runtime before a crash. They can also be added to provide additional information when debugging an issue. This recipe shows how to add logging to an existing method.

Getting ready

We will add some logging statements to the following method, which saves the stock levels of products to a file:

from os.path import join from openerp import models, api, exceptions EXPORTS_DIR = '/srv/exports' class ProductProduct(models.Model): _inherit = 'product.product' @api.model def export_stock_level(self, stock_location): products = self.with_context( location=stock_location.id ).search([]) products = products.filtered('qty_available') fname ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required