On my module when click on create invoice button will appear dialog like dialog in sale module and create invoice .The question is how do that?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
1. Create an Action Button:
- Add a button in your custom module's view to trigger the creation of the invoice.
2. Define a Python Method:
- Define a Python method in your module that will be called when the button is clicked. This method should create the necessary logic for generating the invoice.
3. Create a Wizard/Dialog:
- Create a wizard or a popup dialog (similar to the one in the sale module) using Odoo's views and forms.
- Define the fields and layout for this wizard in XML.
4. Trigger the Wizard from the Button Click:
- In your Python method, when the button is clicked, open the created wizard or dialog using Odoo's action mechanism.
Example Steps:
Create Button in View xml:
Python :
def open_invoice_wizard(self):
# Logic to prepare data for the wizard if needed
return {
'name': 'Create Invoice Wizard',
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'your.invoice.wizard.model',
'view_id': self.env.ref('your_module.xml_id_of_wizard_view').id,
'target': 'new',
# Any other necessary context or default values
}
Wizard View (XML):
your.invoice.wizard.form
your.invoice.wizard.model
Wizard Model (Python):
class YourInvoiceWizardModel(models.TransientModel):
_name = 'your.invoice.wizard.model'
# Define fields for the wizard
def create_invoice(self):
# Logic to create invoice based on the provided data in the wizard
# This method should create the invoice using Odoo's API
# Once the invoice is created, you can handle further actions if needed
return {'type': 'ir.actions.act_window_close'}
Ensure to replace 'your_module', 'your.invoice.wizard.model', 'xml_id_of_wizard_view', and other placeholders with your actual module and view names.
This general approach allows you to create a custom button triggering a wizard or dialog for creating invoices in your custom module similar to the behavior in the sale module.
???