[IMP] other: automatic update
Auto-generated commit based on local changes.
This commit is contained in:
parent
34c5010425
commit
6839d3c110
|
|
@ -4,3 +4,21 @@ from . import reports
|
||||||
from . import wizards
|
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',
|
# 'analytic_account',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
'data/payment_methods_ar.xml',
|
|
||||||
'security/security_data.xml',
|
'security/security_data.xml',
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
|
|
||||||
|
|
@ -95,6 +94,7 @@
|
||||||
'static/src/xml/takaful_dashboard.xml',
|
'static/src/xml/takaful_dashboard.xml',
|
||||||
],
|
],
|
||||||
'icon': 'static/description/icon.png',
|
'icon': 'static/description/icon.png',
|
||||||
|
'post_init_hook': '_update_payment_method_names',
|
||||||
# 'installable': True,
|
# 'installable': True,
|
||||||
# 'application': True,
|
# 'application': True,
|
||||||
# 'auto_install': False,
|
# '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:
|
if rec.waiting_date:
|
||||||
delta = rec.waiting_date - today
|
delta = rec.waiting_date - today
|
||||||
if delta.days > 0:
|
if delta.days > 0:
|
||||||
period_display = str(delta.days) + " Days"
|
period_display = str(delta.days) + " يوم"
|
||||||
else:
|
else:
|
||||||
period_display = "Expired"
|
period_display = "منتهي"
|
||||||
elif rec.end_date:
|
elif rec.end_date:
|
||||||
delta = rec.end_date - today
|
delta = rec.end_date - today
|
||||||
if delta.days > 0:
|
if delta.days > 0:
|
||||||
period_display = str(delta.days) + " Days"
|
period_display = str(delta.days) + " يوم"
|
||||||
else:
|
else:
|
||||||
period_display = "Expired"
|
period_display = "منتهي"
|
||||||
rec.period_display = period_display
|
rec.period_display = period_display
|
||||||
|
|
||||||
@api.depends('direct_debit', 'sponsorship_id', 'sponsorship_mechanism_id')
|
@api.depends('direct_debit', 'sponsorship_id', 'sponsorship_mechanism_id')
|
||||||
|
|
@ -248,28 +248,6 @@ class DonationsDetailsLines(models.Model):
|
||||||
|
|
||||||
rec.payment_method_display = method
|
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')
|
@api.constrains('state')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue