I have the following custom report:
<?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>
I would like the PDF to be downloaded as SO003.pdf
for sales order with reference/sequential SO003
, and as SaleOrder.pdf
for sales order in draft without assigned reference/sequential.
When I try to implement such behaviour with report_name I get the following error:
AssertionError: Element odoo has extra content: report, line 11
How report_name
shall be used?
Following CZoellner comment I tried:
<?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>
And I got the following error:
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>
Note: it is the same if I use object.name
instead of object.number
(which I think it is the right way of getting the reference/sequential of the document.