0

openerp で新しいモジュールを作成しました。レポートを作成したいと思います。レポート作成のための作業はすべて完了しました。モジュールのコンセプトは、ユーザーが消費チャートを作成できることです。チャート名、日付、プロジェクト名が含まれています。各チャートには複数の製品とその製品が含まれています。消費数量。消費チャートの詳細は 1 つのテーブルにあり、消費チャートに関連する製品の詳細は別のテーブルにあります。消費チャートの名前とその製品の詳細を含むレポートを表示したい.レポートを準備したので、PDFを取得すると消費チャートの詳細が表示され、製品の詳細をどのように含めることができますか. 私の質問は、レポート セクションに複数のモデルを含める方法です。以下は私の現在のコードです。

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,
        })


report_sxw.report_sxw('report.mat_mgmt.collection_docket', 'mat.mgmt', 'mat_magmt/report/collection_docket.rml', parser=order, header="external")
4

2 に答える 2

0

製品の詳細を返す関数をパーサーに追加します。

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,
            'details': _get_details,
        })

    def _get_details(self, product_id):
        product = self.pool.get('product.product').browse(self.cr, self.uid, product_id)

        # get product details

        return product_details


report_sxw.report_sxw('report.mat_mgmt.collection_docket', 'mat.mgmt', 'mat_magmt/report/collection_docket.rml', parser=order, header="external")
于 2015-11-09T13:05:12.250 に答える
0

のような任意のモデルのオブジェクトを作成しself.pool.get('product.product')、そのレコードを参照できます。モデル/オブジェクトと関係がある場合は、それらに直接アクセスできます。アドオンには多くの例があります。

于 2013-05-21T04:50:21.813 に答える