Odoo Help


How put my function into custom report

on 1/15/14, 7:44 PM 1,802 views

Hi boys, I have created custom module with 2 custom reports in sale.order object. I use openoffice for report edit. Now I need use custom python function for some fields in this report. (convertion of number into words.)

How can I change this function, when I need new field (wordprice for example.)

    # -*- coding: utf-8 -*-

import time

from openerp.report import report_sxw

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context=None):
        super(order, self).__init__(cr, uid, name, context=context)
            'time': time, 

    def _show_discount(self, uid, context=None):
        cr = self.cr
            group_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'group_discount_per_so_line')[1]
            return False
        return group_id in [x.id for x in self.pool.get('res.users').browse(cr, uid, uid, context=context).groups_id]

report_sxw.report_sxw('report.sale.order1', 'sale.order', 'addons/pest_reports/report/sale_order1.rml', parser=order, header="external")

I have function in python :

def humanize(x):
some code here....

This function convert x into words - from 123 to "onehundredtwentythree". Now I use field [[ o.amount_total ]] in my report, which print : 123. How can I insert my humanize function into my python report file? For example [[ o.amount_total_humanized ]] which will use my custom "humanize" function?

Many thanks for help.

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

0 follower(s)


Asked: 1/15/14, 7:44 PM
Seen: 1802 times
Last updated: 3/16/15, 8:10 AM