Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
3254 Näkymät

how I can change product quantity on hand by code?

Avatar
Hylkää
Paras vastaus

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
Hylkää
Tekijä

I try it and it's not work

Paras vastaus

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
Hylkää
Tekijä

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

Tekijä

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

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
elok. 25
2922
3
heinäk. 24
2358
3
helmik. 25
4195
0
toukok. 24
46
1
huhtik. 24
3742