Skip to Content
Menu
This question has been flagged
2 Replies
3093 Zobrazenia

how I can change product quantity on hand by code?

Avatar
Zrušiť
Best Answer

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})

Avatar
Zrušiť
Autor

I try it and it's not work

Best Answer

Hi,

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

Thanks

Avatar
Zrušiť
Autor

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

Autor

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

Related Posts Replies Zobrazenia Aktivita
2
aug 25
2590
3
júl 24
2160
3
feb 25
3853
0
máj 24
46
1
apr 24
3555