From 2d11576926109511cea07a0ae473a2d07bc39f31 Mon Sep 17 00:00:00 2001 From: Nossibaelhadi Date: Wed, 7 Jan 2026 20:40:07 +0300 Subject: [PATCH] [FIX] solve bugs from test9 --- odex25_takaful/odex_takaful/i18n/ar_001.po | 45 +++++++++++++ .../models/donation_details_lines.py | 1 + .../wizards/account_payment_register.py | 63 ++++++++++++++----- .../wizards/account_payment_register.xml | 13 ++-- 4 files changed, 101 insertions(+), 21 deletions(-) diff --git a/odex25_takaful/odex_takaful/i18n/ar_001.po b/odex25_takaful/odex_takaful/i18n/ar_001.po index 0de7a4b2d..2ce905dbe 100644 --- a/odex25_takaful/odex_takaful/i18n/ar_001.po +++ b/odex25_takaful/odex_takaful/i18n/ar_001.po @@ -7524,3 +7524,48 @@ msgstr "رقم المرجع" #: model:ir.model.fields,help:odex_takaful.field_account_payment__machine_reference msgid "Reference number from the payment machine" msgstr "رقم المرجع من ماكينة الدفع" + + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter Check Due Date." +msgstr "يجب إدخال تاريخ الإستحقاق" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter Check Number." +msgstr "يجب إدخال رقم الشيك" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter File Attached." +msgstr "يجب إدخال المستند" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter Machine." +msgstr "يجب إدخال الماكينة" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter Partner Bank ID." +msgstr "يجب إدخال بنك المتبرع/الكافل" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter Payment Method." +msgstr "يجل إدخال طريقة الدفع" + +#. module: odex_takaful +#: code:addons/odex_takaful/wizards/account_payment_register.py:0 +#, python-format +msgid "Please enter journal ID." +msgstr "يجب إدخال جساب الجمعية" + + diff --git a/odex25_takaful/odex_takaful/models/donation_details_lines.py b/odex25_takaful/odex_takaful/models/donation_details_lines.py index d8392dfaf..586773e45 100644 --- a/odex25_takaful/odex_takaful/models/donation_details_lines.py +++ b/odex25_takaful/odex_takaful/models/donation_details_lines.py @@ -301,6 +301,7 @@ class DonationsDetailsLines(models.Model): for rec in self: show_extend_button = ( rec.record_type == 'sponsorship' and + rec.sponsorship_duration != "permanent" and rec.end_date and rec.end_date >= today and rec.state == 'active' diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.py b/odex25_takaful/odex_takaful/wizards/account_payment_register.py index 49a6c68c8..0d172a294 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.py +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.py @@ -1,4 +1,6 @@ from odoo import api, fields, models, _ +from odoo.exceptions import ValidationError + import logging @@ -271,6 +273,37 @@ class AccountRegisterPayment(models.TransientModel): return super(AccountRegisterPayment, self)._get_batch_available_partner_banks(batch_result, journal) def action_create_payments(self): + errors = [] + + if self.sponsorship_payment: + if not self.takaful_payment_method_id: + errors.append(_("Please enter Payment Method.")) + + if not self.journal_id: + errors.append(_("Please enter journal ID.")) + + if self.takaful_payment_method_id: + method = self.takaful_payment_method_id.payment_method + + if method in ('check', 'bank'): + if not self.partner_bank_id: + errors.append(_("Please enter Partner Bank ID.")) + if not self.transaction_file_attachment: + errors.append(_("Please enter File Attached.")) + + if method == 'check': + if not self.check_number: + errors.append(_("Please enter Check Number.")) + if not self.check_due_date: + errors.append(_("Please enter Check Due Date.")) + + if method == 'network': + if not self.machine_id: + errors.append(_("Please enter Machine.")) + + if errors: + raise ValidationError("\n".join(errors)) + res = super(AccountRegisterPayment, self.with_context(skip_account_move_synchronization=True)).action_create_payments() @@ -291,19 +324,21 @@ class AccountRegisterPayment(models.TransientModel): 'no_quick_close': True, }, } - return { - 'type': 'ir.actions.client', - 'tag': 'display_notification', - 'params': { - 'title': _('Success'), - 'message': _('Payment registered successfully'), - 'type': 'success', - 'sticky': False, - 'next': {'type': 'ir.actions.act_window_close'} - }, - } + else: + return { + 'type': 'ir.actions.client', + 'tag': 'display_notification', + 'params': { + 'title': _('Success'), + 'message': _('Payment registered successfully'), + 'type': 'success', + 'sticky': False, + 'next': {'type': 'ir.actions.act_window_close'} + }, + } - return res + else: + return res def action_cancel(self): wiz_id = self.env.context.get('wiz_id') @@ -322,5 +357,5 @@ class AccountRegisterPayment(models.TransientModel): }, } - - return {'type': 'ir.actions.act_window_close'} + else: + return {'type': 'ir.actions.act_window_close'} diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml index 6fd072dda..964a3c499 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml @@ -82,7 +82,7 @@ + attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method', '!=', 'network')]}"/> @@ -97,20 +97,19 @@ - - - + + + + attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','not in',['bank', 'check'])]}"/> -