跳至内容
菜单
此问题已终结
2 回复
2492 查看

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
589
4
4月 24
173003
0
12月 23
1559
5
2月 25
224728
1
12月 22
2478