Odoo Help


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.


Add a calculated column into tree view

on 7/15/13, 7:31 AM 2,133 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

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

0 follower(s)


Asked: 7/15/13, 7:31 AM
Seen: 2133 times
Last updated: 3/16/15, 8:10 AM