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

Problem with creating printing

By
Matthieu
on 6/1/16, 6:44 AM 342 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.

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

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

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

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

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

Matthieu
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 !

Matthieu
on 6/3/16, 8:17 AM

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

Matthieu
on 6/3/16, 9:17 AM
0

Ahmed M.Elmubarak

--Ahmed M.Elmubarak--
2988
| 5 3 5
Sudan
--Ahmed M.Elmubarak--


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

Hello,

Try to use:

 id="report_invoice"

instead of  id="report_coupon"
in the report tag

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

Matthieu
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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

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