I want to make a sum quantity of PO just like the total amount
what function should I write to get the sum quantity when pressing the update button?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I want to make a sum quantity of PO just like the total amount
what function should I write to get the sum quantity when pressing the update button?
There will be product of different uom's in PO line,, how can we combine that?? eg: 6 gm and 5 liter and 7 No.
If you still want to calculate irrespective of that,, you can use the function
first declare a function and functional field:-
def _compute_total(self, cr, uid, ids, name, args, context=None):
res = {}
for invoice in self.browse(cr, uid, ids, context=context):
res[invoice.id] = {
'amount_total': 0.0,
}
for line in invoice.order_line:
res[invoice.id]['amount_total'] += line.product_qty
return res
'amount_total': fields.function(_compute_total, string='Total Quantity')
If you want to cosider different Units you can update function like this:-
res[invoice.id]['amount_total'] += line.product_qty / line.product_uom.factor
Thanks for the help. It works when I install the module. However, I still cannot update the value when I press the (update) button. Is there any solution?
can you please it clear?? i cant understand what you meant by " It works when I install the module"
Hey! Can anyone help me how I can add this function using the dev tools?
I want to add all the quantities irrespective of their UoM's.
Hi Willie, the sum of quantity may provide wrong information because the quantity depends on the UoM and the product. For example, what is 1 ltr of milk + 1 jug of milk? Or what is 1 dozen of apple + 1 dozen of orange?
Technically, however you get the sum of the figures, by adding the sum="XXXX" in the view's field definition, e.g. <field name="amount_total" sum="Total Amount"/>.
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up
did you mean about sum of "quantity" of products?
Your question is a bit unclear. Please specify with an example.
There will be product of different uom's in PO line,, how can we combine that?? eg: 6 gm and 5 liter and 7 No
I am fixing the uom so I can combine it.