[FIX] odex_takaful

This commit is contained in:
Samir Ladoui 2026-01-15 14:54:16 +01:00
parent 1a4102a30c
commit 0094aeb7db
2 changed files with 155 additions and 152 deletions

View File

@ -5,99 +5,98 @@
<!-- Standard report container to provide <main> for PDF engine -->
<t t-call="web.html_container">
<!-- Get all extension history records for the same invoice -->
<t t-set="invoice_id" t-value="docs[0].invoice_id if docs else False"/>
<t t-set="all_extensions" t-value="docs.env['donation.extension.history'].search([('invoice_id', '=', invoice_id.id)]) if invoice_id else docs"/>
<t t-set="sponsorship" t-value="all_extensions[0].sponsorship_id if all_extensions else False"/>
<t t-foreach="docs" t-as="o">
<t t-set="invoice_id" t-value="o.invoice_id"/>
<t t-set="sponsorship" t-value="o.donation_detail_id.sponsorship_mechanism_id"/>
<t t-if="sponsorship">
<!-- Reuse sale order header layout -->
<t t-call="sale_order_report.sale_order_report_header">
<div class="page font-noto" style="position: relative; min-height: 800px; overflow: visible;" dir="rtl">
<t t-if="sponsorship">
<!-- Reuse sale order header layout -->
<t t-call="sale_order_report.sale_order_report_header">
<div class="page font-noto" style="position: relative; min-height: 800px; overflow: visible;" dir="rtl">
<div style="position: relative; z-index: 1;">
<div class="oe_structure"/>
<div style="position: relative; z-index: 1;">
<div class="oe_structure"/>
<!-- Greeting / intro -->
<div style="text-align: right; margin-bottom: 20px; padding-top: 250px;">
<div style="font-size: 1.5rem; color: #6B6B6A; font-weight: bold;">
مرحباً
<span style="color: #387F75;" t-esc="sponsorship.sponsor_name or sponsorship.sponsor_id.name"/>
<!-- Greeting / intro -->
<div style="text-align: right; margin-bottom: 20px; padding-top: 250px;">
<div style="font-size: 1.5rem; color: #6B6B6A; font-weight: bold;">
مرحباً
<span style="color: #387F75;" t-esc="sponsorship.sponsor_name or sponsorship.sponsor_id.name"/>
</div>
<div style="font-size: 1.5rem; margin-top: 10px; color: #6B6B6A;">
بكل امتنان نشكر لك تجديد كفالتك، ونسأل الله أن يجعلك ممن يرافقون النبي <span style="white-space: nowrap;">
<img src="/odex_takaful/static/src/img/U+FDFA.svg"
style="height: 1.5em; vertical-align: middle; margin-bottom: 2px;"
alt="ﷺ"/>
</span><br/> في الجنة.
</div>
<div style="font-size: 1.3rem; color: #6B6B6A;">
ونتشرف دائما باستقبال عطائك المستمر لدعم أبنائكم الأيتام.
</div>
</div>
<div style="font-size: 1.5rem; margin-top: 10px; color: #6B6B6A;">
بكل امتنان نشكر لك تجديد كفالتك، ونسأل الله أن يجعلك ممن يرافقون النبي <span style="white-space: nowrap;">
<img src="/odex_takaful/static/src/img/U+FDFA.svg"
style="height: 1.5em; vertical-align: middle; margin-bottom: 2px;"
alt="ﷺ"/>
</span><br/> في الجنة.
</div>
<div style="font-size: 1.3rem; color: #6B6B6A;">
ونتشرف دائما باستقبال عطائك المستمر لدعم أبنائكم الأيتام.
</div>
</div>
<!-- Extension info -->
<div style="text-align: right; margin-bottom: 20px;">
<div style="font-size: 1.3rem; color: #8F9090;">
<span style="font-weight: bold;">رقم الكفالة: </span>
<t t-esc="sponsorship.code"/>
<!-- Extension info -->
<div style="text-align: right; margin-bottom: 20px;">
<div style="font-size: 1.3rem; color: #8F9090;">
<span style="font-weight: bold;">رقم الكفالة: </span>
<t t-esc="sponsorship.code"/>
</div>
<div style="font-size: 1.4rem; color: #8F9090;">
<span style="font-weight: bold;">تاريخ التجديد: </span>
<bdi style="display: inline; direction: rtl; unicode-bidi: embed; white-space: nowrap;">
<span t-field="o.extension_date"
t-options='{"format": "dd MMMM yyyy - HH:mm"}'/>
</bdi>
</div>
</div>
<div style="font-size: 1.4rem; color: #8F9090;">
<span style="font-weight: bold;">تاريخ التجديد: </span>
<bdi style="display: inline; direction: rtl; unicode-bidi: embed; white-space: nowrap;">
<span t-field="all_extensions[0].extension_date"
t-options='{"format": "dd MMMM yyyy - HH:mm"}'/>
</bdi>
</div>
</div>
<!-- Extension Lines table -->
<table class="table table-bordered" style="text-align: right;">
<thead>
<tr style="background-color: #f8f9fa;">
<th style="text-align: right; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
نوع التبرع
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
التفاصيل
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
الفترة الجديدة
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
المبلغ
</th>
</tr>
</thead>
<tbody>
<t t-foreach="all_extensions" t-as="ext">
<!-- Extension Lines table -->
<table class="table table-bordered" style="text-align: right;">
<thead>
<tr style="background-color: #f8f9fa;">
<th style="text-align: right; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
نوع التبرع
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
التفاصيل
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
الفترة الجديدة
</th>
<th style="text-align: center; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
المبلغ
</th>
</tr>
</thead>
<tbody>
<tr>
<!-- نوع التبرع -->
<td style="text-align: right; padding: 8px; font-size: 1.3rem; color: #387F75;">
<span t-esc="ext.product_template_id.with_context(lang='ar_001').name or ext.product_template_id.name"/>
<span t-esc="o.product_template_id.with_context(lang='ar_001').name or o.product_template_id.name"/>
</td>
<!-- التفاصيل -->
<td style="text-align: center; padding: 8px; font-size: 1.3rem; color: #387F75;">
<t t-if="ext.donation_detail_id.benefit_id">
<span t-esc="(ext.donation_detail_id.benefit_id.name or '').split()[0]"/> - <span t-esc="ext.donation_detail_id.benefit_family_code or '-'"/>
<t t-if="o.donation_detail_id.benefit_id">
<span t-esc="(o.donation_detail_id.benefit_id.name or '').split()[0]"/> - <span t-esc="o.donation_detail_id.benefit_family_code or '-'"/>
</t>
<t t-else="">
<span t-esc="ext.donation_detail_id.family_id.code or '-'"/>
<span t-esc="o.donation_detail_id.family_id.code or '-'"/>
</t>
<br/>
<small style="color: #8F9090;">شهور التمديد: <span t-esc="ext.extension_months"/></small>
<small style="color: #8F9090;">شهور التمديد: <span t-esc="o.extension_months"/></small>
</td>
<!-- الفترة الجديدة -->
<td style="text-align: center; padding: 8px; font-size: 1.2rem; color: #387F75;">
من: <span t-field="ext.old_end_date" t-options='{"format": "dd/MM/yyyy"}'/>
من: <span t-field="o.old_end_date" t-options='{"format": "dd/MM/yyyy"}'/>
<br/>
إلى <span t-field="ext.new_end_date" t-options='{"format": "dd/MM/yyyy"}'/>
إلى <span t-field="o.new_end_date" t-options='{"format": "dd/MM/yyyy"}'/>
</td>
<!-- المبلغ -->
<td style="text-align: center; padding: 8px; font-size: 1.3rem; color: #387F75;">
<t t-set="amt" t-value="ext.extension_amount"/>
<t t-set="amt" t-value="o.extension_amount"/>
<t t-if="amt == int(amt)">
<span t-esc="'{:,.0f}'.format(amt)"/> <small>ر.س</small>
</t>
@ -106,100 +105,100 @@
</t>
</td>
</tr>
</t>
<!-- Summary Row: المجموع -->
<tr style="background-color: #f8f9fa;">
<td style="text-align: right; padding: 8px; font-size: 1.4rem; color: #6B6B6A; font-weight: bold;">
<strong>المجموع:</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>-</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>-</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>
<t t-set="total_amt" t-value="sum(ext.extension_amount for ext in all_extensions)"/>
<t t-if="total_amt == int(total_amt)">
<span t-esc="'{:,.0f}'.format(total_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(total_amt)"/> <small>ر.س</small>
</t>
</strong>
</td>
</tr>
</tbody>
</table>
<!-- Summary Row: المجموع -->
<tr style="background-color: #f8f9fa;">
<td style="text-align: right; padding: 8px; font-size: 1.4rem; color: #6B6B6A; font-weight: bold;">
<strong>المجموع:</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>-</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>-</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<strong>
<t t-set="total_amt" t-value="o.extension_amount"/>
<t t-if="total_amt == int(total_amt)">
<span t-esc="'{:,.0f}'.format(total_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(total_amt)"/> <small>ر.س</small>
</t>
</strong>
</td>
</tr>
</tbody>
</table>
<!-- Payments table: وسيلة الدفع والمبلغ -->
<table class="table table-bordered" style="text-align: right; margin-top: 12px;">
<thead>
<tr style="background-color: #f8f9fa;">
<th style="text-align: right; width: 75%; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
وسيلة الدفع
</th>
<th style="text-align: center; width: 25%; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
المبلغ
</th>
</tr>
</thead>
<tbody>
<t t-if="sponsorship and sponsorship.payment_ids">
<t t-foreach="sponsorship.payment_ids.filtered(lambda p: invoice_id.id in p.reconciled_invoice_ids.ids)" t-as="pay">
<tr>
<td style="text-align: right; padding: 8px; font-size: 1.3rem; color: #387F75;">
<span t-esc="pay.with_context(lang='ar_001').payment_method_line_id.name or pay.with_context(lang='ar_001').payment_method_id.name"/>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.3rem; color: #387F75;">
<t t-set="pay_amt" t-value="0"/>
<t t-foreach="invoice_id.line_ids.filtered(lambda l: l.account_id.internal_type in ('receivable', 'payable'))" t-as="inv_line">
<t t-foreach="inv_line.matched_debit_ids + inv_line.matched_credit_ids" t-as="partial">
<t t-if="partial.credit_move_id.payment_id == pay or partial.debit_move_id.payment_id == pay">
<t t-set="pay_amt" t-value="pay_amt + partial.amount"/>
<!-- Payments table: وسيلة الدفع والمبلغ -->
<table class="table table-bordered" style="text-align: right; margin-top: 12px;">
<thead>
<tr style="background-color: #f8f9fa;">
<th style="text-align: right; width: 75%; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
وسيلة الدفع
</th>
<th style="text-align: center; width: 25%; font-size: 1.4rem; padding: 8px; color: #6B6B6A; font-weight: bold;">
المبلغ
</th>
</tr>
</thead>
<tbody>
<t t-if="sponsorship and sponsorship.payment_ids">
<t t-foreach="sponsorship.payment_ids.filtered(lambda p: invoice_id.id in p.reconciled_invoice_ids.ids)" t-as="pay">
<tr>
<td style="text-align: right; padding: 8px; font-size: 1.3rem; color: #387F75;">
<span t-esc="pay.with_context(lang='ar_001').payment_method_line_id.name or pay.with_context(lang='ar_001').payment_method_id.name"/>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.3rem; color: #387F75;">
<t t-set="pay_amt" t-value="0"/>
<t t-foreach="invoice_id.line_ids.filtered(lambda l: l.account_id.internal_type in ('receivable', 'payable'))" t-as="inv_line">
<t t-foreach="inv_line.matched_debit_ids + inv_line.matched_credit_ids" t-as="partial">
<t t-if="partial.credit_move_id.payment_id == pay or partial.debit_move_id.payment_id == pay">
<t t-set="pay_amt" t-value="pay_amt + partial.amount"/>
</t>
</t>
</t>
<t t-if="pay_amt == int(pay_amt)">
<span t-esc="'{:,.0f}'.format(pay_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(pay_amt)"/> <small>ر.س</small>
</t>
</td>
</tr>
</t>
<t t-if="pay_amt == int(pay_amt)">
<span t-esc="'{:,.0f}'.format(pay_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(pay_amt)"/> <small>ر.س</small>
</t>
<tr style="background-color: #f8f9fa;">
<td style="text-align: right; padding: 8px; font-size: 1.4rem; color: #6B6B6A; font-weight: bold;">
<strong>
<span style="margin-left: 10px;">الإجمالي:</span>
</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<t t-set="final_amt" t-value="o.extension_amount"/>
<t t-if="final_amt == int(final_amt)">
<span t-esc="'{:,.0f}'.format(final_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(final_amt)"/> <small>ر.س</small>
</t>
</td>
</tr>
</t>
<tr style="background-color: #f8f9fa;">
<td style="text-align: right; padding: 8px; font-size: 1.4rem; color: #6B6B6A; font-weight: bold;">
<strong>
<span style="margin-left: 10px;">الإجمالي:</span>
</strong>
</td>
<td style="text-align: center; padding: 8px; font-size: 1.4rem; color: #387F75; font-weight: bold;">
<t t-set="final_amt" t-value="sum(ext.extension_amount for ext in all_extensions)"/>
<t t-if="final_amt == int(final_amt)">
<span t-esc="'{:,.0f}'.format(final_amt)"/> <small>ر.س</small>
</t>
<t t-else="">
<span t-esc="'{:,.2f}'.format(final_amt)"/> <small>ر.س</small>
</t>
</td>
</tr>
</t>
<t t-else="">
<tr>
<td colspan="2" style="text-align: center; padding: 8px; font-size: 1.3rem; color: #6B6B6A;">
<span>لا توجد دفعات</span>
</td>
</tr>
</t>
</tbody>
</table>
<t t-else="">
<tr>
<td colspan="2" style="text-align: center; padding: 8px; font-size: 1.3rem; color: #6B6B6A;">
<span>لا توجد دفعات</span>
</td>
</tr>
</t>
</tbody>
</table>
</div>
</div>
</div>
</t>
</t>
</t>
</t>

View File

@ -158,7 +158,11 @@
<field name="name">Branch Manager: All Branch Donation Lines</field>
<field name="model_id" ref="model_donations_details_lines"/>
<field name="groups" eval="[(4, ref('branch_manager_group'))]"/>
<field name="domain_force">[('branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)]</field>
<field name="domain_force">[
'|',
('sponsorship_id.branch_custom_id.branch', 'child_of', user.employee_id.department_id.id),
('sponsorship_mechanism_id.branch_custom_id.branch', 'child_of', user.employee_id.department_id.id)
]</field>
</record>
<record id="sponsor_department_rule" model="ir.rule">