Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
2 Risposte
2887 Visualizzazioni

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    

Avatar
Abbandona
Risposta migliore

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

Avatar
Abbandona
Autore

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

Risposta migliore

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.


Avatar
Abbandona
Post correlati Risposte Visualizzazioni Attività
0
mar 25
1082
4
apr 24
173617
0
dic 23
1898
5
feb 25
226500
1
dic 22
2922