Initial commit
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# Additional Implementation Patterns
|
||||
|
||||
## Action Buttons
|
||||
|
||||
```python
|
||||
def action_custom(self):
|
||||
self.ensure_one()
|
||||
# Logic here
|
||||
return {
|
||||
'type': 'ir.actions.client',
|
||||
'tag': 'display_notification',
|
||||
'params': {
|
||||
'title': 'Success',
|
||||
'message': 'Action completed',
|
||||
'type': 'success',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## PDF Reports (QWeb)
|
||||
|
||||
```python
|
||||
class CustomReport(models.AbstractModel):
|
||||
_name = 'report.module.report_name'
|
||||
|
||||
@api.model
|
||||
def _get_report_values(self, docids, data=None):
|
||||
docs = self.env['model.name'].browse(docids)
|
||||
return {
|
||||
'doc_ids': docids,
|
||||
'docs': docs,
|
||||
'custom_data': self._prepare_data(docs),
|
||||
}
|
||||
```
|
||||
|
||||
## Excel Reports
|
||||
|
||||
```python
|
||||
from odoo import models
|
||||
|
||||
class ExcelReport(models.AbstractModel):
|
||||
_name = 'report.module.report_xlsx'
|
||||
_inherit = 'report.report_xlsx.abstract'
|
||||
|
||||
def generate_xlsx_report(self, workbook, data, objects):
|
||||
sheet = workbook.add_worksheet('Report')
|
||||
header_format = workbook.add_format({'bold': True})
|
||||
|
||||
sheet.write(0, 0, 'Header 1', header_format)
|
||||
# Add data rows
|
||||
```
|
||||
|
||||
## Scheduled Actions (Cron)
|
||||
|
||||
```xml
|
||||
<record id="ir_cron_task" model="ir.cron">
|
||||
<field name="name">Task Name</field>
|
||||
<field name="model_id" ref="model_model_name"/>
|
||||
<field name="state">code</field>
|
||||
<field name="code">model._cron_method()</field>
|
||||
<field name="interval_number">1</field>
|
||||
<field name="interval_type">days</field>
|
||||
</record>
|
||||
```
|
||||
Reference in New Issue
Block a user