2015-08-18 68 views
0

我試圖在從openErp 7遷移後在odoo 8中執行我自己的自定義報告。 我遵循this tutorial但我在第一次嘗試從beginnig獲得錯誤用下面的跟蹤服務器無法在odoo 8中創建自定義報告

Traceback (most recent call last): 
    File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi 
    execute(self.server.app) 
    File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute 
    application_iter = app(environ, start_response) 
    File "/usr/lib/python2.7/dist-packages/openerp/service/server.py", line 281, in app 
    return self.app(e, s) 
    File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 216, in application 
    return application_unproxied(environ, start_response) 
    File "/usr/lib/python2.7/dist-packages/openerp/service/wsgi_server.py", line 202, in application_unproxied 
    result = handler(environ, start_response) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1280, in __call__ 
    return self.dispatch(environ, start_response) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1254, in __call__ 
    return self.app(environ, start_wrapped) 
    File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 588, in __call__ 
    return self.app(environ, start_response) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 1421, in dispatch 
    result = ir_http._dispatch() 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_http.py", line 168, in _dispatch 
    return self._handle_exception(e) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_http.py", line 138, in _handle_exception 
    return request._handle_exception(exception) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 659, in _handle_exception 
    return super(HttpRequest, self)._handle_exception(exception) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_http.py", line 164, in _dispatch 
    result = request.dispatch() 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 677, in dispatch 
    r = self._call_function(**self.params) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 303, in _call_function 
    return checked_call(self.db, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/service/model.py", line 113, in wrapper 
    return f(dbname, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 300, in checked_call 
    return self.endpoint(*a, **kw) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 796, in __call__ 
    return self.method(*args, **kw) 
    File "/usr/lib/python2.7/dist-packages/openerp/http.py", line 396, in response_wrap 
    response = f(*args, **kw) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/report/controllers/main.py", line 62, in report_routes 
    html = report_obj.get_html(cr, uid, docids, reportname, data=options_data, context=context) 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/report/models/report.py", line 175, in get_html 
    return self.render(cr, uid, [], report.report_name, docargs, context=context) 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/report/models/report.py", line 151, in render 
    return view_obj.render(cr, uid, template, values, context=context) 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 1029, in render 
    return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context) 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_qweb.py", line 259, in render 
    return self.render_node(self.get_template(id_or_xml_id, qwebcontext), qwebcontext) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_qweb.py", line 188, in get_template 
    xml_doc = qwebcontext.loader(name) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 1027, in loader 
    return self.read_template(cr, uid, name, context=context) 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "<string>", line 2, in read_template 

    File "/usr/lib/python2.7/dist-packages/openerp/tools/cache.py", line 121, in lookup 
    value = d[key] = self.method(*args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 859, in read_template 
    arch = self.read_combined(cr, uid, view_id, fields=['arch'], context=context)['arch'] 
    File "/usr/lib/python2.7/dist-packages/openerp/api.py", line 241, in wrapper 
    return old_api(self, *args, **kwargs) 
    File "/usr/lib/python2.7/dist-packages/openerp/addons/base/ir/ir_ui_view.py", line 524, in read_combined 
    while v.mode != 'primary': 
    File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 823, in __get__ 
    return record._cache[self] 
    File "/usr/lib/python2.7/dist-packages/openerp/models.py", line 5906, in __getitem__ 
    return value.get() if isinstance(value, SpecialValue) else value 
    File "/usr/lib/python2.7/dist-packages/openerp/fields.py", line 55, in get 
    raise self.exception 
MissingError: ('MissingError', u'One of the documents you are trying to access has been deleted, please try again after refreshing.') 

這類似於this SO question迄今回答不面向編碼一個不是很蟒蛇非常有幫助...

+0

如果你想要一個更具體的答案嘗試發佈一些你的Python代碼,謝謝 – ChesuCR

回答

0

你看了Odoo Documentation for QWeb Reports

<!-- Report "Human readable name" document template --> 
<record id="view_model_document_qweb" model="ir.ui.view"> 
    <field name="name">Human readable name</field> 
    <field name="model">model</field> 
    <field name="type">qweb</field> 
    <field name="mode">primary</field> 
    <field name="priority" eval="16" /> 
    <field name="active" eval="True" /> 
    <field name="arch" type="xml"> 
     <t t-name="module.view_model_document_qweb"> 
      <t t-call="report.external_layout"> 
       <div class="page"> 
        <h2>Report title</h2> 
        <p>This object's name is <span t-field="o.name"/></p> 
       </div> 
      </t> 
     </t> 
    </field> 
</record> 

<!-- Report "Human readable name" translate_doc template --> 
<record id="view_model_qweb" model="ir.ui.view"> 
    <field name="name">Human readable name</field> 
    <field name="model">model</field> 
    <field name="type">qweb</field> 
    <field name="mode">primary</field> 
    <field name="priority" eval="16" /> 
    <field name="active" eval="True" /> 
    <field name="arch" type="xml"> 
     <t t-name="module.view_model_qweb"> 
      <t t-call="report.html_container"> 
       <t t-foreach="doc_ids" t-as="doc_id"> 
        <t t-raw="translate_doc(doc_id, doc_model, 'lang', 'module.view_model_document_qweb')"/> 
       </t> 
      </t> 
     </t> 
    </field> 
</record> 

<!-- Report action to show: "Human readable name" --> 
<record id="action_report_human_readable_name" model="ir.actions.report.xml"> 
    <field name="name">Human readable name</field> 
    <field name="model">model</field> 
    <field name="report_type">qweb-pdf</field> 
    <field name="report_name">module.view_model_qweb</field> 
    <field name="attachment_use" eval="True" /> 
    <field name="attachment">(object.name+'.pdf')</field> 
    <field name="paperformat_id" ref="report.paperformat_euro" /> 
    <field name="help">Something about Human readable name</field> 
</record> 

<!-- Button to print the report: "Human readable name" --> 
<record id="human_readable_name_values" model="ir.values"> 
    <field name="name">Human readable name</field> 
    <field name="model_id" ref="module.model_model" /> 
    <field name="model">model</field> 
    <field name="value" eval="'ir.actions.report.xml,' +str(ref('action_report_human_readable_name'))" /> 
    <field name="key">action</field> 
    <field name="key2">client_print_multi</field> 
</record> 

我從here

+1

雖然這個鏈接可能回答這個問題,但最好在這裏包含答案的基本部分,並提供參考鏈接。如果鏈接頁面更改,則僅鏈接答案可能會失效。 – Natali

+0

好吧,我會將主要部分添加到答案 – ChesuCR

1

帶來的片斷,我認爲這會幫助你。

步驟:

 <report 
     id="action_report_id" 
     model="model name" 
     string="Report Name" 
     report_type="qweb-pdf" 
     name="module name.report_template_id" 
     file="module name.report_template_id" 
     /> 

步驟2:1的報告菜單創建菜單創建呼叫報告模板和方法,這樣的.py文件:

class custom_class_name(report_sxw.rml_parse): 


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



class test_report_class_name(osv.AbstractModel): 
    _name = 'report.module_name.report_template_id' 
    _inherit = 'report.abstract_report' 
    _template = 'module_name.report_template_id' 
    _wrapped_report_class = custom_class_name 

步驟:3 XML創建模板文件的報告視圖是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<openerp> 
    <data> 
     <template id="report_template_id"> 
      <t t-foreach="docs" t-as="o"> 
       <div class="page"> 
        <div class="row"> 
         <div class="col-xs-6"> 
          <span> Your Report View</span> 
         </div> 
        </div>    
       </div> 
      </t> 
     </template> 
    </data> 
    </openerp> 
+0

感謝您的提示。我認爲我在這裏看着完全錯誤的方向。即使是基本的未修改的發票報告也不能正確打印標題。實際上並沒有打印標題。因爲我在這裏使用Docker鏡像,所以我想知道Qweb是否有可能發現靜態css樣式表的問題。我將張貼在泊塢窗中心官方網站形象上的問題.... –

+0

對於頁眉頁腳,你必須這樣做: <模板ID =「account.report_invoice_document」> 您的報告

+0

現在,代碼自定義頁眉和頁腳: <模板ID =「extend_la YOUT 「> <噸叔如果= 「不o或不是 'COMPANY_ID' 在鄰」> <噸叔呼叫= 「module_name.report_header」/> <噸t-raw =「0」/> <模板ID = 「report_header」>

Your Report Header
<模板ID = 「report_footer」>