From bbe17c70a92dba359045801ad328fdeddea149f9 Mon Sep 17 00:00:00 2001 From: maltayyar2 Date: Sun, 11 Jan 2026 00:33:53 +0300 Subject: [PATCH] [IMP] other: automatic update Auto-generated commit based on local changes. --- odex25_takaful/odex_takaful/__init__.py | 20 ----------------- odex25_takaful/odex_takaful/__manifest__.py | 1 - .../odex_takaful/data/server_actions.xml | 22 ------------------- .../models/donation_details_lines.py | 20 ++++++++++++----- .../wizards/account_payment_register.py | 6 ++++- 5 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 odex25_takaful/odex_takaful/data/server_actions.xml diff --git a/odex25_takaful/odex_takaful/__init__.py b/odex25_takaful/odex_takaful/__init__.py index 19081f057..e500ff830 100644 --- a/odex25_takaful/odex_takaful/__init__.py +++ b/odex25_takaful/odex_takaful/__init__.py @@ -2,23 +2,3 @@ from . import models from . import controllers 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}) diff --git a/odex25_takaful/odex_takaful/__manifest__.py b/odex25_takaful/odex_takaful/__manifest__.py index 071a62f37..1a51da628 100644 --- a/odex25_takaful/odex_takaful/__manifest__.py +++ b/odex25_takaful/odex_takaful/__manifest__.py @@ -94,7 +94,6 @@ '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, diff --git a/odex25_takaful/odex_takaful/data/server_actions.xml b/odex25_takaful/odex_takaful/data/server_actions.xml deleted file mode 100644 index ef0ca221a..000000000 --- a/odex25_takaful/odex_takaful/data/server_actions.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Extend Donation - - - code - action = records.action_extend_sponsorship() - - - \ No newline at end of file diff --git a/odex25_takaful/odex_takaful/models/donation_details_lines.py b/odex25_takaful/odex_takaful/models/donation_details_lines.py index d8fb6a84b..163a4849c 100644 --- a/odex25_takaful/odex_takaful/models/donation_details_lines.py +++ b/odex25_takaful/odex_takaful/models/donation_details_lines.py @@ -135,6 +135,12 @@ class DonationsDetailsLines(models.Model): compute='_compute_payment_method_display', 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) @@ -220,22 +226,26 @@ class DonationsDetailsLines(models.Model): 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): for rec in self: 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) if dd_method: 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: sponsorship_id = rec.sponsorship_id.id or rec.sponsorship_mechanism_id.id if sponsorship_id: # 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([ ('takaful_sponsorship_id', '=', sponsorship_id), ('state', '=', 'posted') diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.py b/odex25_takaful/odex_takaful/wizards/account_payment_register.py index 2132726a8..9890cbf8d 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.py +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.py @@ -191,7 +191,11 @@ class AccountRegisterPayment(models.TransientModel): state = 'paid' else: 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'): schedule_line = self.env['sponsorship.scheduling.line'].browse(self.env.context.get('schedule_line_id')) schedule_line.sudo().write({'status': 'paid'})