54 lines
2.0 KiB
Python
54 lines
2.0 KiB
Python
print("\n--- FAZ 2 TEST BAŞLIYOR ---")
|
||
product = env['product.template'].create({'name': 'Test Bakım Ürünü', 'type': 'service', 'purchase_ok': False})
|
||
|
||
# Odoo'nun demo datalarında USD olmayabilir veya inaktif olabilir, bulalım veya yaratalım
|
||
currency_usd = env['res.currency'].search([('name', '=', 'USD'), '|', ('active', '=', True), ('active', '=', False)], limit=1)
|
||
if not currency_usd:
|
||
currency_usd = env['res.currency'].create({'name': 'USD', 'symbol': '$', 'active': True})
|
||
else:
|
||
currency_usd.active = True
|
||
|
||
# Örnek kurlar ekleyelim (TL'den USD'ye çeviri için)
|
||
from datetime import date
|
||
env['res.currency.rate'].create({
|
||
'name': date.today(),
|
||
'currency_id': currency_usd.id,
|
||
'company_id': env.company.id,
|
||
'rate': 0.03 # Örn: 1 TL = 0.03 USD
|
||
})
|
||
|
||
model = env['fleet.vehicle.model'].search([], limit=1)
|
||
if not model:
|
||
brand = env['fleet.vehicle.model.brand'].create({'name': 'Test Brand'})
|
||
model = env['fleet.vehicle.model'].create({'name': 'Test Model', 'brand_id': brand.id})
|
||
|
||
vehicle = env['fleet.vehicle'].create({
|
||
'model_id': model.id,
|
||
'license_plate': '34 TEST 2026',
|
||
'purchase_value': 1000000.0,
|
||
'index_currency_id': currency_usd.id
|
||
})
|
||
|
||
# Maliyet Matrisi Kaydı
|
||
cost1 = env['mymach.fleet.maintenance.cost'].create({
|
||
'name': '10.000 Bakımı',
|
||
'product_id': product.id,
|
||
'vehicle_id': vehicle.id,
|
||
'amount': 5000.0
|
||
})
|
||
cost2 = env['mymach.fleet.maintenance.cost'].create({
|
||
'name': '20.000 Bakımı',
|
||
'product_id': product.id,
|
||
'vehicle_id': vehicle.id,
|
||
'amount': 7000.0
|
||
})
|
||
|
||
print("TEST_RESULT_START")
|
||
print("Ürün Masraf Bayrağı (can_be_expensed):", getattr(product, 'can_be_expensed', 'Masraf Modülü Yüklü Değil, Atlandı.'))
|
||
print("Ürün Satınalma Bayrağı (purchase_ok):", product.purchase_ok)
|
||
print("Araç Hareketli Ortalama Bakım Maliyeti (Beklenen 6000):", vehicle.moving_average_maintenance_cost)
|
||
print("Araç Endeksli Alım Bedeli (USD, Kura Göre Hesaplanır):", vehicle.indexed_purchase_value)
|
||
print("TEST_RESULT_END")
|
||
print("--- FAZ 2 TEST BİTTİ ---\n")
|
||
env.cr.rollback()
|