diff --git a/odex25_benefit/odex_benefit/models/benefit.py b/odex25_benefit/odex_benefit/models/benefit.py
index dc587be2f..05151d1ed 100644
--- a/odex25_benefit/odex_benefit/models/benefit.py
+++ b/odex25_benefit/odex_benefit/models/benefit.py
@@ -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),
diff --git a/odex25_benefit/odex_benefit/models/service_request.py b/odex25_benefit/odex_benefit/models/service_request.py
index f5de0d448..27e7b0422 100644
--- a/odex25_benefit/odex_benefit/models/service_request.py
+++ b/odex25_benefit/odex_benefit/models/service_request.py
@@ -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
diff --git a/odex25_benefit/odex_benefit/views/actions_and_menus.xml b/odex25_benefit/odex_benefit/views/actions_and_menus.xml
index 6d5f36300..31e9ac5a3 100644
--- a/odex25_benefit/odex_benefit/views/actions_and_menus.xml
+++ b/odex25_benefit/odex_benefit/views/actions_and_menus.xml
@@ -847,7 +847,7 @@
+ sequence="8" groups="odex_benefit.group_benefit_settings"/>