Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
2910 มุมมอง

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

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

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

   

อวตาร
ละทิ้ง