Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3034 Widoki

how I can change product quantity on hand by code?

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

I try it and it's not work

Najlepsza odpowiedź

Hi,

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

Thanks

Awatar
Odrzuć
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

Powiązane posty Odpowiedzi Widoki Czynność
3
lip 24
2086
3
lut 25
3706
0
maj 24
46
1
kwi 24
3448
4
wrz 23
4956