Skip to Content
Menu
This question has been flagged

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
Discard
Best Answer

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
Discard
Author

Thanks you very much!! Its help a lot!

Related Posts Replies Views Activity
2
Feb 24
5290
1
Feb 18
8199
2
Nov 24
162
0
Mar 24
211
3
Oct 23
6205