Merge pull request #6129 from expsa/14.0-fix-odex_takaful-auto-20260111_172022

[IMP] odex_takaful: general improvements
This commit is contained in:
Mohamed Eltayar 2026-01-11 17:20:50 +03:00 committed by GitHub
commit 44a6eaa4fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 0 deletions

View File

@ -141,6 +141,15 @@ class AccountRegisterPayment(models.TransientModel):
sponsorships = self.env['takaful.sponsorship'].browse(self.env.context.get('sponsorship_id')) sponsorships = self.env['takaful.sponsorship'].browse(self.env.context.get('sponsorship_id'))
branch_ids = sponsorships.mapped('branch_custom_id.id') branch_ids = sponsorships.mapped('branch_custom_id.id')
rec.journal_id = rec.takaful_payment_method_id.journal_id.id rec.journal_id = rec.takaful_payment_method_id.journal_id.id
# Set payment_method_line_id based on payment method name
pml = self.env['account.payment.method.line'].search([
('journal_id', '=', rec.journal_id.id),
('name', '=', rec.takaful_payment_method_id.name)
], limit=1)
if pml:
rec.payment_method_line_id = pml.id
payment_method = rec.takaful_payment_method_id.payment_method payment_method = rec.takaful_payment_method_id.payment_method
j_type = "" j_type = ""
if payment_method == "cash": if payment_method == "cash":
@ -150,6 +159,18 @@ class AccountRegisterPayment(models.TransientModel):
if j_type: if j_type:
return {"domain": {"journal_id": [("type", "=", j_type), ("branch_ids", "in", branch_ids)]}} return {"domain": {"journal_id": [("type", "=", j_type), ("branch_ids", "in", branch_ids)]}}
@api.onchange("journal_id")
def onchange_journal_id_set_payment_method_line(self):
"""Set payment_method_line_id based on takaful_payment_method_id name when journal changes."""
for rec in self:
if rec.journal_id and rec.takaful_payment_method_id and self.env.context.get('sponsorship_payment'):
pml = self.env['account.payment.method.line'].search([
('journal_id', '=', rec.journal_id.id),
('name', '=', rec.takaful_payment_method_id.name)
], limit=1)
if pml:
rec.payment_method_line_id = pml.id
@api.depends('source_amount', 'source_amount_currency', 'source_currency_id', 'company_id', 'currency_id', @api.depends('source_amount', 'source_amount_currency', 'source_currency_id', 'company_id', 'currency_id',
'payment_date') 'payment_date')
def _compute_amount(self): def _compute_amount(self):