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

I want to add a column in product moves that shows real qty for product moves starting from purchasing till selling by calculating qty for example if i purchase 5 qty so balance will 5 then i sell 3 so balance will be 2    

아바타
취소
베스트 답변

Hi,

For this you can inherit the corresponding model in python and add a new field in the model to display the available quantity, once the field is added in the model level, add it to the corresponding view by inheriting the view. If you are an enterprise user you can do it using the studio as well.


Once the field is added, we have to make it as computed field to compute the quantity, inside the product master, we have a field named:  qty_available which returns available quantity of product in stock. so we will utilize this field to get the qty.


Sample Code:

qty_available = fields.Float(string="Available Qty", compute='_compute_qty_available')


@api.depends('product_id')
def _compute_qty_available(self):
for rec in self:
rec.qty_available = rec.product_id.qty_available




Thanks

아바타
취소
작성자

thank you for reply.
how to inherit the corresponding model in python?

베스트 답변

Hi,

It is not recommended to add compute field to product moves. One observation which I have made is, adding compute field might make the system slow with increase in volume of data.

Rather, for your requirement, you can just extract the qty on hand for the respective product and display it in the product moves in a new column (there should be a direct link between product and qty on hand without having to use compute method) OR another workaround would be to extract the product moves report along with qty on hand to excel (Adding a screenshot below to clarify my point). Hope this is useful for you.


아바타
취소
관련 게시물 답글 화면 활동
0
3월 25
761
4
4월 24
173138
0
12월 23
1644
5
2월 25
224985
1
12월 22
2617