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:
- CRM
- e-Commerce
- Comptabilité
- Inventaire
- PoS
- Project
- MRP
Cette question a été signalée
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.
Vous appréciez la discussion ? Ne vous contentez pas de lire, rejoignez-nous !
Créez un compte dès aujourd'hui pour profiter de fonctionnalités exclusives et échanger avec notre formidable communauté !
S'inscrirePublications associées | Réponses | Vues | Activité | |
---|---|---|---|---|
|
1
déc. 23
|
1320 | ||
|
1
oct. 24
|
3389 | ||
|
1
avr. 24
|
1241 | ||
|
2
févr. 24
|
1777 | ||
|
0
déc. 23
|
1579 |