Producing server logs to help debug methods
Server logs are useful 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 is an issue. This recipe shows you how to add logging to an existing method.
We will add some logging statements to the following method, which saves the stock levels of products to a file (you will also need to add the dependencies of the
stock modules to the manifest):
from os.path import join from odoo 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...