Skip to Content
Menú
This question has been flagged
2522 Vistes

hi! someone could help me, I'm trying to get the opening quantityt for a stock card but all the time I have 0.0, could you help me by saying that I have something wrong or another way to do it.

this is my code

my function

def get_opening_quantity(self, product):
product = self.env['product.product'].browse(product)
date = datetime.strptime(str(self.start_date), '%Y-%m-%d %H:%M:%S')
date = date - timedelta(days=1)
date = date.strftime('%Y-%m-%d')
qty = product.with_context(to_date=date).qty_available
return qty

this is my excel where im trying to print it


worksheet.write_merge(row, row, 0, 2, 'Start Qty', group_style)
op_qty = self.get_opening_quantity(val.get('id'))
balance = op_qty
worksheet.write_merge(row, row, 3, 9, '', group_style_right)
worksheet.write(row, 10, op_qty, group_style_right)
row += 1


im doing all that from a wizard 

thanks!!!

Avatar
Descartar
Related Posts Respostes Vistes Activitat
0
de gen. 22
464
1
de jul. 21
176
0
d’abr. 21
331
2
de nov. 22
6163
1
de juny 22
8169