[IMP] odex_takaful: automatic update

Auto-generated commit based on local changes.
This commit is contained in:
maltayyar2 2026-01-10 03:28:11 +03:00
parent 7c83dcbedf
commit b94dd9e97b
5 changed files with 56 additions and 6 deletions

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@
<field name="show_payment_group" invisible="1"/>
</xpath>
<xpath expr="//field[@name='group_payment']" position="attributes">
<attribute name="attrs">{'invisible':['|', ('show_payment_group','=',False), ('can_group_payments', '=', False)]}</attribute>
<attribute name="invisible">1</attribute>
</xpath>
<!-- <xpath expr="//field[@name='amount']" position="attributes">-->
<!-- <attribute name="attrs">{'readonly':[('group_payment','=',True)]}</attribute>-->

View File

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