[IMP] odex_benefit: IMP benefit

This commit is contained in:
younes 2026-01-07 15:07:40 +01:00
parent 189847cf26
commit 2f613d34e6
3 changed files with 21 additions and 16 deletions

View File

@ -1262,6 +1262,8 @@ class GrantBenefitProfile(models.Model):
# Check each ID number for 10-digit format and uniqueness within the parent model
unique_ids = set()
for label, id_number in id_numbers.items():
if id_number == 'NULL' and label == 'رقم هوية الأم':
continue
if id_number:
if not re.match(r'^\d{10}$', id_number):
raise ValidationError(_("%s must contain exactly 10 digits.")%label)
@ -1280,9 +1282,13 @@ class GrantBenefitProfile(models.Model):
# Check for uniqueness against `member_id_number` in child records and across database records
for member in self.member_ids:
if member.member_id_number == 'NULL':
continue
if member.member_id_number and member.member_id_number in unique_ids and member.id not in [self.mother_family_member_id.id,self.replacement_mother_family_member_id.id]:
raise ValidationError(_("The ID number %s in the Family Members list must be unique across the record.")%member.member_id_number)
for id_number in unique_ids:
if id_number == 'NULL':
continue
if id_number == self.father_id_number:
conflict = self.env['grant.benefit'].search([
('id', '!=', self._origin.id),

View File

@ -1,3 +1,5 @@
from Tools.scripts.dutree import store
from odoo import fields, models, api, _
from odoo.exceptions import UserError, ValidationError
from datetime import date, datetime, timedelta
@ -41,10 +43,10 @@ class ServiceRequest(models.Model):
'attachment_id', string='Service Attachment')
requested_service_amount = fields.Float(string="Requested Service Amount", copy=False)
# yearly Estimated Rent Amount
estimated_rent_amount = fields.Float(string="Estimated Rent Amount", compute="_get_estimated_rent_amount")
estimated_rent_amount = fields.Float(string="Estimated Rent Amount", compute="_get_estimated_rent_amount",store=True)
# The value of payment by payment method(yearly-half-quartarly)
estimated_rent_amount_payment = fields.Float(string="Estimated Rent Amount Payment",
compute="_get_estimated_rent_amount_payment")
compute="_get_estimated_rent_amount_payment",store=True)
service_type = fields.Selection([('rent', 'Rent')], string='Service Type', related='service_cat.service_type')
max_limit_period = fields.Selection(string='Maximum Limit Period', related='service_cat.max_limit_period')
payment_method = fields.Selection([
@ -767,12 +769,16 @@ class ServiceRequest(models.Model):
for rec in self:
if rec.service_type != 'rent':
continue
# if rec.start and rec.end and rec.rent_start_date and rec.rent_end_date:
# if not (rec.rent_start_date <= rec.start <= rec.rent_end_date and
# rec.rent_start_date <= rec.end <= rec.rent_end_date):
# raise UserError(_(
# "The Start Date and End Date must be within the Rent Start Date and Rent End Date range."
# ))
months_map = {
'1': 12,
'2': 6,
'4': 3,
'12': 1
}
if rec.payment_type and rec.start:
months_to_add = months_map.get(rec.payment_type)
if months_to_add:
rec.end = rec.start + relativedelta(months=months_to_add, days=-1)
contract = rec.family_id.current_rent_contract_id if rec.benefit_type == 'family' else False
if rec.benefit_type == 'member' and rec.member_id:
@ -797,13 +803,6 @@ class ServiceRequest(models.Model):
_("Requested start date cannot be before the contract start date.")
)
if rec.payment_type and rec.start and rec.end:
months_map = {
'1': 12, # yearly
'2': 6, # half-yearly
'4': 3, # quarterly
'5': 1 # monthly
}
allowed_months = months_map.get(rec.payment_type)
if not allowed_months:
continue

View File

@ -847,7 +847,7 @@
<!-- action="benefit_reports_log_action"-->
<!-- sequence="2"/>-->
<menuitem id='benefit_tools' name='Tools' parent='benefits_root_menu'
sequence="8" groups="odex_benefit.group_benefit_manager"/>
sequence="8" groups="odex_benefit.group_benefit_settings"/>
<!--benefit vehicle model-->
<menuitem id="benefit_vehicle_model_settings_menu" name="General Settings" parent="odex_benefit.benefit_tools" sequence="4"/>