Merge pull request #6057 from expsa/fix_bugs

Fix bugs
This commit is contained in:
NossibaElhadi 2026-01-08 00:01:25 +03:00 committed by GitHub
commit 69da71f289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 146 additions and 22 deletions

View File

@ -7524,3 +7524,68 @@ 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 Bank and 4 Last Digits."
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
#: 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 "يجب ادخال حساب الجمعية"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_account_payment_register__bank_id
msgid "Bank"
msgstr "البنك"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_account_payment_register__last_digits
msgid "Last Digits"
msgstr "اخر اربعة خانات"
#. module: odex_takaful
#: model:ir.model.fields,field_description:odex_takaful.field_account_payment_register__show_last_digits
msgid "Use 4 Digits"
msgstr "استخدام اخر اربعة خانات"

View File

@ -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'

View File

@ -62,7 +62,7 @@ class TakafulSponsorship(models.Model):
gifter_message = fields.Text(string='Message To Gifter')
sponsorship_type = fields.Selection([('person', 'Individual'),('group', 'Group')],string='Sponsorship Type',tracking=True)
code = fields.Char(string="Sequence",copy=False,readonly=True)
code = fields.Char(string="Sequence",copy=False)
benefit_type = fields.Selection([('orphan', 'Orphans'),('widow', 'Widows')],string='Sponsorship Beneficiary Type',tracking=True)
branch_custom_id = fields.Many2one('branch.settings', string="Branch", default=lambda self: self._default_branch_custom_id(), required=True, tracking=True)
sponsorship_creation_date = fields.Datetime(string="Sponsorship Creation Date", default=fields.Datetime.now, required=True, copy=False)

View File

@ -174,6 +174,7 @@
<field name="is_donations_coordinator" invisible="1"/>
<field name="is_sponsorship_coordinator" invisible="1"/>
<field name="registered_type" invisible="1" attrs="{'readonly': [('state','!=','draft')]}"/>
<field name="code" invisible="1" attrs="{'readonly': True}"/>
<label string="Sponsor / Donor Type" for="sponsor_or_donor_type"/>
<div class="o_row">

View File

@ -1,4 +1,6 @@
from odoo import api, fields, models, _
from odoo.exceptions import ValidationError
import logging
@ -89,6 +91,9 @@ class AccountRegisterPayment(models.TransientModel):
string="Show Payment Group",
compute="_compute_show_payment_group"
)
show_last_digits = fields.Boolean(string="Use 4 Digits",)
last_digits = fields.Integer(string="Last Digits")
bank_id = fields.Many2one('res.bank', string="Bank")
@api.depends('can_group_payments')
def _compute_show_payment_group(self):
@ -271,6 +276,44 @@ 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.transaction_file_attachment:
errors.append(_("Please enter File Attached."))
if method == 'bank':
if self.show_last_digits:
if not self.last_digits or not self.bank_id and self.last_digits <= 0:
errors.append(_("Please enter Bank and 4 Last Digits."))
elif not self.show_last_digits and not self.partner_bank_id:
errors.append(_("Please enter Partner Bank ID."))
if method == 'check':
if not self.partner_bank_id:
errors.append(_("Please enter Partner Bank ID."))
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))
self.communication += "******" + self.bank_id.name + "******" + str(self.last_digits)
res = super(AccountRegisterPayment,
self.with_context(skip_account_move_synchronization=True)).action_create_payments()
@ -291,19 +334,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 +367,5 @@ class AccountRegisterPayment(models.TransientModel):
},
}
return {'type': 'ir.actions.act_window_close'}
else:
return {'type': 'ir.actions.act_window_close'}

View File

@ -63,6 +63,10 @@
<xpath expr="//field[@name='payment_method_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
</xpath>
<xpath expr="//field[@name='payment_method_line_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
</xpath>
<xpath expr="//field[@name='branch_id']" position="attributes">
<attribute name="invisible">context.get('sponsorship_payment')</attribute>
@ -82,7 +86,7 @@
<field name="machine_id"
options="{'no_create': True, 'no_create_edit': True, 'no_open': True}"
domain="[('branch_custom_id', '=', sponsorship_branch_id)]"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method', '!=', 'network')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method', '=', 'network')]}"/>
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method', '!=', 'network')]}"/>
<field name="machine_reference"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method', '!=', 'network')]}"/>
</xpath>
@ -97,20 +101,28 @@
<field name="takaful_payment_method" invisible="1"/>
<!-- <field name="payment_method" attrs="{'invisible': [('sponsorship_payment', '=', False)]}"/>-->
<field name="payment_method" invisible="1"/>
<field name="check_number" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<field name="check_due_date" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','check')]}"/>
<field name="partner_bank_id" string="Donor Bank Account" options="{'skip_disable_quick_create': True}" context="{'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create', 'default_partner_id': context.get('force_sponsorship_line_partner_id')}" attrs="{'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','in',['bank','check'])], 'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','not in',['bank','check'])]}" create="1" edit="1"/>
<field name="check_number" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')]}"/>
<field name="check_due_date" attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','check')]}"/>
<field name="partner_bank_id" string="Donor Bank Account" options="{'skip_disable_quick_create': True}" context="{'form_view_ref': 'odex_takaful.res_partner_bank_view_form_quick_create', 'default_partner_id': context.get('force_sponsorship_line_partner_id')}" attrs="{'invisible': ['|', '|', ('sponsorship_payment', '=', False), ('show_last_digits', '=', True), ('takaful_payment_method','not in',['bank','check'])]}" create="1" edit="1"/>
<field name="show_last_digits"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','!=','bank')]}"/>
<field name="last_digits"
attrs="{'invisible': [('show_last_digits', '=', False)]}"/>
<field name="bank_id"
attrs="{'invisible': [('show_last_digits', '=', False)]}"/>
<field name="transaction_file_attachment" widget="binary"
filename="transaction_attachment_file_name"
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','not in',['bank', 'check'])], 'required': [('sponsorship_payment', '=', True), ('takaful_payment_method','=','bank')]}"/>
attrs="{'invisible': ['|', ('sponsorship_payment', '=', False), ('takaful_payment_method','not in',['bank', 'check'])]}"/>
<field name="transaction_attachment_file_name" invisible="1"/>
<field name="payment_date" attrs="{'readonly': [('sponsorship_payment', '=', True)]}"/>
<field name="communication"/>
</xpath>
<xpath expr="//footer/button[2]" position="replace">
<!-- <field name="show_cancel_button" invisible="1"/>-->
<button string="Cancel"
special="cancel"
<button name="action_cancel" type="object" string="Cancel"
class="btn-secondary"/>
<!-- attrs="{'invisible': [('show_cancel_button', '=', True)]}" />-->
</xpath>