Skip to Content
Menu
This question has been flagged
2 Replies
1428 Views

/

for wizard in self:
heading = 'Reporte de Medicinas'
worksheet.write_merge(0, 0, 0, 5, heading, easyxf('font:height 210; align: horiz center;pattern: pattern solid, fore_color black; font: color white; font:bold True;' "borders: top thin,bottom 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)
worksheet.write(row, 5, stock_id.stock_quant_ids.quantity, column_cuerpo_style_align_center)
row += 1
Avatar
Discard
Best Answer

You should use for loop when you access "stock_quant_ids".

cnt = 5
for quant in stock_id.stock_quant_ids:
column_cuerpo_style_align_center)
worksheet.write(row, cnt, stock_id.stock_quant_ids.quantity, column_ceurpo_style_align_center)
cnt += 1

row += 1



Avatar
Discard
Author Best Answer

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