Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
5429 Переглядів

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 


Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
жовт. 23
1519
2
трав. 18
4766
0
серп. 17
3482
0
черв. 23
1625
Inventory report Вирішено
1
вер. 21
2642