diff --git a/odex25_takaful/odex_takaful/models/donation_extension_history.py b/odex25_takaful/odex_takaful/models/donation_extension_history.py index aaa147383..239a7bcf5 100644 --- a/odex25_takaful/odex_takaful/models/donation_extension_history.py +++ b/odex25_takaful/odex_takaful/models/donation_extension_history.py @@ -130,13 +130,24 @@ class DonationExtensionHistory(models.Model): return ['sponsor_phone'] def _compute_receipt_url(self): - """Compute the extension receipt URL for SMS template""" + """Compute short URL for extension receipt using link.tracker (same pattern as Odoo website_slides)""" base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', '') for rec in self: if rec.id: - rec.receipt_url = "%s/sponsorship/pdf/odex_takaful.report_extension_receipt_document/%s" % ( + full_url = "%s/sponsorship/pdf/odex_takaful.report_extension_receipt_document/%s" % ( base_url, rec.id ) + # Use link.tracker if available (same pattern as website_slides) + if self.env.registry.get('link.tracker'): + tracker = self.env['link.tracker'].sudo().search([('url', '=', full_url)], limit=1) + if not tracker: + tracker = self.env['link.tracker'].sudo().create({ + 'url': full_url, + 'title': 'سند التمديد %s' % (rec.extension_ref or rec.id), + }) + rec.receipt_url = tracker.short_url + else: + rec.receipt_url = full_url else: rec.receipt_url = False diff --git a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py index bee15fbf8..57434060a 100644 --- a/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py +++ b/odex25_takaful/odex_takaful/models/takaful_sponorship_model.py @@ -131,7 +131,33 @@ class TakafulSponsorship(models.Model): cancel_record_id = fields.Many2one('esterdad.wizard', string="Cancel Record") record_url = fields.Char(string="Record URL", readonly=True) is_canceled_refund = fields.Boolean() + short_receipt_url = fields.Char( + string="Short Receipt URL", + compute='_compute_short_receipt_url', + store=False + ) + def _compute_short_receipt_url(self): + """Compute short URL for receipt using link.tracker (same pattern as Odoo website_slides)""" + base_url = self.env['ir.config_parameter'].sudo().get_param('web.base.url', '') + for rec in self: + if rec.id: + full_url = "%s/sponsorship/pdf/odex_takaful.report_sponsorship_receipt_document/%s" % ( + base_url, rec.id + ) + # Use link.tracker if available (same pattern as website_slides) + if self.env.registry.get('link.tracker'): + tracker = self.env['link.tracker'].sudo().search([('url', '=', full_url)], limit=1) + if not tracker: + tracker = self.env['link.tracker'].sudo().create({ + 'url': full_url, + 'title': 'سند الكفالة %s' % (rec.code or rec.id), + }) + rec.short_receipt_url = tracker.short_url + else: + rec.short_receipt_url = full_url + else: + rec.short_receipt_url = False def _sms_get_number_fields(self): return ['sponsor_phone'] @@ -1391,6 +1417,7 @@ class TakafulSponsorship(models.Model): 'benefit_ids': [(6, 0, [bf.id])], 'benefit_id': bf.id, 'record_type': line.record_type, + 'donation_type': line.donation_type, 'sponsorship_duration': line.sponsorship_duration, 'product_template_id': line.product_template_id.id, 'direct_debit': line.direct_debit, diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.py b/odex25_takaful/odex_takaful/wizards/account_payment_register.py index 7736c5435..2132726a8 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.py +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.py @@ -104,6 +104,17 @@ class AccountRegisterPayment(models.TransientModel): for rec in self: rec.show_payment_group = (len(unique_partners) == 1) + @api.depends('can_edit_wizard') + def _compute_group_payment(self): + """Override to always group payments for sponsorship - simpler UX""" + for wizard in self: + # Always group payments when in sponsorship context + if self.env.context.get('sponsorship_payment'): + wizard.group_payment = True + else: + # Fall back to default Odoo behavior + super(AccountPaymentRegister, wizard)._compute_group_payment() + @api.depends_context('wiz_id') def _compute_show_cancel_button(self): for rec in self: diff --git a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml index 822e84e47..bb50d519b 100644 --- a/odex25_takaful/odex_takaful/wizards/account_payment_register.xml +++ b/odex25_takaful/odex_takaful/wizards/account_payment_register.xml @@ -45,7 +45,7 @@ - {'invisible':['|', ('show_payment_group','=',False), ('can_group_payments', '=', False)]} + 1 diff --git a/odex25_takaful/odex_takaful/wizards/donation_extension_wizard.py b/odex25_takaful/odex_takaful/wizards/donation_extension_wizard.py index 4be0ad834..05a9c3cf6 100644 --- a/odex25_takaful/odex_takaful/wizards/donation_extension_wizard.py +++ b/odex25_takaful/odex_takaful/wizards/donation_extension_wizard.py @@ -69,12 +69,13 @@ class DonationExtensionWizard(models.TransientModel): extension_line_ids = [(5,)] donation_detail_ids = self.env['donations.details.lines'].browse(self.env.context.get('donation_detail_ids')) for line in donation_detail_ids: + line_ref = line.sequence_no or str(line.id) if not (line.record_type == 'donation' and line.direct_debit) and line.record_type != 'sponsorship': - raise ValidationError(_("Only donation with direct debit or sponsorship can be extended. Line: %s") % line.name) + raise ValidationError(_("Only donation with direct debit or sponsorship can be extended. Line: {}").format(line_ref)) if line.end_date and line.end_date < fields.Date.context_today(line): - raise ValidationError(_("Only active donations with end date in the future can be extended. Line: %s") % line.name) + raise ValidationError(_("Only active donations with end date in the future can be extended. Line: {}").format(line_ref)) if line.state != 'active': - raise ValidationError(_("Only active donations can be extended. Line: %s") % line.name) + raise ValidationError(_("Only active donations can be extended. Line: {}").format(line_ref)) extension_line_ids.append((0, 0, { 'donation_line_id': line.id, 'current_end_date': line.end_date,