基于活动记录生成odoo报告

2024-04-29 10:28:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用以下函数来获取报表中的记录。在

def get_records(self):
    recsss = self.pool.get('overtime_oms_bcube.overtime_oms_bcube').search(self.cr,self.uid, [], context=self.context)
    resss = self.pool.get('overtime_oms_bcube.overtime_oms_bcube').browse(self.cr, self.uid, recsss)
    return resss

并通过以下方式调用记录:

^{pr2}$

问题是结果报告显示了数据库中保存的所有记录。我希望它只显示在树状图中选择的那些记录。正如您在下图中看到的活动/选定记录一样。在

enter image description here即使我们在单记录视图中生成一个报告,它仍然显示所有的记录,但是根据流程,它需要从生成该报告的位置生成该记录的报告。在

请提出一些对这种要求有帮助的建议。提前谢谢。在


Tags: 函数selfuidget报表报告记录context
3条回答

转发此代码:

def get_records(self):
    recsss = self.pool.get('overtime_oms_bcube.overtime_oms_bcube').search(self.cr,self.uid, [], context=self.context)
    resss = self.pool.get('overtime_oms_bcube.overtime_oms_bcube').browse(self.cr, self.uid, recsss)
    return resss

包括以下内容

^{pr2}$

它将只生成活动的id。 干杯!在

调用方法时,请尝试检查active_ids是否存在于context中。如果存在,只需使用browse()调用的ID。在

步骤1:创建向导 Example of odoo default product pricelist report wizard

Click on Print button system will call wizard print method

步骤:2:在向导中创建打印方法

def print_report(self, cr, uid, ids, context=None):
    """
    To get the date and print the report
    @return : return report
    """
    if context is None:
        context = {}
    datas = {'ids': context.get('active_ids', [])}
    res = self.read(cr, uid, ids, ['price_list','qty1', 'qty2','qty3','qty4','qty5'], context=context)
    res = res and res[0] or {}
    res['price_list'] = res['price_list'][0]
    datas['form'] = res
    return self.pool['report'].get_action(cr, uid, [], 'product.report_pricelist', data=datas, context=context)

在上下文中,您将获得活动ID,get_action方法将打印报告

相关问题 更多 >