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

Hi, I would like to update the stock quantity of a product.

When I try this:

obj = self.env['stock.change.product.qty'].create({'product_id':19,'product_tmpl_id':19,'new_quantity':10.0})
obj.change_product_qty()


I'm getting 'NoActiveSqlTransaction: SAVEPOINT can only be used in transaction blocks'

What's wrong?

Thanks

Avatar
Discard
Best Answer

Hello Adrian Nitu,

It's might be due to a user who has no rights on updating stock quantity.

User has no right on quant, therefore you can use with_user. You can make it work as below.

obj = self.env['stock.change.product.qty'].with_user(self.user_stock_user)

When you're updating quantity as a manager it might be as you have done.

You can take reference from addons. /addons/stock/tests/test_warehouse.py

If you still get the Postgres issue of SAVEPOINT please add more code here to make it understand more.

Thank you!

Regards,




Email:      odoo@aktivsoftware.com  

Skype: kalpeshmaheshwari

   

Avatar
Discard