我有以下自定义报告:
<?xml version="1.0"?>
<odoo>
<report
id = "report_custom_sale_order"
name = "custom_saleorder_v2.custom_report_saleorder"
string = "Custom Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
report_name = "((object.number or 'SaleOrder').replace('/','')+'.pdf')"
attachment_use = "False"
/>
</odoo>
我希望将PDF下载为SO003.pdf
,用于销售订单的参考/顺序SO003
,并将SaleOrder.pdf
下载为草稿中的销售订单而不分配参考/顺序。
当我尝试使用report_name实现此类行为时,出现以下错误:
AssertionError: Element odoo has extra content: report, line 11
如何使用report_name
?
按照CZoellner的评论我试过:
<?xml version="1.0"?>
<odoo>
<report
id = "report_custom_sale_order"
name = "custom_saleorder_v2.custom_report_saleorder"
string = "Custom Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
attachment_use = "False"
/>
<record id="report_custom_sale_order" model="ir.actions.report.xml">
<field name="print_report_name"><![CDATA[((object.number or 'SaleOrder').replace('/','')+'.pdf')]]></field>
</record>
</odoo>
我收到以下错误:
ParseError: "null value in column "name" violates not-null constraint
DETAIL: Failing row contains (523, 1, null, 1, 2018-02-13 17:17:20.385168, null, 2018-02-13 17:17:20.385168, ir.actions.report.xml, null, null, t, pdf, null, null, null, null, null, t, null, f, null, null, null, f, null, null, ((object.number or 'SaleOrder').replace('/','')+'.pdf')).
" while parsing /usr/lib/python2.7/dist-packages/odoo/custom_addons/custom_saleorder_v2/reports/sale_report.xml:12, near
<record id="report_custom_sale_order" model="ir.actions.report.xml">
<field name="print_report_name">((object.number or 'SaleOrder').replace('/','')+'.pdf')</field>
</record>
注意:如果我使用object.name
而不是object.number
(我认为这是获取文档的引用/顺序的正确方法),它是相同的。
答案 0 :(得分:1)
您正在为报告名称和对象使用不同的字段。我已使用正确的字段名称更新了您的代码。
<?xml version="1.0"?>
<odoo>
<report
id = "report_custom_sale_order"
name = "custom_saleorder_v2.custom_report_saleorder"
string = "Custom Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
print_report_name = "((object.name or 'SaleOrder').replace('/','')+'.pdf')"
attachment_use = "False"
/>
我希望这会对你有所帮助。
答案 1 :(得分:1)
您可以使用print_report_name
。
<?xml version="1.0"?>
<odoo>
<report id = "report_custom_sale_order"
name = "custom_saleorder_v2.custom_report_saleorder"
string = "Custom Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
print_report_name = "((object.number or 'SaleOrder').replace('/','')+'.pdf')"
attachment_use = "False" />
</odoo>
答案 2 :(得分:1)
在数据XML中使用特殊标记print_report_name
时,不会转换字段report
。因此,之后只需添加具有普通XML记录的字段:
<?xml version="1.0"?>
<odoo>
<report
id = "report_custom_sale_order"
name = "custom_saleorder_v2.custom_report_saleorder"
string = "Custom Quotation / Order"
model = "sale.order"
report_type = "qweb-pdf"
attachment_use = "False"
/>
<record id="custom_module_name.report_custom_sale_order" model="ir.actions.report.xml">
<field name="print_report_name"><![CDATA[((object.number or 'SaleOrder').replace('/','')+'.pdf')]]></field>
</record>
</odoo>