2016-09-28 60 views
1

我想在我的客戶報告中添加外部佈局頁眉和頁腳。自定義模塊報告上的外部佈局odoo9

我的自定義模塊:

class my_module(osv.osv): 
    _name = "my.module" 
    _description = "my module" 
    _columns = { 
      'name': fields.char('Name',size=256), 
      'date': fields.date('Date', select=True), 
      'user': fields.many2one('res.users', 'User', select=True, track_visibility='onchange'), 
      'description':fields.html('Description'), 
      } 

在報告中,我從項目的模塊添加一行external_layout

<t t-foreach="docs" t-as="doc"> 
<t t-call="report.external_layout"> 
     <t t-set="doc" t-value="doc.with_context({'lang':doc.partner_id.lang})" /> 
<div class="page"> 
     <div class="row"> 
       <div class="col-xs-12 text-center"><h2><b>MY REPORT</b></h2></div> 
     </div> 
</div> 

當打開時報告出現錯誤:

Error message: 

"'my.module' object has no attribute 'partner_id'" while evaluating 
"doc.with_context({'lang':doc.partner_id.lang})" 

回答

0

添加partner_id字段到你的模型中。

例如:

'partner_id': fields.many2one('res.partner', 'Partner', required=1) 

不要忘記添加PARTNER_ID在視圖文件。

然後,重新啓動Odoo服務器並升級您的模塊。