hi odooers
i want to print two pdf reports ( invoice, and delivery report) while clicking on single custom button in odoo 16 e
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- ลูกค้าสัมพันธ์
- e-Commerce
- ระบบบัญชี
- สินค้าคงคลัง
- PoS
- Project
- MRP
คำถามนี้ถูกตั้งค่าสถานะ
To print two existing reports (invoice and delivery report) with a single custom button in Odoo 16, you can create a new button in the user interface and define a server action to handle the logic of generating and printing the reports. Here's a step-by-step guide:
1. Create a Server Action:
Go to Settings and enable the Developer Mode.
Navigate to Technical -> Actions -> Server Actions.
Create a new server action:
Action Type: ir.actions.server
Name: Choose a name for your server action.
Model: Select the model you want to associate the server action with (e.g., Sale Order, Invoice, or any relevant model).
Execution Context: Current Record
2. Define the Python Code:
In the server action, you need to define Python code that will generate and print the reports. Below is a sample Python code that you can adapt:
python
# Sample Python Code for the server action
invoice_ids = record.invoice_ids.filtered(lambda inv: inv.state == 'posted')
delivery_ids = record.picking_ids.filtered(lambda picking: picking.state == 'done')
# Generate and print the Invoice report
invoice_report = record.env.ref('account.report_invoice').render_qweb_pdf(invoice_ids.ids)
# Save or attach the invoice_report PDF as needed
# Generate and print the Delivery Order report
delivery_report = record.env.ref('stock.report_deliveryorder').render_qweb_pdf(delivery_ids.ids)
# Save or attach the delivery_report PDF as needed
In this code, record represents the current record for which the button is clicked. Adjust the code according to your specific model and logic.
3. Create a New Button:
Navigate to the model for which you want to add the button (e.g., Sale Order, Invoice, or any relevant model).
In the model's form view, add a new button to trigger the server action.
xml
Replace your_server_action_name with the actual name of your server action.
4. Adjust Security Settings:
Make sure that the user or user group has the necessary access rights to execute the server action and access the reports.
5. Test:
Test the button by navigating to a record of the associated model and clicking on the newly created button. Verify that both reports (invoice and delivery) are generated and printed as expected.
สนุกกับการพูดคุยนี้ใช่ไหม? เข้าร่วมเลย!
สร้างบัญชีวันนี้เพื่อเพลิดเพลินไปกับฟีเจอร์พิเศษและมีส่วนร่วมกับคอมมูนิตี้ที่ยอดเยี่ยมของเรา!
ลงชื่อRelated Posts | ตอบกลับ | มุมมอง | กิจกรรม | |
---|---|---|---|---|
|
1
ธ.ค. 23
|
1526 | ||
|
1
ต.ค. 24
|
3703 | ||
|
1
เม.ย. 24
|
1435 | ||
|
2
ก.พ. 24
|
2011 | ||
|
0
ธ.ค. 23
|
1801 |