mirror of
https://github.com/ManfredAabye/opensimcurrencyserver-dotnet-tests.git
synced 2026-08-14 00:47:56 +00:00
6.3 KiB
6.3 KiB
Ein OpenERP Odoo Plugin für den C# MoneyServer entwickeln
Architektur-Übersicht
1. Plugin-Struktur
opensim_currency/
├── __init__.py
├── __manifest__.py
├── models/
│ ├── __init__.py
│ ├── currency_server.py
│ ├── transactions.py
│ └── accounts.py
├── controllers/
│ ├── __init__.py
│ └── main.py
├── views/
│ ├── currency_views.xml
│ ├── transaction_views.xml
│ └── dashboard.xml
└── static/
└── src/
└── js/
└── dashboard.js
Kernfunktionen
1. Kontenverwaltung
# models/accounts.py
class OpenSimAccount(models.Model):
_name = 'opensim.currency.account'
name = fields.Char('Account Name', required=True)
account_id = fields.Char('UUID', required=True)
balance = fields.Float('Current Balance')
currency_type = fields.Selection([
('opensim', 'OpenSim Currency'),
('virtual', 'Virtual Currency'),
('fiat', 'Fiat Currency')
])
partner_id = fields.Many2one('res.partner', 'Owner')
is_active = fields.Boolean('Active', default=True)
2. Transaktionsmanagement
# models/transactions.py
class OpenSimTransaction(models.Model):
_name = 'opensim.currency.transaction'
transaction_id = fields.Char('Transaction UUID')
from_account = fields.Many2one('opensim.currency.account', 'From Account')
to_account = fields.Many2one('opensim.currency.account', 'To Account')
amount = fields.Float('Amount')
transaction_type = fields.Selection([
('transfer', 'Transfer'),
('payment', 'Payment'),
('exchange', 'Exchange'),
('fee', 'Fee')
])
status = fields.Selection([
('pending', 'Pending'),
('completed', 'Completed'),
('failed', 'Failed')
])
3. Server-Konfiguration
# models/currency_server.py
class CurrencyServerConfig(models.Model):
_name = 'opensim.currency.server'
name = fields.Char('Server Name', required=True)
base_url = fields.Char('Server URL', required=True)
api_key = fields.Char('API Key')
is_active = fields.Boolean('Active')
currency_code = fields.Char('Currency Code', default='OSC')
exchange_rate = fields.Float('Exchange Rate')
API-Integration
1. C# MoneyServer Client
# models/currency_server.py
class OpenSimCurrencyAPI:
def __init__(self, config):
self.base_url = config.base_url
self.api_key = config.api_key
def create_account(self, account_data):
"""Erstellt neues Konto im MoneyServer"""
endpoint = f"{self.base_url}/api/account/create"
# API Call Implementierung
def transfer_funds(self, from_uuid, to_uuid, amount):
"""Führt Überweisung durch"""
endpoint = f"{self.base_url}/api/transaction/transfer"
# API Call Implementierung
def get_balance(self, account_uuid):
"""Abfrage Kontostand"""
endpoint = f"{self.base_url}/api/account/{account_uuid}/balance"
def get_transaction_history(self, account_uuid, limit=100):
"""Transaktionshistorie abrufen"""
Erweiterte Finanzfunktionen
1. Multi-Währungsunterstützung
class CurrencyExchange(models.Model):
_name = 'opensim.currency.exchange'
from_currency = fields.Many2one('res.currency', 'From Currency')
to_currency = fields.Many2one('res.currency', 'To Currency')
exchange_rate = fields.Float('Exchange Rate')
fee_percentage = fields.Float('Exchange Fee %')
2. Rechnungsstellung
class OpenSimInvoice(models.Model):
_name = 'opensim.currency.invoice'
invoice_number = fields.Char('Invoice Number')
amount = fields.Float('Amount')
currency = fields.Many2one('res.currency', 'Currency')
due_date = fields.Date('Due Date')
status = fields.Selection([
('draft', 'Draft'),
('sent', 'Sent'),
('paid', 'Paid')
])
3. Berichte und Analytics
class CurrencyAnalytics(models.Model):
_name = 'opensim.currency.analytics'
@api.model
def get_daily_transactions(self):
"""Tägliche Transaktionsstatistiken"""
return {
'total_volume': self._calculate_daily_volume(),
'transaction_count': self._count_daily_transactions(),
'average_transaction': self._calculate_average_transaction()
}
Manifest-Datei
# __manifest__.py
{
'name': 'OpenSim Currency Server Integration',
'version': '1.0',
'category': 'Accounting',
'summary': 'Integration mit C# MoneyServer für virtuelle Währungen',
'depends': ['base', 'account'],
'data': [
'security/ir.model.access.csv',
'views/currency_views.xml',
'views/transaction_views.xml',
'views/dashboard.xml',
],
'installable': True,
'application': True,
}
Sicherheitsfeatures
1. Zugriffskontrolle
# security/ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_opensim_currency_user,opensim.currency.user,model_opensim_currency_account,account.group_account_user,1,1,1,0
access_opensim_currency_manager,opensim.currency.manager,model_opensim_currency_account,account.group_account_manager,1,1,1,1
2. Transaktionssicherheit
class OpenSimTransaction(models.Model):
# ... existing fields ...
def _validate_transaction(self):
"""Validiert Transaktion vor Ausführung"""
if self.amount <= 0:
raise ValidationError(_("Amount must be positive"))
if self.from_account.balance < self.amount:
raise ValidationError(_("Insufficient funds"))
Installation und Konfiguration
- Plugin installieren in OpenERP
- Server konfigurieren mit C# MoneyServer URL und API Key
- Währungen einrichten und Exchange Rates definieren
- Benutzerkonten synchronisieren mit MoneyServer
Vorteile dieser Integration
- Echtzeit-Synchronisation zwischen OpenERP und MoneyServer
- Umfassende Berichterstattung für virtuelle Währungen
- Multi-Währungsunterstützung
- Automatisierte Transaktionsverarbeitung
- Sicherheits- und Validierungsmechanismen