Skip to Content
Menu
This question has been flagged
1 Reply
2824 Views

I'm trying to modify the order / quotation report to hide unit price in each line of the products and only show total price for the quotation and units of each item.

To achieve it I created a module following the tutorial from \here. I've been able to modify the original view by inheriting it but when I create a new report with an inherited view and setting it as primary="True" I can't print it and it gives error.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 348, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_1656_2177
  File "", line 2, in body_call_content_2176
AttributeError: 'NoneType' object has no attribute 'with_context'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1686, in report_download
    response = self.report_routes(reportname, docids=docids, converter=converter)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/odoo/addons/report_xml/controllers/main.py", line 41, in report_routes
    reportname, docids, converter, **data)
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/usr/local/lib/python3.5/dist-packages/odoo/addons/report_xlsx/controllers/main.py", line 59, in report_routes
    reportname, docids, converter, **data
  File "/usr/lib/python3/dist-packages/odoo/http.py", line 519, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python3/dist-packages/odoo/addons/web/controllers/main.py", line 1627, in report_routes
    pdf = report.with_context(context).render_qweb_pdf(docids, data=data)[0]
  File "/usr/local/lib/python3.5/dist-packages/odoo/addons/mis_builder/report/mis_report_instance_qweb.py", line 28, in render_qweb_pdf
    return super(Report, self).render_qweb_pdf(res_ids, data)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 727, in render_qweb_pdf
    html = self.with_context(context).render_qweb_html(res_ids, data=data)[0]
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 767, in render_qweb_html
    return self.render_template(self.report_name, data), 'html'
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_actions_report.py", line 540, in render_template
    return view_obj.render_template(template, values)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1338, in render_template
    return self.browse(self.get_view_id(template)).render(values, engine)
  File "/usr/lib/python3/dist-packages/odoo/addons/web_editor/models/ir_ui_view.py", line 29, in render
    return super(IrUiView, self).render(values=values, engine=engine, minimal_qcontext=minimal_qcontext)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_ui_view.py", line 1347, in render
    return self.env[engine].render(self.id, qcontext)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/ir_qweb.py", line 59, in render
    result = super(IrQWeb, self).render(id_or_xml_id, values=values, **context)
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 275, in render
    self.compile(template, options)(self, body.append, values or {})
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 355, in _compiled_fn
    raise QWebException("Error to render compiling AST", e, path, node and etree.tostring(node[0], encoding='unicode'), name)
odoo.addons.base.models.qweb.QWebException: 'NoneType' object has no attribute 'with_context'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/odoo/addons/base/models/qweb.py", line 348, in _compiled_fn
    return compiled(self, append, new, options, log)
  File "", line 1, in template_1656_2177
  File "", line 2, in body_call_content_2176
AttributeError: 'NoneType' object has no attribute 'with_context'
Error to render compiling AST
AttributeError: 'NoneType' object has no attribute 'with_context'
Template: 1656
Path: /templates/t/t/t[1]
Node: 

I  think  that this is because I'm inheriting the  sale.report_saleorder_document which doesn't take into account the doc.partner_id.lang\ parameter but to pass the value of the language I would have to inherit the sale.report_saleorder which has the following code:


But if I inherit this view then I can't use xpath to modify the view which this view is already inheriting.

How can I pass that parameter to the inherited view from my new template? Or is ther any other workaround I'm missing?



Avatar
Discard
Best Answer

if u are working with odoo14, primary should be 

    
        
  • new element
  • I would suggest creating a new report using the following code:

    
    
                Invoices
                account.move
                qweb-pdf
                module_name.report_invoice_with_payments
                module_name.report_invoice_with_payments
                (object._get_report_base_filename())
                (object.state == 'posted') and ((object.name or 'INV').replace('/','_')+'.pdf')
                
                report
            


    Avatar
    Discard

    sorry i have no idea why it did that to the code.

    for primary:
    <t t-name="child.template" t-inherit="base.template" t-inherit-mode="primary">

    for creating a new report:

    <record id="account_invoices" model="ir.actions.report">
    <field name="name">Invoices</field>
    <field name="model">account.move</field>
    <field name="report_type">qweb-pdf</field>
    <field name="report_name">module_name.report_invoice_with_payments</field>
    <field name="report_file">module_name.report_invoice_with_payments</field>
    <field name="print_report_name">(object._get_report_base_filename())</field>
    <field name="attachment">(object.state == 'posted') and ((object.name or 'INV').replace('/','_')+'.pdf')</field>
    <field name="binding_model_id" ref="module_name.model_account_move"/>
    <field name="binding_type">report</field>
    </record>

    Author

    I had the same problem trying to post xml code on the forum for some reason it's not shown properly once posted.

    I'm using Odoo 12 I forgot to specify it in the post, does this answer still apply?
    Thanks

    sadly no it does not, but the best way u can fix this is following the code syntax that is avalible on odoo Docs

    https://www.odoo.com/documentation/12.0/

    search exactly the code u need, i hope this was a helpful answer