Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
7077 Vistas

Hi I am trying to create a new report, very similar to the order report, in fact only change 1 word.

To do that I have been created a new module with a new report --> "report_albaran.xml" 

 
<odoo>
<data>
<report id="report_albaran"
string="Imprimir albarán"
model="sale.order"
report_type="qweb-pdf"
name="print_albaran_from_confirmed_order.report_albaran_template"
print_report_name="'A- %s' % (object.name)"

/>

<template id="report_albaran_template" inherit_id="sale.report_saleorder_document">
<xpath expr="//h2[@class='mt16']//span" position="replace">
<span t-field="doc.name"/>
</xpath>
</template>
</data>
</odoo>

The objective is to create a new button in the quotations/orders view and throw xpath method parse the "sale.report_saleorder_document" report to change the variable <span t-field="doc.name"/> for the string "Albarán".

The code presented does not change anything it is only to show that the error occurs anyway.

Can you help me with it?

Regards,

Amadeo


ERROR:

after few lines...
AttributeError: 'NoneType' object has no attribute 'with_context'

Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'with_context'
Template: sale.report_saleorder_document
Path: /t/t/t[1]
Node: <t t-set="doc" t-value="doc.with_context(lang=doc.partner_id.lang)"/>


It seems that the error is when is trying to look in the parent model.. I don't know why.

Avatar
Descartar
Mejor respuesta

Your report bypasses this code snippet from XML templates:
<template id="report_saleorder">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="sale.report_saleorder_document" t-lang="doc.partner_id.lang"/>
</t>
</t>
</template>
So your doc variable is not set anywhere. 
You should do it so that:
<template id="report_albaran_template" inherit_id="sale.report_saleorder">
..
<template id="report_albaran_template_document" inherit_id="sale.report_saleorder_document">
...And further customize your xml





Avatar
Descartar
Autor

Thanks you very much!! Its help a lot!

Publicaciones relacionadas Respuestas Vistas Actividad
2
feb 24
6849
1
feb 18
9424
2
nov 24
1781
0
mar 24
893
3
oct 23
7433