Odoo Help

Welcome!

This community 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.

0

How to make a sum value in PO?

By
willie ho
on 11/11/14, 1:50 AM 914 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
on 11/11/14, 2:26 AM

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

Ludo - Neobis
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
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
2

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        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
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
on 11/12/14, 5:35 AM
0

Ivan

--Ivan--
3210
| 5 3 6
Jakarta, Indonesia
--Ivan--
Ivan
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"/>.

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

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