콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
2001 화면

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