How to do it...

In order to get some logs when this method is being executed, perform the following steps:

  1. At the beginning of the code, import the logging module:
import logging 
  1. Before the definition of the model class, get a logger for the module:
_logger = logging.getLogger(__name__) 
  1. Modify the code of the export_stock_level() method, as follows:
    @api.model 
    def export_stock_level(self, stock_location): 
        _logger.info('export stock level for %s',
stock_location.name)
products = self.with_context(
location=stock_location.id).search([]) products = products.filtered('qty_available') _logger.debug('%d products in the location',
len(products)) fname = join(EXPORTS_DIR, 'stock_level.txt') try: with open(fname, 'w') as fobj: for prod in products: fobj.write('%s %f ' % (
prod.name, prod.qty_available)) except IOError: _logger.exception( 'Error while writing to %s in %s', 'stock_level.txt', EXPORTS_DIR) raise exceptions.UserError('unable to save file')
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset