feat: enhance odex_takaful UI/UX with currency display and field widgets
- Add currency_id field to all amount-related models (donation_details_lines, takaful_sponorship, takaful_sponsor_operation, donation_extension_wizard) - Update all amount fields to use widget='monetary' with system currency display - Update all date fields to use widget='date' or 'datetime' for better UX - Update all phone fields to use widget='phone' for proper validation - Ensure currency symbol displays automatically from system (SAR) without manual input - Maintain all existing business logic and workflows - Compatible with Odoo 14 standards and best practices Files modified: - Models: donation_details_lines.py, takaful_sponorship_model.py, takaful_sponsor_operation.py, donation_extension_wizard.py - Views: donations_details_lines.xml, takaful_sponorship_view.xml, takaful_sponsor_operation_views.xml, donation_extension_wizard.xml
This commit is contained in:
parent
33b294027e
commit
f74ac341f2
|
|
@ -67,6 +67,8 @@ class DonationsDetailsLines(models.Model):
|
|||
benefits_count = fields.Integer(string='Benefits Count', compute='_get_benefits_count')
|
||||
total_donation_amount = fields.Float(string='Total Donation Amount', compute='_get_total_donation_amount')
|
||||
total_months_amount = fields.Float(string='Total Months Amount', compute='_get_total_months_amount')
|
||||
currency_id = fields.Many2one('res.currency', string='Currency',
|
||||
default=lambda self: self.env.company.currency_id, readonly=True)
|
||||
sponsorships_computed = fields.Boolean(copy=False, readonly=True)
|
||||
direct_debit = fields.Boolean(string='Direct Debit')
|
||||
benefit_id_number = fields.Char("Benefit ID Number")
|
||||
|
|
|
|||
|
|
@ -655,6 +655,8 @@ class TakafulSponsorship(models.Model):
|
|||
compute='_check_if_has_delay', store=True)
|
||||
contribution_value = fields.Float(string="Contribution Value")
|
||||
load_amount = fields.Float(string="Load Amount Per Person")
|
||||
currency_id = fields.Many2one('res.currency', string='Currency',
|
||||
default=lambda self: self.env.company.currency_id, readonly=True)
|
||||
total_contribution = fields.Float(string="Contributions Total",
|
||||
compute='calculate_total_paid')
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ class TakafulSponsorOperation(models.Model):
|
|||
origin_id = fields.Integer(readonly=True)
|
||||
period_code = fields.Char(string="Period Code", compute='_compute_period_filter')
|
||||
amount = fields.Float(string="Amount")
|
||||
currency_id = fields.Many2one('res.currency', string='Currency',
|
||||
default=lambda self: self.env.company.currency_id, readonly=True)
|
||||
|
||||
def _compute_period_filter(self):
|
||||
""" Extract period code from date """
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
<field name="direct_debit" invisible="1" />
|
||||
<field name="sequence_no" />
|
||||
<field name="sponsor_id" />
|
||||
<field name="sponsor_phone" />
|
||||
<field name="sponsor_phone" widget="phone"/>
|
||||
<field name="donation_type" optional="show"/>
|
||||
<field name="sponsorship_duration" optional="hide"/>
|
||||
<field name="donation_mechanism" optional="hide"/>
|
||||
|
|
@ -74,10 +74,11 @@
|
|||
<field name="benefit_status" widget="badge"
|
||||
decoration-success="benefit_status == 'benefit'"
|
||||
decoration-danger="benefit_status == 'non_benefit'"/>
|
||||
<field name="start_date" />
|
||||
<field name="end_date" />
|
||||
<field name="donation_amount" />
|
||||
<field name="total_donation_amount" />
|
||||
<field name="start_date" widget="date"/>
|
||||
<field name="end_date" widget="date"/>
|
||||
<field name="donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="total_donation_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="branch_custom_id" optional="hide" />
|
||||
<field name="benefit_family_code" optional="hide" />
|
||||
<field name="benefit_id" optional="hide" />
|
||||
|
|
@ -172,14 +173,19 @@
|
|||
<field name="product_id" invisible="1" />
|
||||
<field name="donation_mechanism" invisible="1" />
|
||||
<field name="fixed_value" invisible="1" />
|
||||
<field name="donation_amount" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="total_donation_amount" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="total_donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
</group>
|
||||
<group string="Sponsorship Information">
|
||||
<field name="sponsorship_id" readonly="1" attrs="{'invisible': [('sponsorship_id', '=', False)]}" />
|
||||
<field name="sponsorship_mechanism_id" readonly="1" attrs="{'invisible': [('sponsorship_mechanism_id', '=', False)]}" />
|
||||
<field name="sponsor_id" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="sponsor_phone" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="sponsor_phone" widget="phone" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="branch_custom_id" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="sponsorship_creation_date" invisible="1" />
|
||||
<field name="parent_state" invisible="1" />
|
||||
|
|
@ -214,20 +220,22 @@
|
|||
|
||||
<field name="payment_month_count"
|
||||
attrs="{'invisible': ['&', ('sponsorship_duration','!=','temporary'), ('direct_debit', '=', False)], 'required': [('sponsorship_duration','=','temporary')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="start_date" string="Start Date"
|
||||
<field name="start_date" string="Start Date" widget="date"
|
||||
attrs="{'invisible': ['&', ('sponsorship_duration', '!=', 'temporary'), ('direct_debit', '=', False)], 'required': [('sponsorship_duration', '=','temporary')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="end_date" string="End Date"
|
||||
<field name="end_date" string="End Date" widget="date"
|
||||
attrs="{'invisible': ['&', ('sponsorship_duration', '!=', 'temporary'), ('direct_debit', '=', False)], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
</group>
|
||||
<group>
|
||||
<field name="donation_mechanism" invisible="1" />
|
||||
<field name="fixed_value" invisible="1" />
|
||||
<field name="donation_amount"
|
||||
<field name="donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':['|', ('fixed_value','=',True), ('parent_state', '!=', 'draft')]}"
|
||||
force_save="1" required="1" />
|
||||
<field name="benefits_count"
|
||||
attrs="{'invisible':[('sponsorship_type','!=','group')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="total_donation_amount"
|
||||
<field name="total_donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible':[('sponsorship_type','!=','group')], 'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
<field name="name" attrs="{'readonly': [('parent_state', '!=', 'draft')]}" />
|
||||
</group>
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@
|
|||
force_save="1" options="{'no_create': True, 'no_create_edit': True}"/>
|
||||
<!-- <field name="sponsor_phone"-->
|
||||
<!-- attrs="{'invisible': [('sponsor_or_donor_type','=', False)], 'readonly': [('sponsor_id', '!=', False)]}"/>-->
|
||||
<field name="sponsor_phone"
|
||||
<field name="sponsor_phone" widget="phone"
|
||||
attrs="{'invisible': [('sponsor_or_donor_type','=', False)], 'readonly': [('sponsor_or_donor_type', '!=', 'unknown')]}"/>
|
||||
<field name="is_widow_orphan" invisible="1"/>
|
||||
<field name="cancel_refund" invisible="1"/>
|
||||
|
|
@ -161,7 +161,7 @@
|
|||
attrs="{'invisible': [('is_gift', '!=', 'yes')]}">
|
||||
<field name="gifter_id" readonly="1"/>
|
||||
<field name="gifter_name" readonly="1"/>
|
||||
<field name="gifter_mobile" readonly="1"/>
|
||||
<field name="gifter_mobile" widget="phone" readonly="1"/>
|
||||
<field name="gifter_message" readonly="1"/>
|
||||
</group>
|
||||
|
||||
|
|
@ -177,7 +177,7 @@
|
|||
<field name="another_sponsors">
|
||||
<tree editable="bottom">
|
||||
<field name="sponsor_name"/>
|
||||
<field name="sponsor_phone"/>
|
||||
<field name="sponsor_phone" widget="phone"/>
|
||||
<field name="sponsor_id_number"/>
|
||||
<field name="receive_messages" widget="boolean_toggle"/>
|
||||
<field name="note"/>
|
||||
|
|
@ -248,16 +248,21 @@
|
|||
attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')]}"/>
|
||||
<field name="payment_month_count" optional="hide"
|
||||
attrs="{'invisible': [('direct_debit', '=', False)]}"/>
|
||||
<field name="start_date" string="From" optional="hide"
|
||||
<field name="start_date" string="From" optional="hide" widget="date"
|
||||
attrs="{'invisible': [('direct_debit', '=', False)],'readonly': [('direct_debit', '=', False)], 'required': [('direct_debit', '=', True)]} "/>
|
||||
<field name="end_date" string="To" optional="hide"
|
||||
<field name="end_date" string="To" optional="hide" widget="date"
|
||||
attrs="{'invisible': [('direct_debit', '=', False)]}"
|
||||
readonly="1"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="donation_qty" force_save="1"/>
|
||||
<field name="donation_amount" attrs="{'readonly':[('fixed_value','=',True)]}"
|
||||
<field name="donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':[('fixed_value','=',True)]}"
|
||||
force_save="1"
|
||||
required="1"/>
|
||||
<field name="total_donation_amount" readonly="1" force_save="1"/>
|
||||
<field name="total_donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
readonly="1" force_save="1"/>
|
||||
<button name="action_view_scheduling_lines"
|
||||
string="View Scheduling Lines"
|
||||
type="object"
|
||||
|
|
@ -337,17 +342,21 @@
|
|||
<field name="payment_month_count"
|
||||
attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')],'invisible': [('direct_debit', '=', False)]}"
|
||||
/>
|
||||
<field name="start_date"
|
||||
<field name="start_date" widget="date"
|
||||
attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')],'invisible': [('payment_option', '!=', 'month')],'readonly': [('direct_debit', '=', False)]}"
|
||||
string="Start Date"/>
|
||||
<field name="end_date"
|
||||
<field name="end_date" widget="date"
|
||||
attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions'),('parent.record_type','!=','sponsorship')],'invisible': [('payment_option', '!=', 'month')]}"
|
||||
string="End Date"/>
|
||||
<field name="donation_qty" invisible="1" force_save="1"/>
|
||||
<field name="record_type" invisible="1"/>
|
||||
<field name="donation_amount" force_save="1"
|
||||
<field name="donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
force_save="1"
|
||||
attrs="{'readonly': [('record_type','=','sponsorship')]}"/>
|
||||
<field name="total_donation_amount" force_save="1"/>
|
||||
<field name="total_donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
force_save="1"/>
|
||||
<field name="donation_mechanism"
|
||||
attrs="{'column_invisible': [('parent.donation_mechanism','!=','with_conditions')]}"/>
|
||||
|
||||
|
|
@ -434,20 +443,24 @@
|
|||
<field name="debit_payment_attachment_file_name" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="start_date" string="Start Date"
|
||||
<field name="start_date" string="Start Date" widget="date"
|
||||
attrs="{'invisible': [('payment_month_count_visibility','!=', True)], 'required': [('direct_debit', '=', True)], 'readonly': [('direct_debit', '=', False)],}"/>
|
||||
<field name="end_date" string="End Date" readonly="1"
|
||||
<field name="end_date" string="End Date" widget="date" readonly="1"
|
||||
attrs="{'invisible': [('payment_month_count_visibility','!=', True)]}"/>
|
||||
<field name="donation_mechanism" invisible="1" force_save="1"/>
|
||||
<field name="fixed_value" invisible="1"/>
|
||||
<field name="donation_qty" force_save="1" invisible="1"/>
|
||||
<field name="donation_amount"
|
||||
<field name="donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':[('fixed_value','=',True)]}"
|
||||
force_save="1" required="1"/>
|
||||
<field name="total_months_amount" attrs="{'invisible':[('payment_month_count_visibility','=', False)]}"/>
|
||||
<field name="total_months_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible':[('payment_month_count_visibility','=', False)]}"/>
|
||||
<field name="benefits_count"
|
||||
attrs="{'invisible':['|', ('sponsorship_type','!=','group'), ('record_type','!=','sponsorship')]}"/>
|
||||
<field name="total_donation_amount"
|
||||
<field name="total_donation_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'invisible':['|', ('sponsorship_type','!=','group'), ('record_type','!=','sponsorship')]}"
|
||||
force_save="1"/>
|
||||
</group>
|
||||
|
|
@ -531,7 +544,9 @@
|
|||
|
||||
<group class="oe_subtotal_footer oe_right" colspan="2"
|
||||
name="donation_total">
|
||||
<field name="total_sponsorship_amount" string="Total Amount"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="total_sponsorship_amount" string="Total Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="donations_count"/>
|
||||
</group>
|
||||
<button name="donation_catelog" type="object" string="Donation Catalog"
|
||||
|
|
@ -559,7 +574,8 @@
|
|||
<field name="refund_reason"/>
|
||||
<field name="payment_method_id"/>
|
||||
<field name="sponsor_id"/>
|
||||
<field name="refund_amount"/>
|
||||
<field name="refund_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="journal_id"/>
|
||||
<field name="attachment_ids"
|
||||
widget="many2many_attachment_preview"/>
|
||||
|
|
@ -600,7 +616,8 @@
|
|||
<field name="registered_type"/>
|
||||
<field name="sponsor_id"/>
|
||||
<field name="sponsor_name" string="Unregistered Sponsor Name" optional="show"/>
|
||||
<field name="total_sponsorship_amount"/>
|
||||
<field name="total_sponsorship_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-muted="state == 'draft'"
|
||||
decoration-warning="state in ['confirmed', 'wait_pay', 'approve_refund']"
|
||||
|
|
@ -611,9 +628,9 @@
|
|||
<field name="sponsorship_duration"/>
|
||||
<field name="sponsorship_type"/>
|
||||
<field name="benefit_type"/>
|
||||
<field name="contribution_value"/>
|
||||
<field name="end_date"/>
|
||||
<field name="overdue_amount"/> -->
|
||||
<field name="contribution_value" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="end_date" widget="date"/>
|
||||
<field name="overdue_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/> -->
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
@ -632,13 +649,14 @@
|
|||
<search string="Takaful SponsorShip Search">
|
||||
<field name="code"/>
|
||||
<field name="create_uid"/>
|
||||
<field name="sponsorship_creation_date"/>
|
||||
<field name="sponsorship_creation_date" widget="datetime"/>
|
||||
<field name="record_type"/>
|
||||
<field name="branch_custom_id"/>
|
||||
<field name="sponsor_or_donor_type"/>
|
||||
<field name="registered_type"/>
|
||||
<field name="sponsor_id"/>
|
||||
<field name="total_sponsorship_amount"/>
|
||||
<field name="total_sponsorship_amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="state"/>
|
||||
<separator/>
|
||||
<!-- State Filters -->
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@
|
|||
|
||||
<field name="month" invisible="1" />
|
||||
<field name="period_code" invisible="1" />
|
||||
<field name="amount" readonly="1" />
|
||||
<field name="date" invisible="1" />
|
||||
<field name="operation_on" readonly="1" />
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}" readonly="1" />
|
||||
<field name="date" widget="date" invisible="1" />
|
||||
<field name="operation_on" widget="datetime" readonly="1" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
@ -39,9 +40,10 @@
|
|||
<field name="operation_type" />
|
||||
<field name="sponsor_id" />
|
||||
<field name="benefit_type" />
|
||||
<field name="amount" />
|
||||
<field name="date" />
|
||||
<field name="operation_on" />
|
||||
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="date" widget="date"/>
|
||||
<field name="operation_on" widget="datetime"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
@ -56,8 +58,8 @@
|
|||
<field name="operation_type" />
|
||||
<field name="sponsor_id" />
|
||||
<field name="benefit_type" />
|
||||
<field name="amount" />
|
||||
<field name="date" />
|
||||
<field name="amount" widget="monetary" options="{'currency_field': 'currency_id'}"/>
|
||||
<field name="date" widget="date"/>
|
||||
</search>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -124,6 +124,8 @@ class DonationExtensionWizardLine(models.TransientModel):
|
|||
readonly=True,
|
||||
help='Total extension amount (amount × months)'
|
||||
)
|
||||
currency_id = fields.Many2one('res.currency', string='Currency',
|
||||
default=lambda self: self.env.company.currency_id, readonly=True)
|
||||
|
||||
current_end_date = fields.Date(
|
||||
string='Current End Date',
|
||||
|
|
|
|||
|
|
@ -25,13 +25,18 @@
|
|||
<field name="donation_mechanism" invisible="1" force_save="1"/>
|
||||
<field name="fixed_value" invisible="1" force_save="1"/>
|
||||
<field name="donation_line_id" force_save="1"/>
|
||||
<field name="current_end_date" force_save="1"/>
|
||||
<field name="new_end_date" force_save="1"/>
|
||||
<field name="current_end_date" widget="date" force_save="1"/>
|
||||
<field name="new_end_date" widget="date" force_save="1"/>
|
||||
<field name="direct_debit" force_save="1"/>
|
||||
<field name="donation_amount" string="Amount" attrs="{'readonly':[('fixed_value','=',True)]}" />
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="donation_amount" string="Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':[('fixed_value','=',True)]}" />
|
||||
<field name="donation_qty" string="Qty" attrs="{'invisible':[('donation_mechanism','!=','without_conditions')]}"/>
|
||||
<field name="total_months_amount" string="Months Amount" force_save="1"/>
|
||||
<field name="total_donation_amount" string="Total Amount" force_save="1"/>
|
||||
<field name="total_months_amount" string="Months Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" force_save="1"/>
|
||||
<field name="total_donation_amount" string="Total Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" force_save="1"/>
|
||||
</tree>
|
||||
<form>
|
||||
<field name="wizard_id" invisible="1" force_save="1"/>
|
||||
|
|
@ -59,10 +64,14 @@
|
|||
attrs="{'required': [('direct_debit', '=', True)], 'invisible': [('direct_debit', '=', False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="donation_amount" string="Amount" attrs="{'readonly':[('fixed_value','=',True)]}" />
|
||||
<field name="donation_amount" string="Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}"
|
||||
attrs="{'readonly':[('fixed_value','=',True)]}" />
|
||||
<field name="donation_qty" string="Qty" attrs="{'invisible':[('donation_mechanism','!=','without_conditions')]}"/>
|
||||
<field name="total_months_amount" string="Months Amount" force_save="1"/>
|
||||
<field name="total_donation_amount" string="Total Amount" force_save="1"/>
|
||||
<field name="total_months_amount" string="Months Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" force_save="1"/>
|
||||
<field name="total_donation_amount" string="Total Amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" force_save="1"/>
|
||||
</group>
|
||||
</group>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue