Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

Unable to print invoice report - odoo 9

By
Alessandro Romano
on 8/4/16, 5:10 AM 547 views

When I try to print an invoice I get the following

the complete traceback is :

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/openerp/addons/report/controllers/main.py", line 101, in report_download
    response = self.report_routes(reportname, docids=docids, converter='pdf')
  File "/usr/lib/python2.7/site-packages/openerp/http.py", line 509, in response_wrap
    response = f(*args, **kw)
  File "/usr/lib/python2.7/site-packages/openerp/addons/report/controllers/main.py", line 45, in report_routes
    pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=data, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/report/models/report.py", line 156, in get_pdf
    html = self.get_html(cr, uid, ids, report_name, data=data, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/report/models/report.py", line 130, in get_html
    return self.render(cr, uid, [], report.report_name, docargs, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/report/models/report.py", line 106, in render
    return view_obj.render(cr, uid, template, values, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/web_editor/models/ir_ui_view.py", line 29, in render
    return super(view, self).render(cr, uid, id_or_xml_id, values=values, engine=engine, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_ui_view.py", line 1070, in render
    return self.pool[engine].render(cr, uid, id_or_xml_id, qcontext, loader=loader, context=context)
  File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper
    return old_api(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 254, in render
    return self.render_node(element, qwebcontext, generated_attributes=qwebcontext.pop('generated_attributes', ''))
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 297, in render_node
    result = self.render_element(element, template_attributes, generated_attributes, qwebcontext)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 320, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 295, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 448, in render_tag_call
    d[0] = self.render_element(element, template_attributes, generated_attributes, d)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 320, in render_element
    generated_attributes= name == "t" and generated_attributes or ''))
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 295, in render_node
    result = self._render_tag[t_render](self, element, template_attributes, generated_attributes, qwebcontext)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 485, in render_tag_set
    qwebcontext[template_attributes["set"]] = self.eval_object(template_attributes["value"], qwebcontext)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 198, in eval_object
    return self.eval(expr, qwebcontext)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 195, in eval
    raise_qweb_exception(message="Could not evaluate expression %r" % expr, expression=expr, template=template)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 192, in eval
    return qwebcontext.safe_eval(expr)
  File "/usr/lib/python2.7/site-packages/openerp/addons/base/ir/ir_qweb.py", line 104, in safe_eval
    return eval(expr, None, locals_dict, nocopy=True, locals_builtins=True)
  File "/usr/lib/python2.7/site-packages/openerp/tools/safe_eval.py", line 298, in safe_eval
    return eval(c, globals_dict, locals_dict)
  File "", line 1, in <module>
QWebException: "'NoneType' object has no attribute 'with_context'" while evaluating
"o.with_context({'lang':o.partner_id.lang})"

If you go to the Customer page If you go to the Customer page , he has a laguage defined? http://prntscr.com/c1j6tj

OpenGest.Solutions
on 8/4/16, 9:04 AM

Yes, it is defined

Alessandro Romano
on 8/4/16, 10:29 AM

If I change invoice template to default "account.report_invoice" I get this error:

Traceback (most recent call last):

File "/usr/lib/python2.7/site-packages/openerp/addons/report/controllers/main.py", line 101, in report_download

response = self.report_routes(reportname, docids=docids, converter='pdf')

File "/usr/lib/python2.7/site-packages/openerp/http.py", line 509, in response_wrap

response = f(*args, **kw)

File "/usr/lib/python2.7/site-packages/openerp/addons/report/controllers/main.py", line 45, in report_routes

pdf = report_obj.get_pdf(cr, uid, docids, reportname, data=data, context=context)

File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/site-packages/openerp/addons/report/models/report.py", line 170, in get_pdf

save_in_attachment = self._check_attachment_use(cr, uid, ids, report)

File "/usr/lib/python2.7/site-packages/openerp/api.py", line 250, in wrapper

return old_api(self, *args, **kwargs)

File "/usr/lib/python2.7/site-packages/openerp/addons/report/models/report.py", line 311, in _check_attachment_use

pdf = base64.decodestring(pdf)

File "/usr/lib64/python2.7/base64.py", line 321, in decodestring

return binascii.a2b_base64(s)

TypeError: must be string or buffer, not None

Alessandro Romano
on 8/4/16, 11:15 AM

Ok. If you go to Settings > User Interface > Views

(if in odoov9, you should activate the developer mode: http://www.opengest.solutions/blog/nouveautes-numeriques-1/post/comment-activer-le-mode-developpeur-sur-odoo-7)

Make a search: report_invoice

You should have 2 views: report_invoice and report_invoice_document

Can you post their content?

Are you working in odoov8 or odoov9?

OpenGest.Solutions
on 8/4/16, 11:38 AM

And let me know if the report_invoice view has inherited views...

OpenGest.Solutions
on 8/4/16, 11:44 AM

No, report_invoice has no inherited views.

I'm on version 9

Alessandro Romano
on 8/4/16, 11:51 AM

report_invoice view:

<?xml version="1.0"?>

<t t-name="account.report_invoice">

<t t-call="report.html_container">

<t t-foreach="docs" t-as="o">

<t t-call="account.report_invoice_document" t-lang="o.partner_id.lang"/>

</t>

</t>

</t>

----------------------------------------

report_invoice_document view --->

<?xml version="1.0"?>

<t t-name="account.report_invoice_document">

<t t-call="report.external_layout">

<t t-set="o" t-value="o.with_context({'lang':o.partner_id.lang})"/>

<div class="page">

<div class="row">

<div class="col-xs-5 col-xs-offset-7">

<address t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/>

<span t-if="o.partner_id.vat">TIN: <span t-field="o.partner_id.vat"/></span>

</div>

</div>

<h2>

<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Invoice</span>

<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>

<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Draft Invoice</span>

<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">Cancelled Invoice</span>

<span t-if="o.type == 'out_refund'">Refund</span>

<span t-if="o.type == 'in_refund'">Vendor Refund</span>

<span t-if="o.type == 'in_invoice'">Vendor Bill</span>

<span t-field="o.number"/>

</h2>

<div class="row mt32 mb32">

<div class="col-xs-2" t-if="o.name">

<strong>Description:</strong>

<p t-field="o.name"/>

</div>

<div class="col-xs-2" t-if="o.date_invoice">

<strong>Invoice Date:</strong>

<p t-field="o.date_invoice"/>

</div>

<div class="col-xs-2" t-if="o.date_due and o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">

<strong>Due Date:</strong>

<p t-field="o.date_due"/>

</div>

<div class="col-xs-2" t-if="o.origin">

<strong>Source:</strong>

<p t-field="o.origin"/>

</div>

<div class="col-xs-2" t-if="o.partner_id.ref">

<strong>Customer Code:</strong>

<p t-field="o.partner_id.ref"/>

</div>

<div name="reference" class="col-xs-2" t-if="o.reference">

<strong>Reference:</strong>

<p t-field="o.reference"/>

</div>

</div>

<!-- Is there a discount on at least one line? -->

<t t-set="display_discount" t-value="any([l.discount for l in o.invoice_line_ids])"/>

<table class="table table-condensed">

<thead>

<tr>

<th>Description</th>

<th class="text-right">Quantity</th>

<th class="text-right">Unit Price</th>

<th t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">Disc.(%)</th>

<th class="text-right">Taxes</th>

<th class="text-right">Price</th>

</tr>

</thead>

<tbody class="invoice_tbody">

<tr t-foreach="o.invoice_line_ids" t-as="l">

<td><span t-field="l.name"/></td>

<td class="text-right">

<span t-field="l.quantity"/>

<span t-field="l.uom_id" groups="product.group_uom"/>

</td>

<td class="text-right">

<span t-field="l.price_unit"/>

</td>

<td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">

<span t-field="l.discount"/>

</td>

<td>

<span t-esc="', '.join(map(lambda x: (x.description or x.name), l.invoice_line_tax_ids))"/>

</td>

<td class="text-right">

<span t-field="l.price_subtotal" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>

</td>

</tr>

</tbody>

</table>

<div class="row">

<div class="col-xs-4 pull-right">

<table class="table table-condensed">

<tr class="border-black">

<td><strong>Subtotal</strong></td>

<td class="text-right">

<span t-field="o.amount_untaxed" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>

</td>

</tr>

<t t-foreach="o._get_tax_amount_by_group()" t-as="amount_by_group">

<tr>

<td><span t-esc="amount_by_group[0]"/></td>

<td class="text-right">

<span t-esc="amount_by_group[1]"/>

</td>

</tr>

</t>

<tr class="border-black">

<td><strong>Total</strong></td>

<td class="text-right">

<span t-field="o.amount_total" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>

</td>

</tr>

</table>

</div>

</div>

<div class="row" t-if="o.tax_line_ids">

<div class="col-xs-6">

<table class="table table-condensed">

<thead>

<tr>

<th>Tax</th>

<th class="text-right">Amount</th>

</tr>

</thead>

<tbody>

<tr t-foreach="o.tax_line_ids" t-as="t">

<td><span t-field="t.name"/></td>

<td class="text-right">

<span t-field="t.amount" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>

</td>

</tr>

</tbody>

</table>

</div>

</div>

<p t-if="o.comment">

<strong>Comment:</strong>

<span t-field="o.comment"/>

</p>

<p t-if="o.payment_term_id">

<span t-field="o.payment_term_id.note"/>

</p>

<p t-if="o.fiscal_position_id.note">

<strong>Fiscal Position Remark:</strong>

<span t-field="o.fiscal_position_id.note"/>

</p>

</div>

<p>Preservativi, test di gravidanza, cerotti, dental dams e test di ovulazione sono dispositivi medici conformi alle direttive europee 93/42/CEE, 90/385/CEE e 98/79/CE</p>

</t>

</t>

Alessandro Romano
on 8/4/16, 11:54 AM

Everything seems correct... you only have problems when printing invoices? if you try to print a sales order, it works?

OpenGest.Solutions
on 8/4/16, 12:13 PM

If yes, try to uncheck the "Reload from attachment" in Settings > Reports > Reports for Invoices

You said: If I change invoice template to default "account.report_invoice" I get this error...

so you have several invoice reports... no problem, but you should have 2 views for that report:

1 for the report similar to this one: http://gitlab.opengest.fr/opengest/odoo/blob/master/addons/account/views/report_invoice.xml#L136

and you can call him my_report_invoice

and change this line:

<t t-call="your_module.my_report_invoice_document" t-lang="o.partner_id.lang"/>

Another view similar to this one:

http://gitlab.opengest.fr/opengest/odoo/blob/master/addons/account/views/report_invoice.xml#L4

And you have to change is id to my_report_invoice_document

I think that the source of the problem is that you have tried to create a new report invoice, customized, with just one view...

OpenGest.Solutions
on 8/4/16, 12:33 PM

Thanks! I unchecked "Reload from attachment" in Settings > Reports > Reports for Invoices

and now the invoice printing is working

Alessandro Romano
on 8/5/16, 3:26 AM
0
OpenGest.Solutions
On 8/5/16, 10:34 AM

Try to uncheck the "Reload from attachment" in Settings > Reports > Reports for Invoices

You said: If I change invoice template to default "account.report_invoice" I get this error...

so you have several invoice reports... no problem, but you should have 2 views for that report:

1 for the report similar to this one: http://gitlab.opengest.fr/opengest/odoo/blob/master/addons/account/views/report_invoice.xml#L136

and you can call him my_report_invoice

and change this line:

<t t-call="your_module.my_report_invoice_document" t-lang="o.partner_id.lang"/>

Another view similar to this one:

http://gitlab.opengest.fr/opengest/odoo/blob/master/addons/account/views/report_invoice.xml#L4

And you have to change is id to my_report_invoice_document

I think that the source of the problem is that you have tried to create a new report invoice, customized, with just one view...

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 8/4/16, 5:10 AM
Seen: 547 times
Last updated: 8/5/16, 10:35 AM