跳至内容
菜单
此问题已终结
1 回复
4765 查看

I have a function which selects a query from database and returns a result, I want to use this function in my openoffice report, please help on how to call that function in the report.

形象
丢弃
最佳答案

You should add methods you want to use in the report in the python file inside report folder of your module. For example:

class picking(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        self.localcontext.update({
            'time': time,
            'your_method_name_from_rml':self._your_method,
        })   

    def _your_method(self,value):
        result = []
        object = self.pool.get('object.name')
        # DB query
        return result

In self.localcontext.update, you have to add the new methods added, so that they are "visible" from the RML file, together with the method they are related to.

You should call your new method from the RML file using the following code:

[[ your_method_name_from_rml(o.value) ]]

Hope you find this useful

形象
丢弃
相关帖文 回复 查看 活动
1
5月 15
6129
1
12月 22
44540
1
9月 18
4320
0
3月 15
11406
1
3月 15
9634