Merge pull request #6105 from expsa/14.0-feat-other-auto-20260110_212833
[IMP] other odex_takaful: improve data models and business logic
This commit is contained in:
commit
ce6f20ca3b
|
|
@ -4,3 +4,21 @@ from . import reports
|
|||
from . import wizards
|
||||
|
||||
|
||||
def _update_payment_method_names(cr, registry):
|
||||
"""Update payment method names to Arabic after module installation/upgrade."""
|
||||
from odoo import api, SUPERUSER_ID
|
||||
env = api.Environment(cr, SUPERUSER_ID, {})
|
||||
|
||||
translations = {
|
||||
'cash': 'نقدي',
|
||||
'bank': 'تحويل بنكي',
|
||||
'direct_debit': 'استقطاع',
|
||||
'check': 'شيك',
|
||||
'network': 'شبكة',
|
||||
}
|
||||
|
||||
PaymentMethod = env['takaful.payment.method']
|
||||
for method_key, arabic_name in translations.items():
|
||||
records = PaymentMethod.search([('payment_method', '=', method_key)])
|
||||
if records:
|
||||
records.write({'name': arabic_name})
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
# 'analytic_account',
|
||||
],
|
||||
'data': [
|
||||
'data/payment_methods_ar.xml',
|
||||
'security/security_data.xml',
|
||||
'security/ir.model.access.csv',
|
||||
|
||||
|
|
@ -95,6 +94,7 @@
|
|||
'static/src/xml/takaful_dashboard.xml',
|
||||
],
|
||||
'icon': 'static/description/icon.png',
|
||||
'post_init_hook': '_update_payment_method_names',
|
||||
# 'installable': True,
|
||||
# 'application': True,
|
||||
# 'auto_install': False,
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<data noupdate="0">
|
||||
<!-- Force update Payment Method Names to Arabic -->
|
||||
|
||||
<!-- Cash -> نقدي -->
|
||||
<function model="takaful.payment.method" name="write">
|
||||
<value model="takaful.payment.method" search="[('payment_method', '=', 'cash')]"/>
|
||||
<value eval="{'name': 'نقدي'}"/>
|
||||
</function>
|
||||
|
||||
<!-- Bank Transfer -> تحويل بنكي -->
|
||||
<function model="takaful.payment.method" name="write">
|
||||
<value model="takaful.payment.method" search="[('payment_method', '=', 'bank')]"/>
|
||||
<value eval="{'name': 'تحويل بنكي'}"/>
|
||||
</function>
|
||||
|
||||
<!-- Direct Debit -> استقطاع -->
|
||||
<function model="takaful.payment.method" name="write">
|
||||
<value model="takaful.payment.method" search="[('payment_method', '=', 'direct_debit')]"/>
|
||||
<value eval="{'name': 'استقطاع'}"/>
|
||||
</function>
|
||||
|
||||
<!-- Check -> شيك -->
|
||||
<function model="takaful.payment.method" name="write">
|
||||
<value model="takaful.payment.method" search="[('payment_method', '=', 'check')]"/>
|
||||
<value eval="{'name': 'شيك'}"/>
|
||||
</function>
|
||||
|
||||
<!-- Network -> شبكة -->
|
||||
<function model="takaful.payment.method" name="write">
|
||||
<value model="takaful.payment.method" search="[('payment_method', '=', 'network')]"/>
|
||||
<value eval="{'name': 'شبكة'}"/>
|
||||
</function>
|
||||
</data>
|
||||
</odoo>
|
||||
|
|
@ -209,15 +209,15 @@ class DonationsDetailsLines(models.Model):
|
|||
if rec.waiting_date:
|
||||
delta = rec.waiting_date - today
|
||||
if delta.days > 0:
|
||||
period_display = str(delta.days) + " Days"
|
||||
period_display = str(delta.days) + " يوم"
|
||||
else:
|
||||
period_display = "Expired"
|
||||
period_display = "منتهي"
|
||||
elif rec.end_date:
|
||||
delta = rec.end_date - today
|
||||
if delta.days > 0:
|
||||
period_display = str(delta.days) + " Days"
|
||||
period_display = str(delta.days) + " يوم"
|
||||
else:
|
||||
period_display = "Expired"
|
||||
period_display = "منتهي"
|
||||
rec.period_display = period_display
|
||||
|
||||
@api.depends('direct_debit', 'sponsorship_id', 'sponsorship_mechanism_id')
|
||||
|
|
@ -248,28 +248,6 @@ class DonationsDetailsLines(models.Model):
|
|||
|
||||
rec.payment_method_display = method
|
||||
|
||||
# pick whichever date is set
|
||||
if rec.state == 'replace' :
|
||||
base_date = rec.end_date
|
||||
elif rec.state == 'waiting':
|
||||
base_date = rec.waiting_date
|
||||
else:
|
||||
base_date = False
|
||||
if base_date:
|
||||
today = fields.Date.today()
|
||||
delta = relativedelta(today, base_date)
|
||||
# build human-readable string
|
||||
if delta.years > 0:
|
||||
rec.period_display = f"{delta.years} year(s)"
|
||||
elif delta.months > 0:
|
||||
rec.period_display = f"{delta.months} month(s)"
|
||||
elif delta.days > 0:
|
||||
rec.period_display = f"{delta.days} day(s)"
|
||||
else:
|
||||
rec.period_display = "Today"
|
||||
else:
|
||||
rec.period_display = "No date"
|
||||
|
||||
|
||||
|
||||
@api.constrains('state')
|
||||
|
|
|
|||
Loading…
Reference in New Issue