From c81cfa3b531a0f71d21c0b571c7ed80477963ee3 Mon Sep 17 00:00:00 2001 From: maltayyar2 Date: Tue, 6 Jan 2026 02:29:10 +0300 Subject: [PATCH] [I18N] odex_takaful: automatic update Auto-generated commit based on local changes. --- odex25_takaful/odex_takaful/__manifest__.py | 1 + odex25_takaful/odex_takaful/i18n/ar_001.po | 2 +- .../odex_takaful/models/__init__.py | 1 + .../odex_takaful/models/payment_machine.py | 68 +++++++++++ .../odex_takaful/models/res_partner.py | 14 ++- .../models/takaful_sponorship_model.py | 1 + .../odex_takaful/security/ir.model.access.csv | 2 + .../views/payment_machine_views.xml | 108 ++++++++++++++++++ .../wizards/account_payment_register.py | 42 ++++++- .../wizards/account_payment_register.xml | 19 ++- 10 files changed, 248 insertions(+), 10 deletions(-) create mode 100644 odex25_takaful/odex_takaful/models/payment_machine.py create mode 100644 odex25_takaful/odex_takaful/views/payment_machine_views.xml diff --git a/odex25_takaful/odex_takaful/__manifest__.py b/odex25_takaful/odex_takaful/__manifest__.py index 66e574e81..762f6b06f 100644 --- a/odex25_takaful/odex_takaful/__manifest__.py +++ b/odex25_takaful/odex_takaful/__manifest__.py @@ -80,6 +80,7 @@ 'views/preferred_communication.xml', 'views/takaful_payment_method.xml', 'views/product_views.xml', + 'views/payment_machine_views.xml', 'views/takaful_menus_actions.xml', 'data/message_template_data.xml', 'data/server_actions.xml', diff --git a/odex25_takaful/odex_takaful/i18n/ar_001.po b/odex25_takaful/odex_takaful/i18n/ar_001.po index e1a5692e1..0f475a9e6 100644 --- a/odex25_takaful/odex_takaful/i18n/ar_001.po +++ b/odex25_takaful/odex_takaful/i18n/ar_001.po @@ -4642,7 +4642,7 @@ msgstr "فواتير المدفوعات" #: model_terms:ir.ui.view,arch_db:odex_takaful.view_account_payment_register_form #, python-format msgid "Payment Method" -msgstr "طريقة الدفع" +msgstr "طريقة السداد" #. module: odex_takaful #: model:ir.model.fields,field_description:odex_takaful.field_donations_details_lines__payment_month_count diff --git a/odex25_takaful/odex_takaful/models/__init__.py b/odex25_takaful/odex_takaful/models/__init__.py index 2a117e145..0efc0b126 100644 --- a/odex25_takaful/odex_takaful/models/__init__.py +++ b/odex25_takaful/odex_takaful/models/__init__.py @@ -28,3 +28,4 @@ from . import donation_extension_history from . import family_member from . import sponsorship_scheduling_line from . import donation_replacement_log +from . import payment_machine diff --git a/odex25_takaful/odex_takaful/models/payment_machine.py b/odex25_takaful/odex_takaful/models/payment_machine.py new file mode 100644 index 000000000..3092ec001 --- /dev/null +++ b/odex25_takaful/odex_takaful/models/payment_machine.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- + +from odoo import models, fields, api, _ + + +class PaymentMachine(models.Model): + """Payment Machine Model for POS Terminals like Gidea, Neoleap, etc.""" + _name = 'payment.machine' + _description = 'Payment Machine' + _order = 'name' + _rec_name = 'name' + + name = fields.Char( + string='Machine Name', + required=True, + help='Name or identifier of the payment machine' + ) + code = fields.Char( + string='Machine Code', + help='Serial number or code of the payment machine' + ) + machine_type = fields.Selection([ + ('neoleap', 'Neoleap'), + ('gidea', 'Gidea'), + ('other', 'Other'), + ], string='Machine Type', required=True, default='neoleap') + machine_type_other = fields.Char( + string='Other Machine Type', + help='Specify the machine type if not listed above' + ) + branch_custom_id = fields.Many2one( + 'branch.settings', + string='Branch', + required=True, + help='Branch where this payment machine is located' + ) + journal_id = fields.Many2one( + 'account.journal', + string='Journal', + required=True, + domain="[('type', '=', 'bank')]", + help='Bank journal associated with this payment machine' + ) + active = fields.Boolean( + string='Active', + default=True, + help='If unchecked, the machine will be archived and hidden' + ) + notes = fields.Text( + string='Notes', + help='Additional notes or information about the machine' + ) + + _sql_constraints = [ + ('code_unique', 'UNIQUE(code)', 'Machine code must be unique!'), + ] + + @api.depends('name', 'code') + def name_get(self): + """Display name with code if available""" + result = [] + for record in self: + if record.code: + name = f"{record.name} [{record.code}]" + else: + name = record.name + result.append((record.id, name)) + return result diff --git a/odex25_takaful/odex_takaful/models/res_partner.py b/odex25_takaful/odex_takaful/models/res_partner.py index 6e6ccd132..0cc57af22 100644 --- a/odex25_takaful/odex_takaful/models/res_partner.py +++ b/odex25_takaful/odex_takaful/models/res_partner.py @@ -211,10 +211,15 @@ class ResPartner(models.Model): if not args: args = [] + # If no name is provided, use standard Odoo search behavior + # This fixes the issue where empty name causes invalid domain + if not name: + return super()._name_search(name, args=args, operator=operator, limit=limit, name_get_uid=name_get_uid) + # Build search domains for the raw name and (optionally) the name # without leading zero, to "ignore" a starting 0 in the search term. - search_terms = [name] if name else [] - if name and name.startswith('0'): + search_terms = [name] + if name.startswith('0'): search_terms.append(name[1:]) domain = [] @@ -562,9 +567,10 @@ class ResPartner(models.Model): def name_get(self): result = [] for sponsor in self: - name = sponsor.name + # Ensure name is always a string, never False or None + name = sponsor.name or '' if sponsor.mobile: - name = sponsor.name + " - " + str(sponsor.mobile) + name = (sponsor.name or '') + " - " + str(sponsor.mobile) result.append((sponsor.id, name)) return result diff --git a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py index 24a2357dd..bdb8c552f 100644 --- a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py +++ b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py @@ -1892,6 +1892,7 @@ class TakafulSponsorship(models.Model): 'sponsorship_payment_skip_compute_amount': True, 'default_sponsorship_payment': True, 'force_sponsorship_line_partner_id': self.sponsor_id.id, + 'default_takaful_sponsorship_id': self.id, }, 'target': 'new', 'type': 'ir.actions.act_window', diff --git a/odex25_takaful/odex_takaful/security/ir.model.access.csv b/odex25_takaful/odex_takaful/security/ir.model.access.csv index 35e6632f1..2dfb8cb2e 100644 --- a/odex25_takaful/odex_takaful/security/ir.model.access.csv +++ b/odex25_takaful/odex_takaful/security/ir.model.access.csv @@ -59,3 +59,5 @@ access_replace_benefit_wizard,replace.benefit.wizard.access,model_replace_benefi access_group_esterdad_wizard,access_group_esterdad_wizard,model_esterdad_wizard,,1,1,1,0 access_group_otp_confirmation_wizard,access_group_otp_confirmation_wizard,model_otp_confirmation_wizard,,1,1,1,0 +access_payment_machine,access_payment_machine,model_payment_machine,odex_takaful.group_kufula_user,1,1,1,1 +access_payment_machine_manager,access_payment_machine_manager,model_payment_machine,odex_takaful.sponsorship_system_manager_group,1,1,1,1 diff --git a/odex25_takaful/odex_takaful/views/payment_machine_views.xml b/odex25_takaful/odex_takaful/views/payment_machine_views.xml new file mode 100644 index 000000000..e058b7dde --- /dev/null +++ b/odex25_takaful/odex_takaful/views/payment_machine_views.xml @@ -0,0 +1,108 @@ + + + + + payment.machine.view.tree + payment.machine + + + + + + + + + + + + + + + payment.machine.view.form + payment.machine + +
+ +
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+ + + + payment.machine.view.search + payment.machine + + + + + + + + + + + + + + + + + + + + + + Payment Machines + payment.machine + tree,form + + +

+ Create your first payment machine +

+

+ Payment machines are used to track POS terminals like Gidea, Neoleap, etc. +

+
+
+ + + + +
diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.py b/odex25_takaful/odex_takaful/wizards/account_payment_register.py index 2da45f1ce..338c4844b 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.py +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.py @@ -8,6 +8,24 @@ _logger = logging.getLogger(__name__) class AccountRegisterPayment(models.TransientModel): _inherit = 'account.payment.register' + @api.model + def default_get(self, fields_list): + res = super(AccountRegisterPayment, self).default_get(fields_list) + if 'machine_id' in res and res['machine_id']: + machine = self.env['payment.machine'].browse(res['machine_id']) + if machine.exists() and machine.journal_id: + res['journal_id'] = machine.journal_id.id + elif not res.get('machine_id'): + # Fallback if default_get didn't catch the field default (though it usually does for computed defaults) + # Let's explicitly check our custom default logic if not present + machine_id = self._default_machine_id() + if machine_id: + res['machine_id'] = machine_id + machine = self.env['payment.machine'].browse(machine_id) + if machine.exists() and machine.journal_id: + res['journal_id'] = machine.journal_id.id + return res + @api.model def _default_payment_method_id(self): payment_method = self.env['takaful.payment.method'].sudo().search( @@ -30,7 +48,29 @@ class AccountRegisterPayment(models.TransientModel): transaction_file_attachment = fields.Binary(string='Transaction Attachment', attachment=False) transaction_attachment_file_name = fields.Char('Transaction File Name', required=False) payment_method = fields.Selection(selection=[("cash", "Cash"), ("bank", "Bank Transfer"), ("check", "Check")], string="Payment Method", required=True, default="cash") - machine_id = fields.Many2one('geidea.terminals', string=_('Machine')) + @api.model + def _default_machine_id(self): + sponsorship_id = self.env.context.get('default_takaful_sponsorship_id') or self.env.context.get('active_id') + if sponsorship_id: + sponsorship = self.env['takaful.sponsorship'].browse(sponsorship_id) + if sponsorship.exists() and sponsorship.branch_custom_id: + return self.env['payment.machine'].search([ + ('branch_custom_id', '=', sponsorship.branch_custom_id.id), + ('active', '=', True) + ], limit=1).id + return False + + machine_id = fields.Many2one( + 'payment.machine', + string='Payment Machine', + default=_default_machine_id + ) + sponsorship_branch_id = fields.Many2one( + 'branch.settings', + string='Sponsorship Branch', + related='takaful_sponsorship_id.branch_custom_id', + store=False, + ) check_number = fields.Char(string='Check Number') check_due_date = fields.Date(string='Check Due Date') sponsorship_payment = fields.Boolean(string='Sponsorship Payment', default=False) diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml index 2ae3da164..8e3e5f4bf 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml @@ -76,24 +76,35 @@ - + + + + - + + {'readonly':[('is_refund_sponsorship','=',True)], 'invisible': [('takaful_payment_method', '=', 'network')]} + Association Journal + + + - + - +