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

Good day everyone, 

We have a set of special products for which their inventory is handled on a legacy app and we need to have odoo in sync with that. Is there any kinda sample code of how to update the quantity on hand of a product from within a runing source code.


Thanks in advance.

頭像
捨棄
作者 最佳答案

thanks for reply Samir,  I found this sample code and adapted in my module , it updates the on hand quantity properly but left the stock records like something still pending.

here the code

[CODE UPDATED!] now works fine

warehouse = self.env['stock.warehouse'].search([('code', '=', 'T006')],limit=1)



new_quantity = 742

for product in products:

self.env['stock.quant'].with_context(inventory_mode=True).create({

'product_id': product.id,

'inventory_quantity': new_quantity,

'location_id': warehouse.lot_stock_id.id,

}).action_apply_inventory()




頭像
捨棄
最佳答案

HI Sir

By using the inventory Adjustment , you can the ware location you need to update the product Quantity  

set the new count and apply it 

you can run that by batch 


頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
10月 23
1507
2
5月 18
4755
0
8月 17
3462
0
6月 23
1614
1
9月 21
2637