İçereği Atla
Menü
Bu soru işaretlendi
2 Cevaplar
3039 Görünümler

how I can change product quantity on hand by code?

Avatar
Vazgeç
En İyi Yanıt

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
Vazgeç
Üretici

I try it and it's not work

En İyi Yanıt

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
Vazgeç
Üretici

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

Üretici

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

İlgili Gönderiler Cevaplar Görünümler Aktivite
3
Tem 24
2092
3
Şub 25
3718
0
May 24
46
1
Nis 24
3450
4
Eyl 23
4970