This question has been flagged

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)
        self.localcontext.update({
            'time': time, 
            'show_discount':self._show_discount,
        })

    def _show_discount(self, uid, context=None):
        cr = self.cr
        try: 
            group_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'sale', 'group_discount_per_so_line')[1]
        except:
            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.

Avatar
Discard