Skip to Content
Menu
This question has been flagged
1524 Views

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
Discard
Related Posts Replies Views Activity
0
Jan 22
464
1
Jul 21
176
0
Apr 21
331
2
Nov 22
4363
1
Jun 22
6761