Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
2 Відповіді
1967 Переглядів

hello,

i need to print a label when i click on a button

No problem for the label but i can't find how to call the report with a button!

Is anybody knows how to do that ?


Thank you :)

Аватар
Відмінити

Just go through these odoo customization tips: https://learnopenerp.tumblr.com/

Найкраща відповідь

Hello, 

You can do this using a server action combined with the button. You want to call the server action from the button using:

  <button name="<id>" type="action" string="Print Button"/>

Where Id is the id of your server action (reference on URL actions). In the server action you would put the code:

action = {
  "type": "ir.actions.act_url",
  "url": "/report/pdf/sale.report_saleorder/"+str(record.id),
  "target": "new",
}

This would open the PDF in a new page which you can then download. All reports you make are web pages as defined in the documentation, so this can be changed easily (reference). If you want to download the PDF report it may be worth analysing the traffic on your browser when you print and change the URL which is used. 

I hope his helps,

Thanks, 

Аватар
Відмінити
Автор

Hello Jack,

i will try this solution

And if i want to print directly on a printer, what is the target or the way to do that ?

Thanks

Найкраща відповідь

Hi,

See a sample from the purchase module.


Button:

<button name="print_quotation" string="Print RFQ" type="object" states="draft" class="oe_highlight" groups="base.group_user"/>
def print_quotation(self):
self.write({'state': "sent"})
return self.env.ref('purchase.report_purchase_quotation').report_action(self)

For reference:  How To Print PDF Report In A Button Click Odoo


Thanks

Аватар
Відмінити
Автор

Hi Niyas,

Thanks for your answer

i already tried this solution but i've got this error :

return self.env.ref('safar_module.report_label_sato').report_action(self)

AttributeError: 'ir.ui.view' object has no attribute 'report_action'

Also i was thinking that works only for previous odoo version

But maybe, i forgot something