Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
3015 Zobrazení

how I can change product quantity on hand by code?

Avatar
Zrušit
Nejlepší odpověď

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šit
Autor

I try it and it's not work

Nejlepší odpověď

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šit
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 Odpovědi Zobrazení Aktivita
3
čvc 24
2042
3
úno 25
3647
0
kvě 24
46
1
dub 24
3406
4
zář 23
4903