Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
4785 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
Custom Report Đã xử lý
2
thg 9 21
3627
0
thg 5 24
1362
1
thg 4 16
3730
1
thg 3 15
9003
2
thg 11 24
7742