Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
3416 Widoki

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    

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

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

Najlepsza odpowiedź

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.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
mar 25
1597
4
kwi 24
174511
0
gru 23
2345
5
lip 25
229004
1
gru 22
3488