Odoo Help


How to make a sum value in PO?

willie ho
on 11/11/14, 1:50 AM 1,530 views

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?

did you mean about sum of "quantity" of products?

Baiju KS
on 11/11/14, 2:26 AM

Your question is a bit unclear. Please specify with an example.

21south, Ludo - 21South
on 11/11/14, 3:26 AM

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

Baiju KS
on 11/11/14, 4:30 AM

I am fixing the uom so I can combine it.

willie ho
on 11/11/14, 8:14 PM

Baiju KS

--Baiju KS--
| 5 5 8
Kochi, India
--Baiju KS--
ODOO technical

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju KS
On 11/11/14, 4:40 AM

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?

willie ho
on 11/11/14, 8:15 PM

can you please it clear?? i cant understand what you meant by " It works when I install the module"

Baiju KS
on 11/12/14, 5:35 AM



| 5 3 6
Jakarta, Indonesia
On 11/11/14, 3:32 AM

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"/>.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

3 follower(s)


Asked: 11/11/14, 1:50 AM
Seen: 1530 times
Last updated: 3/16/15, 8:10 AM