Skip to Content
Menu
This question has been flagged
1 Reply
1257 Views

this is working perfectly for me but only with one product, when I add two or more products I get this error
ValueError: Expected singleton: product.product(4, 3)
for wizard in self:
heading = 'Reporte de Medicinas'
worksheet.write_merge(0, 0, 0, 5, heading, easyxf('font:height 210;"borders: top thin"))

stock = self.env['product.product'].search([('sale_ok', '=', 'true')])
for stock_id in stock:
worksheet.write(row, 0, stock_id.name, column_cuerpo_style_align_left)
worksheet.write(row, 1, stock_id.med_rs.name, column_cuerpo_style_align_center)
worksheet.write(row, 2, stock_id.man_company.name, column_cuerpo_style_align_center)
worksheet.write(row, 3, stock_id.tit_company, column_cuerpo_style_align_center)
worksheet.write(row, 4, stock_id.qty_available, column_cuerpo_style_align_center)

action = self.env['stock.production.lot'].search([('product_id', '=', stock.id)])
for lot in action:
worksheet.write(row, 5, lot.name, column_cuerpo_style_align_center)
worksheet.write(row, 6, lot.product_qty, column_cuerpo_style_align_center)
row += 1

obt_lots = self.env['stock.quant'].search([('location_id.usage', '=', 'internal')])
back= obt_lots.filtered(lambda r: r.lot_id.name == False)
for no_lot in back:
worksheet.write(row, 5, no_lot.lot_id.name, column_cuerpo_style_align_center)
worksheet.write(row, 6, no_lot.quantity, column_cuerpo_style_align_center)
row += 1
row +=1

Avatar
Discard
Best Answer

Hi ,

change 

action = self.env['stock.production.lot'].search([('product_id', '=', stock.id)])
to
action = self.env['stock.production.lot'].search([('product_id', '=', stock_id .id)]
Avatar
Discard