[IMP] odex_benefit: IMP benefit
This commit is contained in:
parent
189847cf26
commit
2f613d34e6
|
|
@ -1262,6 +1262,8 @@ class GrantBenefitProfile(models.Model):
|
||||||
# Check each ID number for 10-digit format and uniqueness within the parent model
|
# Check each ID number for 10-digit format and uniqueness within the parent model
|
||||||
unique_ids = set()
|
unique_ids = set()
|
||||||
for label, id_number in id_numbers.items():
|
for label, id_number in id_numbers.items():
|
||||||
|
if id_number == 'NULL' and label == 'رقم هوية الأم':
|
||||||
|
continue
|
||||||
if id_number:
|
if id_number:
|
||||||
if not re.match(r'^\d{10}$', id_number):
|
if not re.match(r'^\d{10}$', id_number):
|
||||||
raise ValidationError(_("%s must contain exactly 10 digits.")%label)
|
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
|
# Check for uniqueness against `member_id_number` in child records and across database records
|
||||||
for member in self.member_ids:
|
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]:
|
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)
|
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:
|
for id_number in unique_ids:
|
||||||
|
if id_number == 'NULL':
|
||||||
|
continue
|
||||||
if id_number == self.father_id_number:
|
if id_number == self.father_id_number:
|
||||||
conflict = self.env['grant.benefit'].search([
|
conflict = self.env['grant.benefit'].search([
|
||||||
('id', '!=', self._origin.id),
|
('id', '!=', self._origin.id),
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
from Tools.scripts.dutree import store
|
||||||
|
|
||||||
from odoo import fields, models, api, _
|
from odoo import fields, models, api, _
|
||||||
from odoo.exceptions import UserError, ValidationError
|
from odoo.exceptions import UserError, ValidationError
|
||||||
from datetime import date, datetime, timedelta
|
from datetime import date, datetime, timedelta
|
||||||
|
|
@ -41,10 +43,10 @@ class ServiceRequest(models.Model):
|
||||||
'attachment_id', string='Service Attachment')
|
'attachment_id', string='Service Attachment')
|
||||||
requested_service_amount = fields.Float(string="Requested Service Amount", copy=False)
|
requested_service_amount = fields.Float(string="Requested Service Amount", copy=False)
|
||||||
# yearly Estimated Rent Amount
|
# 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)
|
# The value of payment by payment method(yearly-half-quartarly)
|
||||||
estimated_rent_amount_payment = fields.Float(string="Estimated Rent Amount Payment",
|
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')
|
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')
|
max_limit_period = fields.Selection(string='Maximum Limit Period', related='service_cat.max_limit_period')
|
||||||
payment_method = fields.Selection([
|
payment_method = fields.Selection([
|
||||||
|
|
@ -767,12 +769,16 @@ class ServiceRequest(models.Model):
|
||||||
for rec in self:
|
for rec in self:
|
||||||
if rec.service_type != 'rent':
|
if rec.service_type != 'rent':
|
||||||
continue
|
continue
|
||||||
# if rec.start and rec.end and rec.rent_start_date and rec.rent_end_date:
|
months_map = {
|
||||||
# if not (rec.rent_start_date <= rec.start <= rec.rent_end_date and
|
'1': 12,
|
||||||
# rec.rent_start_date <= rec.end <= rec.rent_end_date):
|
'2': 6,
|
||||||
# raise UserError(_(
|
'4': 3,
|
||||||
# "The Start Date and End Date must be within the Rent Start Date and Rent End Date range."
|
'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
|
contract = rec.family_id.current_rent_contract_id if rec.benefit_type == 'family' else False
|
||||||
if rec.benefit_type == 'member' and rec.member_id:
|
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.")
|
_("Requested start date cannot be before the contract start date.")
|
||||||
)
|
)
|
||||||
if rec.payment_type and rec.start and rec.end:
|
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)
|
allowed_months = months_map.get(rec.payment_type)
|
||||||
if not allowed_months:
|
if not allowed_months:
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -847,7 +847,7 @@
|
||||||
<!-- action="benefit_reports_log_action"-->
|
<!-- action="benefit_reports_log_action"-->
|
||||||
<!-- sequence="2"/>-->
|
<!-- sequence="2"/>-->
|
||||||
<menuitem id='benefit_tools' name='Tools' parent='benefits_root_menu'
|
<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-->
|
<!--benefit vehicle model-->
|
||||||
<menuitem id="benefit_vehicle_model_settings_menu" name="General Settings" parent="odex_benefit.benefit_tools" sequence="4"/>
|
<menuitem id="benefit_vehicle_model_settings_menu" name="General Settings" parent="odex_benefit.benefit_tools" sequence="4"/>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue