跳至内容
菜单
此问题已终结
1 回复
8004 查看

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.

形象
丢弃
最佳答案

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





形象
丢弃
编写者

Thanks you very much!! Its help a lot!

相关帖文 回复 查看 活动
2
2月 24
8068
1
2月 18
10252
2
11月 24
2895
0
3月 24
1598
3
10月 23
8528