[IMP] odex_benefit: IMP benefit
This commit is contained in:
parent
1ef4053ba7
commit
8a04116bc3
|
|
@ -1137,10 +1137,14 @@ msgstr "حساب"
|
|||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__acc_holder_name
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__family_member_id
|
||||
msgid "Account Holder Name"
|
||||
msgstr "اسم مالك الحساب"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__family_member_id
|
||||
msgid "Account Holder Name"
|
||||
msgstr "مالك الحساب"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__acc_number
|
||||
msgid "Account Number"
|
||||
|
|
@ -14988,8 +14992,8 @@ msgstr "البنك مطلوب."
|
|||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/benefit.py:0
|
||||
#, python-format
|
||||
msgid "Account Holder Name is required for non-family members."
|
||||
msgstr "اسم صاحب الحساب مطلوب لغير أفراد العائلة."
|
||||
msgid "Account Holder Name is required."
|
||||
msgstr "اسم صاحب الحساب مطلوب."
|
||||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/benefit.py:0
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class GrantBenefitProfile(models.Model):
|
|||
mother_location_conf = fields.Many2one('location.settings',string='Mother Location',domain="[('location_type','=','mother_location')]")
|
||||
is_mother_work = fields.Boolean('Is Mother Work?')
|
||||
mother_has_disabilities = fields.Boolean('Has Disabilities?')
|
||||
mother_income = fields.Float("Mother Income", digits=(16, 0))
|
||||
mother_income = fields.Float("Mother Income", digits=(16, 0),compute='calculate_income', store=True)
|
||||
mother_net_income = fields.Float(string="Mother Net Income",compute='_compute_mother_net_income',
|
||||
store=True,help="Mother gross income minus her deducted expenses and monthly debt installments")
|
||||
mother_birth_date = fields.Date(string="Birth Date")
|
||||
|
|
@ -302,6 +302,7 @@ class GrantBenefitProfile(models.Model):
|
|||
food_surplus_type = fields.Many2many('food.surplus.type', string='')
|
||||
# Income and salary
|
||||
salary_ids = fields.One2many('salary.line', 'benefit_id', string='')
|
||||
mother_salary_ids = fields.One2many('salary.line', 'mother_benefit_id', string="Mother Income")
|
||||
# Commercial Record
|
||||
is_active = fields.Boolean(string='')
|
||||
commercial_record_code = fields.Char(string='Commercial Record Code')
|
||||
|
|
@ -707,8 +708,18 @@ class GrantBenefitProfile(models.Model):
|
|||
def _sms_get_number_fields(self):
|
||||
return ['sms_phone']
|
||||
|
||||
@api.onchange('family_member_id')
|
||||
def _onchange_family_member_id(self):
|
||||
for record in self:
|
||||
if record.is_family_member and record.family_member_id:
|
||||
record.acc_holder_name = record.family_member_id.name
|
||||
record.acc_holder_id_number = record.family_member_id.member_id_number
|
||||
else:
|
||||
record.acc_holder_name = False
|
||||
record.acc_holder_id_number = False
|
||||
|
||||
@api.depends('mother_income', 'is_mother_work','mother_expenses_ids','mother_debits_ids')
|
||||
|
||||
@api.depends('is_mother_work','mother_salary_ids','mother_expenses_ids','mother_debits_ids')
|
||||
def _compute_mother_net_income(self):
|
||||
for rec in self:
|
||||
if not rec.is_mother_work:
|
||||
|
|
@ -720,7 +731,9 @@ class GrantBenefitProfile(models.Model):
|
|||
sum(rec.mother_debits_ids.filtered('deduct_from_family_income').mapped('monthly_installment'))
|
||||
)
|
||||
|
||||
rec.mother_net_income = max(rec.mother_income - deductions, 0.0)
|
||||
mother_income = sum(rec.mother_salary_ids.filtered(lambda e: e.approved and e.is_mother_salary).mapped('salary_amount'))
|
||||
|
||||
rec.mother_net_income = max(mother_income - deductions, 0.0)
|
||||
|
||||
def _compute_total_families(self):
|
||||
for record in self:
|
||||
|
|
@ -1460,7 +1473,7 @@ class GrantBenefitProfile(models.Model):
|
|||
]
|
||||
if any(field in vals for field in mother_fields):
|
||||
for rec in self:
|
||||
rec.calculate_income(rec.mother_net_income, rec.mother_status, rec.salary_ids)
|
||||
#rec.calculate_income(rec.mother_net_income, rec.mother_status, rec.salary_ids)
|
||||
rec.add_or_replace_mother_as_member()
|
||||
|
||||
# Handle replacement mother update/create
|
||||
|
|
@ -1476,7 +1489,7 @@ class GrantBenefitProfile(models.Model):
|
|||
if any(field in vals for field in replacement_fields):
|
||||
for rec in self:
|
||||
if rec.add_replacement_mother:
|
||||
rec.calculate_income(rec.replacement_mother_income, rec.replacement_mother_status, rec.salary_ids)
|
||||
#rec.calculate_income(rec.replacement_mother_income, rec.replacement_mother_status, rec.salary_ids)
|
||||
rec.add_or_replace_replacement_mother_as_member()
|
||||
return res
|
||||
|
||||
|
|
@ -1495,11 +1508,11 @@ class GrantBenefitProfile(models.Model):
|
|||
res.code = self.env['ir.sequence'].sudo().next_by_code('benefit.sequence') or _('New')
|
||||
# Add mother
|
||||
if res.mother_id_number:
|
||||
res.calculate_income(res.mother_net_income, res.mother_status, res.salary_ids)
|
||||
#res.calculate_income(res.mother_net_income, res.mother_status, res.salary_ids)
|
||||
res.add_or_replace_mother_as_member()
|
||||
# Add replacement mother
|
||||
if res.add_replacement_mother and res.replacement_mother_id_number:
|
||||
res.calculate_income(res.replacement_mother_income, res.replacement_mother_status, res.salary_ids)
|
||||
#res.calculate_income(res.replacement_mother_income, res.replacement_mother_status, res.salary_ids)
|
||||
res.add_or_replace_replacement_mother_as_member()
|
||||
return res
|
||||
|
||||
|
|
@ -1594,10 +1607,16 @@ class GrantBenefitProfile(models.Model):
|
|||
messages.append(_("Account Number is required."))
|
||||
if not rec.bank_id:
|
||||
messages.append(_("Bank is required."))
|
||||
if not rec.is_family_member and not rec.acc_holder_name:
|
||||
messages.append(_("Account Holder Name is required for non-family members."))
|
||||
if rec.is_family_member and not rec.family_member_id:
|
||||
messages.append(_("Family Member must be selected."))
|
||||
if not rec.is_family_member and not rec.owner_identity_attachment_ids:
|
||||
messages.append(_("Owner Identity Attachment is required."))
|
||||
if not rec.is_family_member and not rec.family_approval_attachment_ids:
|
||||
messages.append(_("Family Approval Attachment is required."))
|
||||
if not rec.acc_holder_name:
|
||||
messages.append(_("Account Holder Name is required."))
|
||||
if not rec.acc_holder_id_number:
|
||||
messages.append(_("Account Holder ID Number is required."))
|
||||
|
||||
if messages:
|
||||
raise UserError("\n".join(messages))
|
||||
|
|
@ -2110,32 +2129,22 @@ class GrantBenefitProfile(models.Model):
|
|||
ben.expenses_total = len(expenses)
|
||||
ben.total_expenses = total_expenses + ben.estimated_rent_amount
|
||||
|
||||
def calculate_income(self,income, status, salary_ids):
|
||||
@api.depends('mother_net_income', 'mother_status')
|
||||
def calculate_income(self):
|
||||
validation_setting = self.env["family.validation.setting"].search([], limit=1)
|
||||
max_income_for_mother = validation_setting.max_income_for_mother
|
||||
total = 0.0
|
||||
existing_mother_salary = salary_ids.filtered(lambda x: x.is_mother_salary == True)
|
||||
should_have_salary_line = (status == 'benefit' and income > max_income_for_mother)
|
||||
income_type = self.env['attachments.settings'].search([('is_mother_salary', '=', True)], limit=1)
|
||||
if should_have_salary_line:
|
||||
if not existing_mother_salary:
|
||||
self.env['salary.line'].create({
|
||||
'benefit_id': self.id,
|
||||
'is_mother_salary': True,
|
||||
'salary_amount': income,
|
||||
'income_type': income_type and income_type.id or False,
|
||||
'approved': True,
|
||||
})
|
||||
elif existing_mother_salary:
|
||||
existing_mother_salary.write({'salary_amount': income})
|
||||
add_mother_net_income = (self.mother_status == 'benefit' and self.mother_net_income > max_income_for_mother)
|
||||
if add_mother_net_income:
|
||||
self.mother_income = self.mother_net_income
|
||||
else:
|
||||
if existing_mother_salary:
|
||||
existing_mother_salary.sudo().unlink()
|
||||
self.mother_income = 0.0
|
||||
|
||||
@api.depends(
|
||||
'salary_ids',
|
||||
'salary_ids.salary_amount',
|
||||
'salary_ids.approved',
|
||||
'mother_income',
|
||||
'mother_status',
|
||||
)
|
||||
def get_total_income(self):
|
||||
for rec in self:
|
||||
|
|
@ -2143,19 +2152,15 @@ class GrantBenefitProfile(models.Model):
|
|||
rec.total_income = 0.0
|
||||
if not rec.add_replacement_mother:
|
||||
if rec.mother_status == 'non_benefit':
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved and not e.is_mother_salary).mapped(
|
||||
'salary_amount'))
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||
elif rec.mother_status == 'benefit':
|
||||
total = sum(
|
||||
rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.mother_income
|
||||
rec.total_income = total
|
||||
if rec.add_replacement_mother:
|
||||
if rec.replacement_mother_status == 'non_benefit':
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved and not e.is_mother_salary).mapped(
|
||||
'salary_amount'))
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||
elif rec.replacement_mother_status == 'benefit':
|
||||
total = sum(
|
||||
rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount'))
|
||||
total = sum(rec.salary_ids.filtered(lambda e: e.approved).mapped('salary_amount')) + rec.replacement_mother_income
|
||||
rec.total_income += total
|
||||
|
||||
def get_mother_name(self):
|
||||
|
|
|
|||
|
|
@ -293,6 +293,7 @@ class Salary(models.Model):
|
|||
|
||||
benefit_id = fields.Many2one(
|
||||
'grant.benefit')
|
||||
mother_benefit_id = fields.Many2one('grant.benefit', string="Mother Benefit", ondelete='cascade')
|
||||
currency_id = fields.Many2one('res.currency', related='benefit_id.currency_id')
|
||||
salary_type = fields.Char()
|
||||
income_type = fields.Many2one('attachments.settings',string='Income Type',domain="[('attach_type','=','income_attach')]")
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ class FamilyMemberProfile(models.Model):
|
|||
limit_age = 0
|
||||
|
||||
if limit_age > 0:
|
||||
start_of_next_year = rec.birth_date + rd(years=limit_age + 1)
|
||||
start_of_next_year = rec.birth_date + rd(years=limit_age)
|
||||
end_benefit_date = start_of_next_year + rd(days=grace_days)
|
||||
age_exceeded = date.today() > end_benefit_date
|
||||
else:
|
||||
|
|
@ -588,8 +588,7 @@ class FamilyMemberProfile(models.Model):
|
|||
rec.member_status = 'non_benefit'
|
||||
reasons.append(
|
||||
_("He has a physical or intellectual disability but is over %s years of age.") % exceptional_age_has_disabilities)
|
||||
if rec.education_status in [
|
||||
'educated'] and current_education_status_id.case_study != 'continuous':
|
||||
if current_education_status_id.case_study != 'continuous':
|
||||
rec.member_status = 'non_benefit'
|
||||
reasons.append(
|
||||
_("Over %s years old and not enrolled in any educational institution.") % male_benefit_age
|
||||
|
|
|
|||
|
|
@ -842,17 +842,13 @@
|
|||
<field name="is_mother_work"
|
||||
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
|
||||
<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_net_income" widget="monetary" force_save="1"
|
||||
options="{'currency_field': 'currency_id', 'field_digits': False}"
|
||||
digits="[16,0]"
|
||||
attrs="{'invisible':[('is_mother_work','=',False)]}"/>
|
||||
<field name="mother_salary_certificate"
|
||||
widget="many2many_attachment_preview"
|
||||
attrs="{'invisible':[('is_mother_work','=',False)]}"/>
|
||||
invisible="1"/>
|
||||
<field name="education_status"/>
|
||||
<!-- <field name="is_mother_benefit"/>-->
|
||||
</group>
|
||||
|
|
@ -918,6 +914,31 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Mother Income" attrs="{'invisible':[('is_mother_work','=',False)]}">
|
||||
<field name="mother_salary_ids"
|
||||
context="{'default_state': 'accepted','default_is_mother_salary': True}"
|
||||
mode="tree"
|
||||
options="{'no_open': True}"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
||||
<tree editable="bottom" delete="0">
|
||||
<field name="benefit_id" invisible="1"/>
|
||||
<field name="mother_benefit_id" invisible="1"/>
|
||||
<field name="income_type"
|
||||
options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"/>
|
||||
<field name="is_mother_salary" invisible="1"/>
|
||||
<field name="salary_amount" widget="monetary"
|
||||
options="{'currency_field': 'currency_id'}" sum="Total Income"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
<field name="salary_attach" widget="many2many_attachment_preview"/>
|
||||
<field name="attach_start_date"/>
|
||||
<field name="attach_end_date"/>
|
||||
<field name="is_required" invisible="1"/>
|
||||
<field name="is_default" invisible="1"/>
|
||||
<field name="state" invisible="1"/>
|
||||
<field name="approved" widget="boolean_toggle"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Mother Debts" attrs="{'invisible':[('is_mother_work','=',False)]}">
|
||||
<field name="mother_debits_ids" context="{'default_state': 'accepted'}"
|
||||
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}">
|
||||
|
|
@ -1634,6 +1655,9 @@
|
|||
</field>
|
||||
|
||||
<group class="oe_subtotal_footer oe_right">
|
||||
<label for="mother_income"/>
|
||||
<field name="mother_income" widget="monetary" nolabel="1" force_save="1"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
<label for="total_income"/>
|
||||
<field name="total_income" widget="monetary" nolabel="1"
|
||||
options="{'currency_field': 'currency_id'}"/>
|
||||
|
|
@ -1798,14 +1822,14 @@
|
|||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"
|
||||
options="{'no_create': True, 'no_create_edit': True}"
|
||||
/>
|
||||
<field name="acc_holder_name"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"/>
|
||||
<field name="acc_holder_id_number"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"/>
|
||||
<field name="family_member_id"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"
|
||||
options="{'no_create': True, 'no_create_edit': True}"
|
||||
/>
|
||||
<field name="acc_holder_name"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"/>
|
||||
<field name="acc_holder_id_number"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"/>
|
||||
<field name="owner_identity_attachment_ids"
|
||||
attrs="{'readonly':[('state','not in',['complete_info','waiting_approve','first_approve'])]}"
|
||||
widget="many2many_attachment_preview"/>
|
||||
|
|
|
|||
|
|
@ -344,7 +344,6 @@
|
|||
<field name="district_id"/>
|
||||
<field name="last_visit_date" optional="hide"/>
|
||||
<field name="acc_number" optional="hide"/>
|
||||
<field name="family_member_id" optional="hide"/>
|
||||
<field name="acc_holder_name" optional="hide"/>
|
||||
<field name="state" widget="badge"
|
||||
decoration-success="state in ['first_approve', 'second_approve']"
|
||||
|
|
|
|||
Loading…
Reference in New Issue