i just built a sample employee module but not able to figure out how to add report and print button. help please?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
Hi Ankur,
You will get the print button in the top of the form, by adding a report tag to that module, for getting the print button in your custom module, you just add a code like this, and you have to define a report template in the corresponding name.
Thank you
<template id="template_id">
<t t-call="report.html_container">
<t t-set="doc" t-value="doc.with_context()" />
<t t-call="report.internal_layout">
<div class="page" >
<t t-call="report.external_layout">
#add the body here
</t>
</div>
</t>
</t>
</template>
<report
id="report_id"
string="String to display"
model="model_name"
report_type="qweb-pdf"
file="module_name.template_id"
name="module_name.template_id"
/>
It only applies to inherited modules that have built-in print function, which method to create print button in new model?
You can try the above for the new report also
Hi everyone!
Just wanted to share how I managed to add the "Print" button for a custom model in Odoo 15. Hopefully this helps someone!
Report Template (QWeb)
Here’s an example of a simple report template:
<template id="my_model_report_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<div class="page">
<h2>My Model Report</h2>
<p><strong>Name:</strong> <t t-esc="doc.name"/></p>
<p><strong>Description:</strong> <t t-esc="doc.description"/></p>
</div>
</t>
</t>
</template>
Report Action
To make the report available and add the "Print" button directly in the form view of your custom model, define the report like this:
<record id="action_my_model_report" model="ir.actions.report">
<field name="name">My Model Report</field>
<field name="model">my.model</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">my_module.my_model_report_template</field>
<field name="print_report_name">'My Model Report - %s' % (object.name)</field>
<field name="binding_model_id" ref="model_my_model"/> <!-- This adds the "Print" button -->
</record>
Hope this helps!
Best regards!
hi Niyas,
does this method works in odoo 11?
Yes
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
0
thg 3 15
|
3529 | ||
|
1
thg 1 16
|
4017 | ||
|
1
thg 3 15
|
5827 | ||
|
1
thg 3 15
|
5372 | ||
|
1
thg 4 25
|
1213 |