IMP benefit

This commit is contained in:
younes 2025-09-25 16:18:27 +01:00
parent 222ea2260c
commit cea5aa1d05
7 changed files with 70 additions and 53 deletions

View File

@ -2115,6 +2115,7 @@ msgstr "عائلات المستفيدين"
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__replacement_mother_status__benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__visit_location__benefit_type__benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__benefit_type__benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_search
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_tree
#, python-format
@ -6753,11 +6754,6 @@ msgstr "متاح "
msgid "Is Benefit?"
msgstr "هل هو مستفيد؟"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_category__is_benefit
msgid "Is Benefit"
msgstr "الاسرة مستفيدة؟"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_craft_skills__is_capital
#: model:ir.model.fields,field_description:odex_benefit.field_training_inclinations__is_capital
@ -8426,6 +8422,7 @@ msgstr "نهاية الوقت المعين للنشاط"
#: model:ir.model.fields,field_description:odex_benefit.field_housing_rooms_type__name
#: model:ir.model.fields,field_description:odex_benefit.field_insurance_company__name
#: model:ir.model.fields,field_description:odex_benefit.field_insurance_type__name
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__benefit_partner_name
#: model:ir.model.fields,field_description:odex_benefit.field_item_status__name
#: model:ir.model.fields,field_description:odex_benefit.field_job_settings__name
#: model:ir.model.fields,field_description:odex_benefit.field_main_service__name
@ -10792,6 +10789,7 @@ msgstr "نوع الرياضة"
#: model:ir.model.fields,field_description:odex_benefit.field_res_country_city__state_id
#: model:ir.model.fields,field_description:odex_benefit.field_visit_location__state
#: model:ir.model.fields,field_description:odex_benefit.field_seasonal_service__state
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_search
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_search
msgid "State"
msgstr "الحالة"
@ -15274,6 +15272,8 @@ msgstr "شهادة الوفاة"
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_family_member__salary_certificate
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__mother_salary_certificate
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__replacement_mother_salary_certificate
msgid "Salary Certificate"
msgstr "شهادة الراتب"
@ -15619,4 +15619,17 @@ msgstr "<span class=\"o_stat_text\">المصروف الشهري</span>"
#: code:addons/odex_benefit/models/benefit.py:0
#, python-format
msgid "The procedure cannot be continued; the family is not a beneficiary."
msgstr "لا يمكن متابعة الإجراء، الأسرة غير مستفيدة."
msgstr "لا يمكن متابعة الإجراء، الأسرة غير مستفيدة."
#. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_category__is_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_category_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.view_benefit_category_tree
msgid "Is Benefit"
msgstr "الاسرة مستفيدة؟"
#. module: odex_benefit
#: model_terms:ir.ui.view,arch_db:odex_benefit.family_member_form
#: model_terms:ir.ui.view,arch_db:odex_benefit.grant_benefit_form
msgid "Exception First Approve"
msgstr ""

View File

@ -9,6 +9,7 @@ import qrcode
import base64
from io import BytesIO
import re
from odoo.osv import expression
SAUDI_MOBILE_PATTERN = "(^(05|5)(5|0|3|6|4|9|1|8|7)([0-9]{7})$)"
ALPHABETIC_PATTERN = "^[\u0600-\u065F\u066A-\u06EF\u06FA-\u06FFA-Za-z ]+$"
@ -29,28 +30,27 @@ class GrantBenefitProfile(models.Model):
result = []
for rec in self:
if rec.name and rec.code:
branch = " "
if rec.branch_custom_id:
branch = rec.branch_custom_id.name
else:
" "
name = rec.name + " " + rec.code + " " + branch
result.append((rec.id, name))
display_name = f"{rec.code} - {rec.name}"
result.append((rec.id, display_name))
else:
result.append((rec.id, rec.name or rec.code or ""))
return result
@api.model
def name_search(self, name, args=None, operator='ilike', limit=100):
if not args:
args = []
def _name_search(self, name, args=None, operator='ilike', limit=100, name_get_uid=None):
args = args or []
name = name.strip() if name else ""
# Extend the domain filter with custom search conditions
domain = ['|', '|', '|', ('name', operator, name), ('phone', operator, name),
('code', operator, name), ('father_id_number', operator, name)]
# Combine domain filter with any existing args (domain filter in Many2one)
partners = self.search(domain + args, limit=limit)
return partners.name_get()
if operator == "ilike" and not name:
domain = []
else:
domain = ["|", "|", "|",
("name", operator, name),
("code", operator, name),
("sms_phone", operator, name),
("father_id_number", operator, name),
]
return self._search(expression.AND([domain, args]), limit=limit, access_rights_uid=name_get_uid)
profile_step_count = fields.Integer()
complete_registration_step = fields.Char(string="Complete Registration Step")
@ -147,7 +147,7 @@ class GrantBenefitProfile(models.Model):
# Father's case and his data # Birth Date # Address # dead data
# Father's case and his data
# family_name = fields.Char(string="Family Name", tracking=True)
# name = fields.Char(string="Name", compute='get_partner_name', store=True,readonly = False)
benefit_partner_name = fields.Char(string="Name",related='partner_id.name',store=True)
# father_name = fields.Char(string="Father First Name", tracking=True)
# father_second_name = fields.Char(string="Father Second Name", tracking=True)
# father_third_name = fields.Char(string="Father Third Name", tracking=True)
@ -1146,7 +1146,7 @@ class GrantBenefitProfile(models.Model):
max_income_for_mother = validation_setting.max_income_for_mother
for rec in self:
if rec.mother_location_conf and rec.mother_marital_conf:
if not rec.mother_location_conf.is_benefit or not rec.mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
if not rec.mother_location_conf.is_benefit or not rec.mother_marital_conf.is_benefit or rec.state in ['suspended_second_approve','refused']:
return 'non_benefit'
elif rec.mother_marital_conf.is_benefit :
if rec.is_mother_work and rec.mother_country_id.code == 'SA' or (
@ -1169,7 +1169,7 @@ class GrantBenefitProfile(models.Model):
rec.replacement_mother_status = False
if not rec.add_replacement_mother:
continue
if not rec.replacement_mother_location_conf.is_benefit or not rec.replacement_mother_marital_conf.is_benefit or rec.state == 'suspended_second_approve':
if not rec.replacement_mother_location_conf.is_benefit or not rec.replacement_mother_marital_conf.is_benefit or rec.state in ['suspended_second_approve','refused']:
return 'non_benefit'
elif rec.replacement_mother_marital_conf.is_benefit:
if rec.replacement_is_mother_work and rec.replacement_mother_country_id.code == 'SA' or (
@ -1541,6 +1541,7 @@ class GrantBenefitProfile(models.Model):
def action_suspend_second_accept(self):
for rec in self:
rec.state = 'suspended_second_approve'
rec.action_type = 'suspended'
def action_auto_suspend(self):
# Fetch grants in second approval state that are not excluded from suspension
@ -1615,6 +1616,7 @@ class GrantBenefitProfile(models.Model):
if rec.exception_end_date and rec.exception_end_date <= fields.Datetime.now():
rec.is_excluded_suspension = False
rec.state = 'suspended_second_approve'
rec.action_type = 'suspended'
for member in rec.member_ids:
member.is_excluded_suspension = False

View File

@ -499,7 +499,7 @@ class FamilyMemberProfile(models.Model):
rec.member_status = rec.benefit_id.check_mother_status()
elif rec.relationn.relation_type == 'replacement_mother':
rec.member_status = rec.benefit_id.check_replacement_mother_status()
if rec.state == 'suspended_second_approve' or not benefiting_children:
if rec.state in ['suspended_second_approve','refused'] or not benefiting_children:
rec.member_status = 'non_benefit'
# continue # Skip further checks for mothers
# Gender-specific checks
@ -525,7 +525,7 @@ class FamilyMemberProfile(models.Model):
rec.member_status = 'non_benefit'
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
if rec.state == 'suspended_second_approve' or rec.is_dead == True:
if rec.state in ['suspended_second_approve','refused'] or rec.is_dead == True:
rec.member_status = 'non_benefit'
elif rec.relationn.relation_type == 'daughter':
if rec.age < female_benefit_age and rec.is_married:
@ -555,7 +555,7 @@ class FamilyMemberProfile(models.Model):
rec.member_status = 'non_benefit'
if not rec.member_location_conf.is_benefit:
rec.member_status = 'non_benefit'
if rec.state == 'suspended_second_approve' or rec.is_dead == True:
if rec.state in ['suspended_second_approve','refused'] or rec.is_dead == True:
rec.member_status = 'non_benefit'
# General checks for all members
# if rec.is_work:

View File

@ -41,7 +41,7 @@
<!-- <p>Year</p>-->
<!-- </group>-->
<group>
<field name="is_benefit" widget="boolean_toggle"/>
<field name="is_benefit" string="Is Benefit" widget="boolean_toggle"/>
</group>
<group>
<field name="expenses_ids">
@ -64,7 +64,7 @@
<field name="name"/>
<field name="mini_income_amount"/>
<field name="max_income_amount"/>
<field name="is_benefit" widget="boolean_toggle"/>
<field name="is_benefit" string="Is Benefit" widget="boolean_toggle"/>
</tree>
</field>
</record>

View File

@ -292,6 +292,7 @@
<group>
<field name="profile_step_count" invisible="1"/>
<field name="family_edit" invisible="1"/>
<field name="benefit_partner_name" invisible="1"/>
</group>
</group>
</div>
@ -523,14 +524,14 @@
readonly="1"/>
<field name="is_mother_work"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('is_mother_work','=',False)]}"/>
<field name="mother_has_disabilities" invisible="1"/>
<field name="mother_income" widget="monetary"
options="{'currency_field': 'currency_id', 'field_digits': False}"
digits="[16,0]"
attrs="{'invisible':[('is_mother_work','=',False)],'required':[('is_mother_work','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('is_mother_work','=',False)]}"/>
<field name="education_status"/>
<!-- <field name="is_mother_benefit"/>-->
</group>
@ -681,13 +682,13 @@
readonly="1"/>
<field name="replacement_is_mother_work"
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('replacement_is_mother_work','=',False)]}"/>
<field name="replacement_mother_has_disabilities"
attrs="{'required':[('state','not in',['draft','new']),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_mother_income"
attrs="{'invisible':[('replacement_is_mother_work','=',False)],'required':[('replacement_is_mother_work','=',True),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="replacement_mother_salary_certificate"
widget="many2many_attachment_preview"
attrs="{'invisible':[('replacement_is_mother_work','=',False)]}"/>
<field name="replacement_education_status"/>
<!-- <field name="is_mother_benefit"/>-->
</group>
@ -758,22 +759,22 @@
<field name="relation" class="oe_inline" nolabel="1" invisible="1"/>
</div>
</group>
<group>
<group attrs="{'invisible':[('relationn_type','in',['mother','replacement_mother'])]}">
<group>
<label for="member_first_name" string="Member Name"/>
<div class="o_row">
<field name="member_first_name" force_save="1" nolabel="1"
placeholder="First Name"
attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
attrs="{'required':[('is_mother','=',False)]}"/>
<field name="member_second_name" force_save="1" nolabel="1"
placeholder="Second Name"
attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
attrs="{'required':[('is_mother','=',False)]}"/>
<field name="member_third_name" force_save="1" nolabel="1"
placeholder="Third Name"
attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
attrs="{'required':[('is_mother','=',False)]}"/>
<field name="member_family_name" force_save="1" nolabel="1"
placeholder="Famil yname"
attrs="{'invisible':[('is_mother','=',True)],'required':[('is_mother','=',False)]}"/>
attrs="{'required':[('is_mother','=',False)]}"/>
</div>
</group>
<group/>
@ -1604,7 +1605,7 @@
<field name="arch" type="xml">
<tree string=" Benefit" create="0">
<field name="code" decoration-bf="1"/>
<field name="name" force_save="1"/>
<field name="benefit_partner_name"/>
<field name="benefit_category_id"/>
<field name="create_date" optional="hide"/>
<field name="meal_card" optional="hide"/>

View File

@ -75,19 +75,19 @@
options='{"no_open": True,"no_create_edit": True}'/>
</div>
</group>
<group>
<group attrs="{'invisible':[('relationn_type','in',['mother','replacement_mother'])]}">
<group>
<label for="member_first_name" string="Member Name"/>
<div class="o_row">
<field name="member_first_name" required="1" nolabel="1" placeholder="First Name"
<field name="member_first_name" nolabel="1" placeholder="First Name"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
<field name="member_second_name" force_save="1" nolabel="1"
placeholder="Second Name" required="1"
placeholder="Second Name"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
<field name="member_third_name" required="1" nolabel="1" placeholder="Third Name"
<field name="member_third_name" nolabel="1" placeholder="Third Name"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
<field name="member_family_name" force_save="1" nolabel="1"
placeholder="Famil yname" required="1"
placeholder="Famil yname"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
</div>
</group>
@ -104,8 +104,9 @@
<field name="member_phone"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
<field name="relationn_type" invisible="1"/>
<field name="member_location_conf" required="1" domain="[('location_type', '=', relationn_type in ['mother','replacement_mother'] and 'mother_location' or 'member')]"
options="{'no_create': True, 'no_create_edit': True}"
<field name="member_location_conf" required="1"
domain="[('location_type', '=', relationn_type in ['mother','replacement_mother'] and 'mother_location' or 'member')]"
options="{'no_create': True, 'no_create_edit': True}"
attrs="{'readonly':[('state','not in',['draft','complete_info'])]}"/>
</group>
<group>

View File

@ -87,7 +87,7 @@
<button name="action_create_new_visit"
string="Create New Visit"
type="object"
states="close"/>
states="cancel"/>
<button name="action_postpone"
string="Postponement"
type="object"
@ -119,7 +119,7 @@
type="object"
class="oe_highlight"
icon="fa-map"
attrs="{'invisible':['|',('benefit_id', '=', False),('state', '=', 'done')]}"/>
attrs="{'invisible':['|',('benefit_id', '=', False),('state', 'in', ('done','close'))]}"/>
<field name="state" widget="statusbar"
statusbar_visible="draft,contact,schedule_a_visit,cancel,done,close"/>
</header>