Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 18:50:04 +08:00
commit 3e809e35ad
41 changed files with 10010 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
# Reference Documentation for Odoo Feature Enhancer
This is a placeholder for detailed reference documentation.
Replace with actual reference content or delete if not needed.
Example real reference docs from other skills:
- product-management/references/communication.md - Comprehensive guide for status updates
- product-management/references/context_building.md - Deep-dive on gathering context
- bigquery/references/ - API references and query examples
## When Reference Docs Are Useful
Reference docs are ideal for:
- Comprehensive API documentation
- Detailed workflow guides
- Complex multi-step processes
- Information too lengthy for main SKILL.md
- Content that's only needed for specific use cases
## Structure Suggestions
### API Reference Example
- Overview
- Authentication
- Endpoints with examples
- Error codes
- Rate limits
### Workflow Guide Example
- Prerequisites
- Step-by-step instructions
- Common patterns
- Troubleshooting
- Best practices

View File

@@ -0,0 +1,81 @@
# Odoo Field Types Reference
## Basic Field Types
### Char - String field
```python
name = fields.Char(string='Name', required=True, size=128, index=True)
```
### Text - Multi-line text
```python
description = fields.Text(string='Description')
```
### Integer
```python
quantity = fields.Integer(string='Quantity', default=1)
```
### Float
```python
price = fields.Float(string='Price', digits=(10, 2))
```
### Boolean
```python
active = fields.Boolean(string='Active', default=True)
```
### Selection
```python
state = fields.Selection([
('draft', 'Draft'),
('done', 'Done'),
], string='Status', default='draft')
```
### Date / Datetime
```python
date = fields.Date(string='Date', default=fields.Date.context_today)
datetime = fields.Datetime(string='DateTime', default=fields.Datetime.now)
```
### Monetary
```python
amount = fields.Monetary(string='Amount', currency_field='currency_id')
currency_id = fields.Many2one('res.currency')
```
## Relational Fields
### Many2one - Foreign key
```python
partner_id = fields.Many2one('res.partner', string='Partner', ondelete='cascade')
```
### One2many - Reverse relationship
```python
line_ids = fields.One2many('model.line', 'parent_id', string='Lines')
```
### Many2many
```python
tag_ids = fields.Many2many('model.tag', string='Tags')
```
### Related Field
```python
partner_email = fields.Char(related='partner_id.email', string='Email', store=True, readonly=True)
```
## Computed Fields
```python
total = fields.Float(compute='_compute_total', store=True)
@api.depends('line_ids.amount')
def _compute_total(self):
for record in self:
record.total = sum(record.line_ids.mapped('amount'))
```

View File

@@ -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>
```

View File

@@ -0,0 +1,58 @@
# XPath Patterns for Odoo View Inheritance
## Common XPath Positions
- `before` - Insert before the target element
- `after` - Insert after the target element
- `inside` - Insert inside the target element (as last child)
- `replace` - Replace the target element entirely
- `attributes` - Add/modify attributes of the target element
## Examples
### Add Field After Another Field
```xml
<xpath expr="//field[@name='partner_id']" position="after">
<field name="new_field"/>
</xpath>
```
### Add Field Inside Group
```xml
<xpath expr="//group[@name='group_name']" position="inside">
<field name="new_field"/>
</xpath>
```
### Replace Field
```xml
<xpath expr="//field[@name='old_field']" position="replace">
<field name="new_field"/>
</xpath>
```
### Add Attributes
```xml
<xpath expr="//field[@name='field_name']" position="attributes">
<attribute name="readonly">1</attribute>
<attribute name="required">1</attribute>
</xpath>
```
### Add to Header
```xml
<xpath expr="//header" position="inside">
<button name="action_custom" string="Custom" type="object"/>
</xpath>
```
### Add Notebook Page
```xml
<xpath expr="//notebook" position="inside">
<page string="New Page">
<group>
<field name="field1"/>
</group>
</page>
</xpath>
```