[IMP] other: automatic update
Auto-generated commit based on local changes.
This commit is contained in:
parent
ce6f20ca3b
commit
bbe17c70a9
|
|
@ -2,23 +2,3 @@ from . import models
|
||||||
from . import controllers
|
from . import controllers
|
||||||
from . import reports
|
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})
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@
|
||||||
'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,22 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<odoo>
|
|
||||||
<data>
|
|
||||||
<!-- <record id="server_action_unlink_sponsor_and_related" model="ir.actions.server">
|
|
||||||
<field name="name">Sponsor Unlink And Its Relations</field>
|
|
||||||
<field name="model_id" ref="odex_takaful.model_takaful_sponsor"/>
|
|
||||||
<field name="binding_model_id" ref="odex_takaful.model_takaful_sponsor"/>
|
|
||||||
<field name="state">code</field>
|
|
||||||
<field name="code">
|
|
||||||
action = records.action_unlink_sponsor_and_related()
|
|
||||||
</field>
|
|
||||||
</record> -->
|
|
||||||
|
|
||||||
<record id="action_extend_donation" model="ir.actions.server">
|
|
||||||
<field name="name">Extend Donation</field>
|
|
||||||
<field name="model_id" ref="odex_takaful.model_donations_details_lines"/>
|
|
||||||
<field name="binding_model_id" ref="odex_takaful.model_donations_details_lines"/>
|
|
||||||
<field name="state">code</field>
|
|
||||||
<field name="code">action = records.action_extend_sponsorship()</field>
|
|
||||||
</record>
|
|
||||||
</data>
|
|
||||||
</odoo>
|
|
||||||
|
|
@ -135,6 +135,12 @@ class DonationsDetailsLines(models.Model):
|
||||||
compute='_compute_payment_method_display',
|
compute='_compute_payment_method_display',
|
||||||
store=True
|
store=True
|
||||||
)
|
)
|
||||||
|
# Stored field to hold the actual payment method selected during payment
|
||||||
|
takaful_payment_method_id = fields.Many2one(
|
||||||
|
'takaful.payment.method',
|
||||||
|
string='Payment Method (Stored)',
|
||||||
|
help='Payment method selected during payment registration',
|
||||||
|
)
|
||||||
payment_method_type = fields.Selection(related='payment_method_display.payment_method', string='Payment Method Type', store=True)
|
payment_method_type = fields.Selection(related='payment_method_display.payment_method', string='Payment Method Type', store=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -220,22 +226,26 @@ class DonationsDetailsLines(models.Model):
|
||||||
period_display = "منتهي"
|
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', 'takaful_payment_method_id')
|
||||||
def _compute_payment_method_display(self):
|
def _compute_payment_method_display(self):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
method = False
|
method = False
|
||||||
# 1. Check Direct Debit first
|
|
||||||
if rec.direct_debit:
|
# 1. PRIORITY: Use stored payment method if available (set during payment)
|
||||||
|
if rec.takaful_payment_method_id:
|
||||||
|
method = rec.takaful_payment_method_id.id
|
||||||
|
|
||||||
|
# 2. Check Direct Debit flag
|
||||||
|
if not method and rec.direct_debit:
|
||||||
dd_method = self.env['takaful.payment.method'].search([('payment_method', '=', 'direct_debit')], limit=1)
|
dd_method = self.env['takaful.payment.method'].search([('payment_method', '=', 'direct_debit')], limit=1)
|
||||||
if dd_method:
|
if dd_method:
|
||||||
method = dd_method.id
|
method = dd_method.id
|
||||||
|
|
||||||
# 2. If not Direct Debit, check related Payments
|
# 3. FALLBACK: If not stored, check related Payments via journal
|
||||||
if not method:
|
if not method:
|
||||||
sponsorship_id = rec.sponsorship_id.id or rec.sponsorship_mechanism_id.id
|
sponsorship_id = rec.sponsorship_id.id or rec.sponsorship_mechanism_id.id
|
||||||
if sponsorship_id:
|
if sponsorship_id:
|
||||||
# Find latest posted payment for this sponsorship
|
# Find latest posted payment for this sponsorship
|
||||||
# We use the related field 'takaful_sponsorship_id' on account.payment which is computed from the move
|
|
||||||
payment = self.env['account.payment'].search([
|
payment = self.env['account.payment'].search([
|
||||||
('takaful_sponsorship_id', '=', sponsorship_id),
|
('takaful_sponsorship_id', '=', sponsorship_id),
|
||||||
('state', '=', 'posted')
|
('state', '=', 'posted')
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,11 @@ class AccountRegisterPayment(models.TransientModel):
|
||||||
state = 'paid'
|
state = 'paid'
|
||||||
else:
|
else:
|
||||||
state = 'paid'
|
state = 'paid'
|
||||||
line.write({'state': state})
|
# Write both state and payment method to the line
|
||||||
|
write_vals = {'state': state}
|
||||||
|
if self.takaful_payment_method_id:
|
||||||
|
write_vals['takaful_payment_method_id'] = self.takaful_payment_method_id.id
|
||||||
|
line.write(write_vals)
|
||||||
if self.env.context.get('schedule_line_payment'):
|
if self.env.context.get('schedule_line_payment'):
|
||||||
schedule_line = self.env['sponsorship.scheduling.line'].browse(self.env.context.get('schedule_line_id'))
|
schedule_line = self.env['sponsorship.scheduling.line'].browse(self.env.context.get('schedule_line_id'))
|
||||||
schedule_line.sudo().write({'status': 'paid'})
|
schedule_line.sudo().write({'status': 'paid'})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue