コンテンツへスキップ
メニュー
この質問にフラグが付けられました
2 返信
4740 ビュー

I had a doubt regarding the .py code to print a report.For purchase order the code in the .py file is being provided below.But I didn't understand the last line report_sxw.report_sxw('report.purchase.order','purchase.order','addons/purchase/report/order.rml',parser=order).

class order(report_sxw.rml_parse):
    def __init__(self, cr, uid, name, context):
        super(order, self).__init__(cr, uid, name, context=context)
        self.localcontext.update({'time': time})

report_sxw.report_sxw('report.purchase.order','purchase.order','addons/purchase/report/order.rml',parser=order)

How is purchase.order given in that line.What is its significance and where is it taken from?The class name is order yet the report.sxw is given the name purchase.order.Can anyone please give me a clarification.

アバター
破棄
著作者

Can you please give explanation for the purchase.order given in report_sxw

最善の回答

The parser inherit from the report_sxw.rml_parse object and it add to the localcontext, the function time so it will be possible to call it in the report.

After an instance of report_sxw.report_sxw is created with the parameters

  1. the name of the report
  2. the object name on which the report is defined
  3. the path to the rml file
  4. the parser to use for the report (by default rml_parse)
  5. a boolean to add or not the company header on the report (default True)

report_sxw The second parameter is object name 'purchase.order' for Purchase Module

from openerp.report import report_sxw File Location server\server\openerp\report\report_sxw.py

アバター
破棄
最善の回答

As prakash suggested: See this for clarification.

order is a custom parser that inherits from report_sxw.rml_parse.
The __ini__ function is overridden to give access to the time via the localcontext.

From the given link above:

After, an instance of report_sxw.report_sxw is created with the parameters:
- the name of the report
- the object name on which the report is defined
- the path to the rml file
- the parser to use for the report (by default rml_parse)
- a boolean to add or not the company header on the report (default True)

If you check the code of report_sxw.report_sxw you will find the definition of its __init__ function:

class report_sxw(report_rml, preprocess.report):
def __init__(self, name, table, rml=False, parser=rml_parse, header='external', store=False):
    report_rml.__init__(self, name, table, rml, '')
    self.name = name
    self.parser = parser
    self.header = header
    self.store = store
    self.internal_header=False
    if header=='internal' or header=='internal landscape':
        self.internal_header=True

There you can see what the documentation already told you: The second argument is the table/model/object on which you create the report.
In your case 'purchase.order'. It has nothing to do with the name of the parser; this is the fourth argument.

Regards.

アバター
破棄
著作者

I tried the code for printing in the warranty module.But on clicking the print button error occurs that

AttributeError: 'warranty_warranty' object has no attribute '%(collection_docket)d'

関連投稿 返信 ビュー 活動
1
11月 16
4432
2
2月 24
14088
1
10月 22
5700
1
8月 21
4140
0
7月 21
2146