콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
3300 화면

how I can change product quantity on hand by code?

아바타
취소
베스트 답변

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

아바타
취소
작성자

I try it and it's not work

베스트 답변

Hi,

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

Thanks

아바타
취소
작성자

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

작성자

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

관련 게시물 답글 화면 활동
2
8월 25
3005
3
7월 24
2464
3
2월 25
4312
0
5월 24
46
1
4월 24
3816