Merge pull request #5365 from expsa/fix/sponsor-form-issues-20251112-024500
fix: Sponsor Form Critical Fixes - Footer Buttons + Required Name + Constraint - 20251112
This commit is contained in:
commit
a5da2b3b46
|
|
@ -801,6 +801,22 @@ class TakafulSponsorship(models.Model):
|
|||
rec.sponsor_phone = rec.sponsor_id.mobile
|
||||
rec.preferred_communication = rec.sponsor_id.preferred_communication
|
||||
|
||||
@api.constrains('sponsor_id', 'sponsor_or_donor_type', 'sponsor_donor_type', 'state')
|
||||
def _check_new_sponsor_created(self):
|
||||
"""
|
||||
Constraint: If user selects 'new_sponsor', they must create a sponsor before saving
|
||||
"""
|
||||
for rec in self:
|
||||
if rec.state == 'draft': # Only check in draft state
|
||||
# Check for donation
|
||||
if rec.record_type == 'donation' and rec.sponsor_or_donor_type == 'new_sponsor':
|
||||
if not rec.sponsor_id:
|
||||
raise ValidationError(_('يجب إنشاء مشترك جديد أولاً قبل الحفظ. اضغط على زر "إنشاء مشترك" لإضافة مشترك جديد.'))
|
||||
# Check for sponsorship
|
||||
elif rec.record_type == 'sponsorship' and rec.sponsor_donor_type == 'new_sponsor':
|
||||
if not rec.sponsor_id:
|
||||
raise ValidationError(_('يجب إنشاء كافل جديد أولاً قبل الحفظ. اضغط على زر "إنشاء مشترك" لإضافة كافل جديد.'))
|
||||
|
||||
def _get_default_record_type(self):
|
||||
if self.env.user.has_group("odex_takaful.donation_officer_group"):
|
||||
return "donation"
|
||||
|
|
|
|||
|
|
@ -29,11 +29,8 @@
|
|||
<field name="name">partner.sponsor.form</field>
|
||||
<field name="model">res.partner</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="The sponsor">
|
||||
<form string="The sponsor" create="false">
|
||||
<header>
|
||||
<button name="action_save_and_close" string="حفظ وإغلاق" type="object"
|
||||
class="btn-primary" attrs="{'invisible': [('id', '!=', False)]}"
|
||||
context="{'save_and_close': True}"/>
|
||||
<button name="action_unlink_sponsor_and_related" string="Unlink Partners" type="object"
|
||||
groups="base.group_no_one" invisible="1"/>
|
||||
</header>
|
||||
|
|
@ -86,7 +83,7 @@
|
|||
<field placeholder="اللقب" name="title" class="oe_inline" nolabel="1" style="width: 20%;"
|
||||
domain="[('position', 'in', ['prefix','both'])]"
|
||||
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
|
||||
<field placeholder="الاسم" name="first_name" class="oe_inline" nolabel="1" style="width: 60%;"/>
|
||||
<field placeholder="الاسم" name="first_name" class="oe_inline" nolabel="1" style="width: 60%;" required="1"/>
|
||||
<field placeholder="العبارة الختامية" name="suffix_title_id" class="oe_inline" nolabel="1" style="width: 20%;"
|
||||
domain="[('position', 'in', ['suffix','both'])]"
|
||||
options="{'no_create': True, 'no_create_edit':True, 'no_open': True}"/>
|
||||
|
|
@ -188,6 +185,10 @@
|
|||
|
||||
</notebook>
|
||||
</sheet>
|
||||
<footer>
|
||||
<button name="action_save_and_close" string="حفظ وإغلاق" type="object" class="btn-primary"/>
|
||||
<button string="تجاهل" class="btn-secondary" special="cancel"/>
|
||||
</footer>
|
||||
<div class="oe_chatter">
|
||||
<field name="message_follower_ids" widget="mail_followers"/>
|
||||
<field name="message_ids" widget="mail_thread"/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue