跳至內容
選單
此問題已被標幟
2 回覆
3181 瀏覽次數

how I can change product quantity on hand by code?

頭像
捨棄
最佳答案

you can try ths way:

from odoo import api, models

class ProductQuantityUpdate(models.Model):
_inherit = 'product.product'

def change_quantity(self, new_quantity):
for product in self:
product.write({'qty_available': new_quantity})

頭像
捨棄
作者

I try it and it's not work

最佳答案

Hi,

Easy method for the same from the code and ui is to make an inventory adjustment on particular location with needed value.

Thanks

頭像
捨棄
作者

is the method is action_update_quantity_on_hand ?
I try it but I had error
can you write the code to implement the method

feel free to update the question with the tried code and error you received

作者

product = self.enve['product.product'].search([('id','=',product_id.id)])
product.qty_available = 100
product.action_update_quantity_on_hand ()
I have no change in this try and no error

as i suggested in answer, try simulating the same code execution of inventory adjustment with stock.quant model

相關帖文 回覆 瀏覽次數 活動
2
8月 25
2829
3
7月 24
2274
3
2月 25
4035
0
5月 24
46
1
4月 24
3626