Skip to Content
Menu
This question has been flagged
3 Replies
3337 Views

Hello,


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

http://i.imgur.com/FK6GhFO.png

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 :

<report

    id="report_coupon"

    model="report.coupon"

    string="Coupons"

    report_type="qweb-pdf"

    name="coupon.report_invoice"

    file="coupon.report_invoice"

    attachment_use="True"

    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.

Avatar
Discard
Best Answer

Hello, 

- Is "coupon" the name of your module ?

- can you share the complete traceback ?

# With your info:

Add a method on your model

@api.multi 
def coupon_print(self):  
self.ensure_one()
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

Avatar
Discard
Author

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

Author

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.

Author

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.

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.

Author

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 !

Author

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

Best Answer

Hello,

Try to use:

 id="report_invoice"

instead of  id="report_coupon"
in the report tag

Avatar
Discard
Author

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

Related Posts Replies Views Activity
1
Dec 23
7193
3
Nov 23
7891
7
Dec 23
16032
0
Mar 16
2503
1
Dec 24
184