我正在为Odoo V8创建一个模块,用于打印自定义报告,但由于某种原因,它没有找到模块中定义的一些模板,到目前为止我不知道为什么。
以下是报告(发票)的内容: 发票
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<template id="clusterbrands_custom_report_invoice">
<t t-call="clusterbrands_custom_report_invoice">
<div class="page">
<div class="spacer" style="margin-top: 40px;"></div>
<div class="row space-bottom">
<div class="col-xs-2">
<h3>
<b>Razon social: </b>
<span t-field="o.partner_id.name"/>
<br/>
<span t-if="o.partner_id.vat">
<b>R.I.F.: </b>
</span>
<span t-esc="o.partner_id.vat[2:]"/>
<br/>
<b>Telf:</b> <span t-field="o.partner_id.phone"/>
</h3>
</div>
<div class="col-xs-3">
<h3>
<b>Dirección Fiscal:</b>
<br/>
<span t-field="o.partner_id.street"/>
<span t-field="o.partner_id.street2"/>
<span t-field="o.partner_id.city"/>
<span t-field="o.partner_id.state_id"/>
</h3>
</div>
<div class="col-xs-4 text-center">
<h4>
<div t-if="o.name" class="col-xs-4">
<p><strong> Descripción: </strong></p>
<span t-field="o.name"/>
</div>
<div t-if="o.origin" class="col-xs-4">
<strong> Doc. Origen: </strong>
<br/>
<span t-field="o.origin"/>
</div>
<div t-if="o.partner_id.ref" class="col-xs-4">
<strong> Codigo Cliente: </strong>
<br/>
<span t-field="o.partner_id.ref"/>
</div>
<div t-if="o.reference" class="col-xs-4">
<strong> Ref: </strong>
<br/>
<span t-field="o.reference"/>
</div>
<div t-if="o.user_id" class="col-xs-4">
<strong> Comercial: </strong>
<br/>
<span t-field="o.user_id" />
</div>
</h4>
</div>
<div class="col-xs-3 text-right">
<h3>
<strong>
<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Factura</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Factura Borrador</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Factura Cancelada</span>
<span t-if="o.type == 'out_refund'">Reembolso</span>
<span t-if="o.type == 'in_refund'">Reembolso Proveedor</span>
<span t-if="o.type == 'in_invoice'">Factura Proveedor</span>
<span t-field="o.nro_ctrl"/>
</strong>
<br/>
<strong>Fecha emisión:</strong> <span t-field="o.date_document"/>
<br/>
<strong>Fecha vcto:</strong> <span t-field="o.date_due"/>
</h3>
</div>
</div>
<table class="table table-condensed">
<thead>
<tr>
<th>Código</th>
<th>Descripción</th>
<th>Cant</th>
<th>Precio Unit.</th>
<th class="text-center" groups="sale.group_discount_per_so_line">Descuento (%)</th>
<th class="text-center">Sub total</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td style="width: 10%"><span t-field="l.product_id.default_code"/></td>
<td style="width: 40%"><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td>
<span t-field="l.price_unit"/>
</td>
<td class="text-center" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
<td class="text-center">
<span t-field="l.price_subtotal" />
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-xs-3 pull-right">
<table class="table table-condensed">
<tr>
<td><strong>Sub total</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed" t-field-options="{"widget": "monetary", "display_currency": "o.currency_id"}"/>
</td>
</tr>
<tr>
<td><strong>I.V.A. <span t-esc="o.tax_line.name[:3]"></span></strong></td>
<td class="text-right">
<span t-field="o.amount_tax" t-field-options="{"widget": "monetary", "display_currency": "o.currency_id"}"/>
</td>
</tr>
<tr>
<td><strong>Total</strong></td>
<td class="text-right">
<span t-field="o.amount_total" t-field-options="{"widget": "monetary", "display_currency": "o.currency_id"}"/>
</td>
</tr>
</table>
</div>
</div>
<p t-if="o.comment">
<strong>Observaciones:</strong>
<span t-field="o.comment"/>
</p>
<p t-if="o.payment_term.note">
<strong>Forma de pago:</strong>
<span t-field="o.payment_term.note"/>
</p>
<p t-if="o.fiscal_position.note">
<strong>Fiscal Position Remark:</strong>
<span t-field="o.fiscal_position.note"/>
</p>
</div>
</t>
</template>
<template id="report_template">
<t t-call="report.html_container">
<t t-foreach="doc_ids" t-as="doc_id">
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'clusterbrands_custom_invoice.clusterbrands_invoice')"/>
</t>
</t>
</template>
</data>
</openerp>
这是报告菜单的输入: report.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<!-- form view for company -->
<report
id="cluster_custom_invoice"
model="account.invoice"
string="Proforma (Media carta)"
report_type="qweb-pdf"
name="clusterbrands_custom_invoice.report_template"
file="clusterbrands_custom_invoice.report_template"
attachment_use="True"
attachment="(object.state in ('open','paid')) and ('INV'+(object.number or '').replace('/','')+'.pdf')"
/>
<record id="cluster_report_paperformat" model="report.paperformat">
<field name="name">Media Carta</field>
<field name="default" eval="True"/>
<field name="format">custom</field>
<field name="page_height">140</field>
<field name="page_width">216</field>
<field name="orientation">Portrait</field>
<field name="margin_top">3</field>
<field name="margin_bottom">3</field>
<field name="margin_left">3</field>
<field name="margin_right">3</field>
<field name="header_line" eval="False"/>
<field name="header_spacing">3</field>
<field name="dpi">80</field>
</record>
<record id="cluster_custom_invoice" model="ir.actions.report.xml">
<field name="paperformat_id" ref="cluster_report_paperformat"/>
</record>
</data>
</openerp>
以及在文件中定义它们的顺序&#34; openerp .py&#34;: openerp
# any module necessary for this one to work correctly
'depends': ['base_setup', 'product', 'analytic', 'board', 'edi', 'report', 'account'],
# always loaded
'data': [
'report/cluster_invoice.xml',
'report/cluster_layout.xml',
'report/cluster_footer.xml',
'report/report.xml',
],
'css': [
'static/src/css/style.css',
],
# only loaded in demonstration mode
'demo': [
'data/demo.xml',
],
如何定义报告的ID并不重要Odoo一直给我一个错误:
"External ID not found in the system: clusterbrands_custom_invoice.external_layout" while evaluating "translate_doc(doc_id, doc_model, 'partner_id.lang', 'clusterbrands_custom_invoice.clusterbrands_invoice')"
答案 0 :(得分:0)
在模板ID中你输入了这样的id:
<template id="clusterbrands_custom_report_invoice">
和报告模板
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'clusterbrands_custom_invoice.clusterbrands_invoice')"/>
代码应该是这样的:
<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'clusterbrands_custom_invoice.clusterbrands_custom_report_invoice')"/>
答案 1 :(得分:0)
我不明白
<template id="clusterbrands_custom_report_invoice">
<t t-call="clusterbrands_custom_report_invoice">
你的模板自己调用? 我想你的意思是
<template id="clusterbrands_custom_report_invoice">
<t t-call="external_layout">
使用将openerp.py更改为
的文件,您可能会遇到优先级问题'data': [
'report/cluster_footer.xml',
'report/cluster_layout.xml',
'report/cluster_invoice.xml',
'report/report.xml',
],