from odoo import api, models class ReplenishmentReport(models.AbstractModel): _inherit = 'report.stock.report_product_product_replenishment' @api.model def _get_report_lines(self, product_template_ids, product_variant_ids, wh_location_ids): lines = super(ReplenishmentReport, self)._get_report_lines(product_template_ids, product_variant_ids, wh_location_ids) # result_dict = {} # # for line in lines: # document_out = line.get('document_out') # # if document_out and "SO/" in document_out.name: # order_id = document_out.id # if document_out == False: # continue # product_id = line.get('product', {}).get('id') # query = [('product_id', '=', product_id)] # # if order_id: # result = self._calculate_result(line) # quantity = line.get('quantity', 0) # result_dict.setdefault(order_id, []).append((result, quantity)) # # for order_id, results in result_dict.items(): # sales_order = self.env['sale.order'].browse(order_id) # # for result, quantity in results: # self.env['sales.order.fullfillment'].create({ # 'sales_order_id': sales_order.id, # 'product_id': product_id, # 'reserved_from': result, # 'qty_fullfillment': quantity, # }) return lines def _calculate_result(self, line): if line['document_in']: return str(line["document_in"].name) elif line['reservation'] and not line['document_in']: return 'Reserved from stock' elif line['replenishment_filled']: if line['document_out']: return 'Inventory On Hand' else: return 'Free Stock' else: return 'Unfulfilled'