تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
9421 أدوات العرض
We are currently having problems logging items in a recordset. What best way would you recommend to iterate through a recordset and print it in odoo log.

For example, if we have a recordset and we want to see what are the items in that. I may not be using the right technical terminology but what I am trying to say is, let's say we have a delivery Order and we want to see all the line item fields for the corresponding stock move, but we want to do this on the odoo log
الصورة الرمزية
إهمال

@Ray Thank you for your detailed answer, are there any special steps required to log on the odoo.sh log?

Same process, but you will need your own module.

أفضل إجابة

You need to import the logger:

import logging
_logger = logging.getLogger(__name__)


Then something like this:

        # add logging
        _logger.info('------------------------')
        stock_moves = self.mapped('move_lines')
        for stock_move in stock_moves:
            _logger.info(stock_move.product_id.name)
        _logger.info('------------------------')
        #

I added these lines to the start of the action_assign method of the stock.picking model, which runs when you click CHECK AVAILABILITY.


Output for Chic/OUT/00002 using the demo database:




الصورة الرمزية
إهمال
المنشورات ذات الصلة الردود أدوات العرض النشاط
1
ديسمبر 23
2357
1
أكتوبر 20
2929
2
مارس 16
4211
1
مايو 25
13100
0
أبريل 24
2476