Odoo Help


Problem with creating printing

on 6/1/16, 6:44 AM 404 views


I'm currently creating an Odoo 9 module and I've got this view :


When you click on the print button, I've got this error :

File "/opt/odoo/openerp/addons/base/ir/ir_model.py", line 972, in xmlid_lookup
    raise ValueError('External ID not found in the system: %s' % (xmlid))
ValueError: External ID not found in the system: coupon.report_invoice

My code is composed by two things :

-> A report :









    attachment="(object.state in ('open','paid')) and

          ('INV'+(object.number or '').replace('/','')+'.pdf')"


-> A python class :

class CouponReport(models.Model):

_name = 'report.coupon'

    def render_html(self, cr, uid, ids, data=None, context=None):

       report_obj = self.pool['report']

       report = report_obj._get_report_from_name(

          cr, uid, 'coupon'


       docargs = {

          'doc_ids': ids,

          'doc_model': report.model,

          'docs': self.pool[report.model].browse(

             cr, uid, ids, context=context



       return report_obj.render(

           cr, uid, ids, 'coupon',

           docargs, context=context


I don't understand what is wrong with my code.

Please, help me !

Thanks in advance for you help.

Nicolas JEUDY
On 6/3/16, 3:55 AM


- Is "coupon" the name of your module ?

- can you share the complete traceback ?

# With your info:

Add a method on your model

def coupon_print(self):  
return self.env['report'].get_action(self, 'loyalty.report_coupon')

Next add an action in xml file

<template id="report_coupon"> 
 <t t-call="report.html_container">
 <t t-foreach="docs" t-as="o">
 <t t-call="loyalty.report_coupon_document" t-lang="o.partner_id.lang"/> </t> </t> </template>

- report_coupon_document is your document template

- loyalty is the name of the module (for correct xml_id)

- report_coupon is the name on the report action in XML

Hello, thanks for your help ! My module name is "loyalty". The complete traceback is here : http://pastebin.com/88XYHsJ9

on 6/3/16, 5:10 AM

I'm trying to print coupons, but I'm trying to use the invoice print option to understand how it works, and I think it's the problem. Thanks for your help.

on 6/3/16, 5:12 AM

Well, thank you. I tried what you've sent but now, nothing append. I tried to see if the coupon_print(self) function was read, with _logger.info(), but it's currently not the case.

on 6/3/16, 5:59 AM

can you share je python code .. coupon print should be launched by you print button on the form .. I think you missed to change the name or action of this button.

Nicolas JEUDY
on 6/3/16, 7:59 AM

I modified some things to integrate the CouponReport class to my loyalty_coupon class and all the code is here : http://pastebin.com/hjMeBKBr Thank you so much !

on 6/3/16, 8:17 AM

But it doesn't work (I think it was a little bit ambiguous)

on 6/3/16, 9:17 AM

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
--Ahmed M.Elmubarak--

Ahmed M.Elmubarak
On 6/2/16, 2:54 AM


Try to use:


instead of  id="report_coupon"
in the report tag

hello, When I do this, the problem is the same. nothing changed in the error.

on 6/2/16, 6:12 AM

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 platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 6/1/16, 6:44 AM
Seen: 404 times
Last updated: 6/3/16, 3:55 AM