Odoo Help


Add a calculated column into tree view

on 7/15/13, 7:31 AM 3,240 views

Hi all,

I am adding a column to my Quotation tree view. The new column shows the total amount of products in one quotation. I tried to write one method do the calculation...it worked once but it is not working any more..There is no error message, but nothing is shown in the under the column. If I edit the old record, which has the number shown, the number is not updated. i don't know what's wrong with it. Much appreciate you can advise how to fix.

Thanks a lot in advance!

from openerp.osv import fields, osv

class sale_order(osv.osv):


def amount_all(self, cr, uid, ids, field_name, arg, context=None):
    res = {}
    for order in self.browse(cr, uid, ids, context=context):
        res[order.id] = {
            'total_quantity': 0.0,
        val2 = 0.0
        for line in order.order_line:
            val2 += line.product_uom_qty
        res[order.id]['total_quantity'] = val2
    return res

def _get_order(self, cr, uid, ids, context=None):
    result = {}
    for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context):
        result[line.order_id.id] = True
    return result.keys()


    'total_quantity':fields.function(amount_all,type='float',string='Total Quantity',
            'sale.order': (lambda self, cr, uid, ids, c={}: ids, ['order_line'], 10),
            'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty'], 10),
        multi='sums', help="The total quantity", track_visibility='always'),


Inside xml:

                    <field name="partner_id" position="after">
                        <field name="total_quantity"/>

You can solved it? I'm with the same problem....

Jorge Sixto
on 3/28/14, 1:27 PM

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

1 follower(s)


Asked: 7/15/13, 7:31 AM
Seen: 3240 times
Last updated: 5/25/17, 6:04 PM