Merge branch 'dev_odex25_ensan' of https://github.com/expsa/odex25-standard-modules into samir-aladawi-service-requests-updates
This commit is contained in:
commit
d5f50e7e9a
|
|
@ -2375,6 +2375,7 @@ msgstr "التدريب"
|
|||
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_followers__follower_type
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__benefit_type
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__benefit_type
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_services_settings__benefit_type
|
||||
msgid "Benefit Type"
|
||||
msgstr "نوع المستفيدين"
|
||||
|
||||
|
|
@ -4905,6 +4906,7 @@ msgstr "استثنائية"
|
|||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__action_type__exception
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__family_member__action_type__exception
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__exception
|
||||
msgid "Exception"
|
||||
msgstr "استثناء"
|
||||
|
||||
|
|
@ -4912,6 +4914,7 @@ msgstr "استثناء"
|
|||
#: model:ir.model.fields,field_description:odex_benefit.field_exception_wizard__exception_attachment
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_family_member__exception_attachment
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__exception_attachment
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__exception_attach
|
||||
msgid "Exception Attachment"
|
||||
msgstr "مرفق الاستثناء"
|
||||
|
||||
|
|
@ -5137,6 +5140,7 @@ msgstr "الاسر المستفيدة"
|
|||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__family_id
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_visit_location__family_id
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_zkat_line__family_id
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__services_settings__benefit_type__family
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__generate_reports__service_to__family
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__benefit_type__family
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__visit_location__benefit_type__family
|
||||
|
|
@ -7951,6 +7955,7 @@ msgstr "الاجتماعات"
|
|||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__member_id
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_suspend_reason_wizard__member_id
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__benefit_type__member
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__services_settings__benefit_type__member
|
||||
msgid "Member"
|
||||
msgstr "الفرد"
|
||||
|
||||
|
|
@ -15716,11 +15721,7 @@ msgid "Maximum Age"
|
|||
msgstr "الأقصى للعمر"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_services_settings__service_description
|
||||
msgid "Service Description"
|
||||
msgstr "وصف الخدمة"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_service_request__service_conditions
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_services_settings__service_conditions
|
||||
msgid "Service Conditions"
|
||||
msgstr "شروط الخدمة"
|
||||
|
|
@ -15735,11 +15736,6 @@ msgstr "الإعدادات"
|
|||
msgid "Accounts"
|
||||
msgstr "الحسابات"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model_terms:ir.ui.view,arch_db:odex_benefit.services_settings_form
|
||||
msgid "Description and Details"
|
||||
msgstr "الوصف والتفاصيل"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields,field_description:odex_benefit.field_services_settings__allowed_recurrence
|
||||
msgid "Allowed Recurrence"
|
||||
|
|
@ -15893,6 +15889,7 @@ msgstr "متزوجة"
|
|||
|
||||
#. module: odex_benefit
|
||||
#: code:addons/odex_benefit/models/family_members.py:0
|
||||
#: code:addons/odex_benefit/models/family_members.py:0
|
||||
#, python-format
|
||||
msgid "She is employed and not enrolled in an educational institution."
|
||||
msgstr "تعمل وغير منتظمة بجهة تعلمية"
|
||||
|
|
@ -15934,4 +15931,10 @@ msgstr "لاتقييم مع الاسرة"
|
|||
msgid ""
|
||||
"Application rejected due to missing documents, missing official proofs, or "
|
||||
"the family's ineligibility for the association's services."
|
||||
msgstr "عدم استكمال المستندات المطاوبة او الاثباتات الرسمية او عدم استحقاق الاسرة لخدمات الجمعية وتم رفض الطلب"
|
||||
msgstr "عدم استكمال المستندات المطاوبة او الاثباتات الرسمية او عدم استحقاق الاسرة لخدمات الجمعية وتم رفض الطلب"
|
||||
|
||||
#. module: odex_benefit
|
||||
#: model_terms:ir.ui.view,arch_db:odex_benefit.service_request_form
|
||||
#: model_terms:ir.ui.view,arch_db:odex_benefit.services_settings_form
|
||||
msgid "Eligibility Criteria"
|
||||
msgstr "شروط الاستحقاق"
|
||||
|
|
@ -169,15 +169,22 @@ class ServiceRequest(models.Model):
|
|||
('send_request_to_supplier', 'Send Request To Supplier'),
|
||||
('family_received_device', 'Family Received Device'),
|
||||
('refused', 'Refused')
|
||||
], string='state',default='draft', tracking=True)
|
||||
], string='state',default='draft', tracking=True, group_expand='_expand_states')
|
||||
state_a = fields.Selection(related='state', tracking=False)
|
||||
state_b = fields.Selection(related='state', tracking=False)
|
||||
refuse_reason_id = fields.Many2one('service.refuse.reason', string="Refuse Reason")
|
||||
return_reason = fields.Text(string="Reason for Returning the Request")
|
||||
specialist_note = fields.Text(string="Specialist's Note After Return")
|
||||
exception = fields.Boolean(string='Exception',default=False)
|
||||
exception_attach = fields.Many2many('ir.attachment', 'rel_exception_attachment_service_request', 'service_request_id',
|
||||
'attachment_id', string='Exception Attachment')
|
||||
service_conditions = fields.Html(related='service_cat.service_conditions', string="Service Conditions")
|
||||
|
||||
|
||||
|
||||
def _expand_states(self, states, domain, order):
|
||||
return [key for key, val in type(self).state.selection]
|
||||
|
||||
@api.depends('service_cat', 'service_reason_id')
|
||||
def _compute_account_id(self):
|
||||
for rec in self:
|
||||
|
|
@ -576,342 +583,343 @@ class ServiceRequest(models.Model):
|
|||
date_before_ten_years = today - timedelta(days=3650)
|
||||
date_before_month = today - timedelta(days=30)
|
||||
for rec in self:
|
||||
# Validation for 'member' benefit type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'rent':
|
||||
max_requested_amount = rec.service_cat.max_amount_for_student
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
if not rec.exception and not rec.exception_attach:
|
||||
# Validation for 'member' benefit type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'rent':
|
||||
max_requested_amount = rec.service_cat.max_amount_for_student
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Validation for 'family' benefit type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'rent':
|
||||
rent_line_id = rec.service_cat.rent_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id \
|
||||
and r.benefit_count == rec.benefit_member_count
|
||||
)
|
||||
max_requested_amount = rent_line_id.estimated_rent_branches if rec.branch_custom_id.branch_type == 'branches' else rent_line_id.estimated_rent_governorate
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'rent':
|
||||
rent_line_id = rec.service_cat.rent_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id \
|
||||
and r.benefit_count == rec.benefit_member_count
|
||||
)
|
||||
max_requested_amount = rent_line_id.estimated_rent_branches if rec.branch_custom_id.branch_type == 'branches' else rent_line_id.estimated_rent_governorate
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Validation for 'family and member' benefit type with 'home_maintenance'
|
||||
if rec.service_cat.service_type == 'home_maintenance':
|
||||
max_requested_amount = rec.service_cat.max_maintenance_amount
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'home_maintenance'
|
||||
if rec.service_cat.service_type == 'home_maintenance':
|
||||
max_requested_amount = rec.service_cat.max_maintenance_amount
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(_("You cannot request this service more than once a year."))
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service with restoration service in the same year."))
|
||||
# Validation for 'family' benefit type with 'home_restoration'
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_restoration':
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_ten_years),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service more than once a ten years."))
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance')
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(
|
||||
_("You cannot request this service with maintenance service in the same year."))
|
||||
if rec.has_money_to_pay_first_payment == 'no':
|
||||
home_restoration_line_id = rec.service_cat.home_restoration_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id)
|
||||
if rec.requested_service_amount > home_restoration_line_id.max_amount:
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(_("You cannot request this service more than once a year."))
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service with restoration service in the same year."))
|
||||
# Validation for 'family' benefit type with 'home_restoration'
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_restoration':
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_ten_years),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service more than once a ten years."))
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance')
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(
|
||||
_("You cannot request more than %s") % home_restoration_line_id.max_amount
|
||||
)
|
||||
_("You cannot request this service with maintenance service in the same year."))
|
||||
if rec.has_money_to_pay_first_payment == 'no':
|
||||
home_restoration_line_id = rec.service_cat.home_restoration_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id)
|
||||
if rec.requested_service_amount > home_restoration_line_id.max_amount:
|
||||
raise UserError(
|
||||
_("You cannot request more than %s") % home_restoration_line_id.max_amount
|
||||
)
|
||||
|
||||
# Validation for 'family' benefit type with 'complete_building_house' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'complete_building_house':
|
||||
# Check for existing request of the same type
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'complete_building_house'),
|
||||
], limit=1)
|
||||
if existing_request:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice"))
|
||||
existing_request_restoration = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You Cannot request this service and home restoration twice"))
|
||||
# Validation for 'family' benefit type with 'electrical_devices' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electrical_devices':
|
||||
# Check for existing request of the same type in seven years and not exception or steal
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'electrical_devices'),
|
||||
('date', '>', date_before_seven_years),
|
||||
('device_id', '=', rec.device_id.id)
|
||||
], limit=1)
|
||||
if existing_request and not rec.exception_or_steal:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice in seven years"))
|
||||
# Validation for 'family' benefit type with 'home_furnishing' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_furnishing':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_furnishing'),
|
||||
('date', '>', date_before_three_years),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# if self.id:
|
||||
# domain.append(('id', '!=', self.id)) # Exclude current record if already saved
|
||||
# Validation for 'family' benefit type with 'complete_building_house' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'complete_building_house':
|
||||
# Check for existing request of the same type
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'complete_building_house'),
|
||||
], limit=1)
|
||||
if existing_request:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice"))
|
||||
existing_request_restoration = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You Cannot request this service and home restoration twice"))
|
||||
# Validation for 'family' benefit type with 'electrical_devices' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electrical_devices':
|
||||
# Check for existing request of the same type in seven years and not exception or steal
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'electrical_devices'),
|
||||
('date', '>', date_before_seven_years),
|
||||
('device_id', '=', rec.device_id.id)
|
||||
], limit=1)
|
||||
if existing_request and not rec.exception_or_steal:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice in seven years"))
|
||||
# Validation for 'family' benefit type with 'home_furnishing' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_furnishing':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_furnishing'),
|
||||
('date', '>', date_before_three_years),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# if self.id:
|
||||
# domain.append(('id', '!=', self.id)) # Exclude current record if already saved
|
||||
|
||||
# Search for existing requests
|
||||
existing_requests_within_three_years = self.search(domain)
|
||||
# Search for existing requests
|
||||
existing_requests_within_three_years = self.search(domain)
|
||||
|
||||
# Include current record in the calculation
|
||||
total_amount_in_three_years = sum(
|
||||
existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years += sum(self.furnishing_items_ids.mapped('furnishing_cost'))
|
||||
if not rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount:
|
||||
# Include current record in the calculation
|
||||
total_amount_in_three_years = sum(
|
||||
existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years += sum(self.furnishing_items_ids.mapped('furnishing_cost'))
|
||||
if not rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
return res
|
||||
if rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount_if_exception:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'electricity_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electricity_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'electricity_bill'),
|
||||
('date', '>', date_before_month)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_month = self.search(domain)
|
||||
if existing_requests_within_month:
|
||||
raise UserError(_("You cannot request this service agin in this month"))
|
||||
if rec.requested_service_amount > rec.max_electricity_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
"You cannot request more than %s") % rec.max_electricity_bill_amount}
|
||||
return res
|
||||
if rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount_if_exception:
|
||||
# Validation for 'family' benefit type with 'water_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'water_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'water_bill'),
|
||||
('date', '>', date_before_year),('id','!=',self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service agin in this year"))
|
||||
if rec.requested_service_amount > rec.max_water_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
"You cannot request more than %s") % rec.max_water_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'electricity_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electricity_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'electricity_bill'),
|
||||
('date', '>', date_before_month)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_month = self.search(domain)
|
||||
if existing_requests_within_month:
|
||||
raise UserError(_("You cannot request this service agin in this month"))
|
||||
if rec.requested_service_amount > rec.max_electricity_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_electricity_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'water_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'water_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'water_bill'),
|
||||
('date', '>', date_before_year),('id','!=',self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service agin in this year"))
|
||||
if rec.requested_service_amount > rec.max_water_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_water_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_car' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_car':
|
||||
if rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you had a car"))
|
||||
if rec.benefit_member_count < rec.service_cat.min_count_member:
|
||||
raise UserError(
|
||||
_("You cannot request this service because you are less than %s") % rec.service_cat.min_count_member)
|
||||
if rec.requested_service_amount > rec.service_cat.max_buy_car_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_buy_car_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'recruiting_driver':
|
||||
recruiting_driver_existing_request = self.search([
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_driver'), ('id', '!=', self._origin.id)],
|
||||
limit=1)
|
||||
son_members_above_age = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'son' and x.age > 18)
|
||||
daughter_members_above_age = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'daughter' and x.age > 18)
|
||||
disable_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'mother')
|
||||
work_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'mother' and x.benefit.is_mother_work)
|
||||
disable_replacement_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'replacement_mother')
|
||||
work_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda
|
||||
x: x.relationn.relation_type == 'replacement_mother' and x.replacement_is_mother_work)
|
||||
if not rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you do not have a car"))
|
||||
if son_members_above_age or daughter_members_above_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service because children above 18 years"))
|
||||
if rec.family_id.add_replacement_mother and not disable_replacement_mother and not work_replacement_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if not rec.family_id.add_replacement_mother and not disable_mother and not work_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if recruiting_driver_existing_request:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again"))
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_driver_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_recruiting_driver_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'transportation_insurance' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'transportation_insurance':
|
||||
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
|
||||
# Validation for 'family' benefit type with 'buy_car' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_car':
|
||||
if rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you had a car"))
|
||||
if rec.benefit_member_count < rec.service_cat.min_count_member:
|
||||
raise UserError(
|
||||
_("You cannot request this service because you are less than %s") % rec.service_cat.min_count_member)
|
||||
if rec.requested_service_amount > rec.service_cat.max_buy_car_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {
|
||||
'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.max_amount
|
||||
}
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_buy_car_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'health_care':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'health_care'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'recruiting_driver':
|
||||
recruiting_driver_existing_request = self.search([
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_driver'), ('id', '!=', self._origin.id)],
|
||||
limit=1)
|
||||
son_members_above_age = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'son' and x.age > 18)
|
||||
daughter_members_above_age = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'daughter' and x.age > 18)
|
||||
disable_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'mother')
|
||||
work_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'mother' and x.benefit.is_mother_work)
|
||||
disable_replacement_mother = rec.family_id.mapped('member_ids').filtered(
|
||||
lambda x: x.relationn.relation_type == 'replacement_mother')
|
||||
work_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda
|
||||
x: x.relationn.relation_type == 'replacement_mother' and x.replacement_is_mother_work)
|
||||
if not rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you do not have a car"))
|
||||
if son_members_above_age or daughter_members_above_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service because children above 18 years"))
|
||||
if rec.family_id.add_replacement_mother and not disable_replacement_mother and not work_replacement_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if not rec.family_id.add_replacement_mother and not disable_mother and not work_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if recruiting_driver_existing_request:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again"))
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_driver_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_recruiting_driver_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'transportation_insurance' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'transportation_insurance':
|
||||
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {
|
||||
'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.max_amount
|
||||
}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'health_care':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'health_care'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
|
||||
# Include current record in the calculation
|
||||
total_amount_in_year = sum(existing_requests_within_year.mapped('requested_service_amount'))
|
||||
total_amount_in_year += rec.requested_service_amount
|
||||
if total_amount_in_year > rec.service_cat.max_health_care_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_health_care_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'recruiting_domestic_worker_or_nurse':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_domestic_worker_or_nurse'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service more than once Within year."))
|
||||
# Include current record in the calculation
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount}
|
||||
return res
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'marriage':
|
||||
if rec.member_age > rec.service_cat.member_max_age:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Age should be less than %s ") % rec.service_cat.member_max_age}
|
||||
return res
|
||||
if rec.member_payroll > rec.service_cat.member_max_payroll:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Payroll should be less than %s ") % rec.service_cat.member_max_payroll}
|
||||
return res
|
||||
if rec.has_marriage_course == 'no':
|
||||
raise UserError(_("You Should take a course"))
|
||||
# Validation for 'family' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.eid_gift_benefit_count == 0:
|
||||
raise UserError(_("You cannot request this service"))
|
||||
# Validation for 'family and member' benefit type with 'natural_disasters' service type
|
||||
if rec.service_cat.service_type == 'natural_disasters':
|
||||
if rec.requested_service_amount > rec.service_cat.natural_disasters_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.natural_disasters_max_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'legal_arguments' service type
|
||||
if rec.service_cat.service_type == 'legal_arguments':
|
||||
if rec.requested_service_amount > rec.service_cat.legal_arguments_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.legal_arguments_max_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_home' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_home':
|
||||
# Search for existing requests
|
||||
existing_buy_home_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'buy_home'),
|
||||
('id', '!=', self._origin.id)])
|
||||
existing_home_restoration_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=',
|
||||
'home_restoration'),
|
||||
('id', '!=', self._origin.id)])
|
||||
if rec.requested_service_amount > rec.service_cat.buy_home_max_total_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.buy_home_max_total_amount}
|
||||
return res
|
||||
if existing_buy_home_requests:
|
||||
raise UserError(_("You cannot request this service Again"))
|
||||
if existing_home_restoration_requests:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because you request Home restoration service"))
|
||||
if rec.home_age > rec.service_cat.home_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because the home Age More than %s") % rec.service_cat.home_age)
|
||||
# Include current record in the calculation
|
||||
total_amount_in_year = sum(existing_requests_within_year.mapped('requested_service_amount'))
|
||||
total_amount_in_year += rec.requested_service_amount
|
||||
if total_amount_in_year > rec.service_cat.max_health_care_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_health_care_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'recruiting_domestic_worker_or_nurse':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_domestic_worker_or_nurse'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service more than once Within year."))
|
||||
# Include current record in the calculation
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount}
|
||||
return res
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'marriage':
|
||||
if rec.member_age > rec.service_cat.member_max_age:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Age should be less than %s ") % rec.service_cat.member_max_age}
|
||||
return res
|
||||
if rec.member_payroll > rec.service_cat.member_max_payroll:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Payroll should be less than %s ") % rec.service_cat.member_max_payroll}
|
||||
return res
|
||||
if rec.has_marriage_course == 'no':
|
||||
raise UserError(_("You Should take a course"))
|
||||
# Validation for 'family' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.eid_gift_benefit_count == 0:
|
||||
raise UserError(_("You cannot request this service"))
|
||||
# Validation for 'family and member' benefit type with 'natural_disasters' service type
|
||||
if rec.service_cat.service_type == 'natural_disasters':
|
||||
if rec.requested_service_amount > rec.service_cat.natural_disasters_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.natural_disasters_max_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'legal_arguments' service type
|
||||
if rec.service_cat.service_type == 'legal_arguments':
|
||||
if rec.requested_service_amount > rec.service_cat.legal_arguments_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.legal_arguments_max_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_home' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_home':
|
||||
# Search for existing requests
|
||||
existing_buy_home_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'buy_home'),
|
||||
('id', '!=', self._origin.id)])
|
||||
existing_home_restoration_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=',
|
||||
'home_restoration'),
|
||||
('id', '!=', self._origin.id)])
|
||||
if rec.requested_service_amount > rec.service_cat.buy_home_max_total_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.buy_home_max_total_amount}
|
||||
return res
|
||||
if existing_buy_home_requests:
|
||||
raise UserError(_("You cannot request this service Again"))
|
||||
if existing_home_restoration_requests:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because you request Home restoration service"))
|
||||
if rec.home_age > rec.service_cat.home_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because the home Age More than %s") % rec.service_cat.home_age)
|
||||
|
||||
|
||||
@api.onchange('requested_quantity','benefit_type')
|
||||
|
|
@ -952,16 +960,12 @@ class ServiceRequest(models.Model):
|
|||
# if self.service_cat:
|
||||
# self.service_cat = False
|
||||
|
||||
@api.depends('family_category', 'sub_service_category')
|
||||
@api.depends('family_category')
|
||||
def _compute_available_service_cats(self):
|
||||
for rec in self:
|
||||
if rec.benefit_type:
|
||||
if rec.benefit_type == 'family':
|
||||
domain = [
|
||||
('is_main_service', '=', False),
|
||||
('service_type', '!=', False),
|
||||
('parent_service', '=', rec.sub_service_category.id)
|
||||
]
|
||||
domain = [('service_type', '!=', 'main_service')]
|
||||
rec.available_service_cats = rec.available_service_cats.sudo().search(domain).filtered(
|
||||
lambda r: rec.family_category.id in r.benefit_category_ids.ids or\
|
||||
(rec.family_category.id, rec.benefit_member_count) in r.rent_lines.mapped(lambda r: (r.benefit_category_id.id, r.benefit_count)) or\
|
||||
|
|
@ -971,9 +975,7 @@ class ServiceRequest(models.Model):
|
|||
)
|
||||
elif rec.benefit_type == 'member':
|
||||
domain = [
|
||||
('is_main_service', '=', False),
|
||||
('service_type', '!=', False),
|
||||
('parent_service', '=', rec.sub_service_category.id),
|
||||
('service_type', '!=', 'main_service'),
|
||||
('is_this_service_for_student','=',True)
|
||||
]
|
||||
rec.available_service_cats = rec.available_service_cats.sudo().search(domain).filtered(
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ from odoo import fields, models, api, _
|
|||
class ServicesSettings(models.Model):
|
||||
_name = 'services.settings'
|
||||
_rec_name = 'service_name'
|
||||
_order = 'service_number'
|
||||
|
||||
service_name = fields.Char(string='Service Name')
|
||||
benefit_type = fields.Selection(string='Benefit Type', selection=[('family', 'Family'), ('member', 'Member')])
|
||||
parent_service = fields.Many2one('services.settings',string='Parent Service')
|
||||
is_main_service = fields.Boolean(string='Is Main Service?')
|
||||
is_service_producer = fields.Boolean(string='Is Service Producer?')
|
||||
|
|
@ -18,7 +20,7 @@ class ServicesSettings(models.Model):
|
|||
('providing_medicines_medical_devices_and_needs_the_disabled','Providing Medicines Medical Devices And Needs The Disabled'),
|
||||
('recruiting_domestic_worker_or_nurse','Recruiting a domestic worker or nurse') ,('marriage','Marriage'),('eid_gift','Eid gift'),
|
||||
('winter_clothing','Winter clothing'),('ramadan_basket','Ramadan basket'),('natural_disasters','Natural disasters'),
|
||||
('legal_arguments','Legal arguments'),('buy_home','Buy Home')]
|
||||
('legal_arguments','Legal arguments'),('buy_home','Buy Home'),('main_service','Main Service')]
|
||||
,string='Service Type')
|
||||
max_amount_for_student = fields.Float(string='Max Amount for Student')
|
||||
raise_amount_for_orphan = fields.Float(string='Raise Amount For Orphan')
|
||||
|
|
@ -94,7 +96,7 @@ class ServicesSettings(models.Model):
|
|||
max_amount = fields.Monetary(string="Maximum Amount", currency_field='currency_id',copy=False)
|
||||
max_age = fields.Integer(string="Maximum Age",copy=False)
|
||||
service_description = fields.Text(string="Service Description")
|
||||
service_conditions = fields.Text(string="Service Conditions")
|
||||
service_conditions = fields.Html(string="Service Conditions")
|
||||
allowed_recurrence = fields.Selection([
|
||||
('once', 'Once'),
|
||||
('periodic', 'Every Period'),
|
||||
|
|
|
|||
|
|
@ -64,20 +64,20 @@
|
|||
<field name="branch_custom_id" force_save="1"/>
|
||||
<field name="member_id" attrs="{'invisible':[('benefit_type','!=','member')],'readonly':[('state','not in',['draft','researcher','send_request'])],'required':[('benefit_type','=','member')]}"/>
|
||||
<field name="member_age" attrs="{'invisible':[('benefit_type','!=','member')]}"/>
|
||||
<field name="account_id" attrs="{'invisible':[('service_type','=','electrical_devices')]}"/>
|
||||
<field name="device_account_id" attrs="{'invisible':[('service_type','!=','electrical_devices')]}"/>
|
||||
<field name="account_id" invisible="1"/>
|
||||
<field name="device_account_id" invisible="1"/>
|
||||
<field name="accountant_id" attrs="{'invisible':[('state','in',['draft','researcher','send_request','first_approve','second_approve'])]}"/>
|
||||
<field name="payment_order_id" readonly="1" groups="odex_benefit.group_benefit_accounting_accept" attrs="{'invisible':[('service_type','=','electrical_devices')]}"/>
|
||||
<field name="payment_order_id" readonly="1" groups="odex_benefit.group_benefit_accounting_accept" invisible="1"/>
|
||||
<field name="vendor_bill" readonly="1" attrs="{'invisible':[('service_type','!=','electrical_devices')]}"/>
|
||||
<field name="is_service_producer" invisible="1"/>
|
||||
<field name="service_producer_id" attrs="{'invisible':[('is_service_producer','=',False)],'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="available_service_cats" invisible="1"/>
|
||||
<field name="service_cat" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" domain="[('id','in',available_service_cats)]" required="1"/>
|
||||
<field name="need_status" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="main_service_category" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="sub_service_category" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="available_service_cats" invisible="1" />
|
||||
<field name="service_cat" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" domain="[('id', 'in', available_service_cats)]" required="1"/>
|
||||
<field name="main_service_category" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" invisible="1"/>
|
||||
<field name="sub_service_category" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" invisible="1"/>
|
||||
<field name="requested_service_amount" attrs="{'readonly': [
|
||||
'|',
|
||||
'&',
|
||||
|
|
@ -85,17 +85,19 @@
|
|||
('service_type', 'in', ['marriage', 'eid_gift', 'winter_clothing', 'ramadan_basket']),
|
||||
('service_type', 'in', ['electrical_devices', 'home_furnishing'])
|
||||
]}" force_save="1" required="1" />
|
||||
<field name="exception" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="exception_attach" attrs="{'invisible': [('exception', '=', False)]}" widget="many2many_attachment_preview"/>
|
||||
<field name="amount_for_buy_home_for_member_count" attrs="{'invisible':[('service_type','!=','buy_home')]}"/>
|
||||
<field name="home_age" attrs="{'invisible':[('service_type','!=','buy_home')]}"/>
|
||||
<field name="max_electricity_bill_amount" readonly="1" force_save="1" attrs="{'invisible':[('service_type','!=','electricity_bill')]}"/>
|
||||
<field name="max_water_bill_amount" readonly="1" force_save="1" attrs="{'invisible':[('service_type','!=','water_bill')]}"/>
|
||||
<field name="aid_amount" invisible="1"/>
|
||||
<field name="description" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="service_attach" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" widget="many2many_attachment_preview"/>
|
||||
<field name="service_attach" invisible="1" widget="many2many_attachment_preview"/>
|
||||
<field name="has_marriage_course" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])],'invisible':[('service_type','!=','marriage')],'required':[('service_type','=','marriage')]}"/>
|
||||
<field name="service_type" invisible="1"/>
|
||||
<field name="refuse_reason_id" readonly="1"/>
|
||||
<field name="return_reason" readonly="1"/>
|
||||
<field name="refuse_reason_id" attrs="{'invisible': [('refuse_reason_id', '=', False)]}" readonly="1"/>
|
||||
<field name="return_reason" attrs="{'invisible': [('return_reason', '=', False)]}" readonly="1"/>
|
||||
<field name="specialist_note" attrs="{'invisible': [('return_reason', '=', False)]}"/>
|
||||
<field name="required_attach" invisible="1"/>
|
||||
</group>
|
||||
|
|
@ -177,34 +179,34 @@
|
|||
</sheet>
|
||||
</form>
|
||||
</page>
|
||||
<page string="Maintenance Service" attrs="{'invisible':[('service_type', '!=', 'home_maintenance')]}">
|
||||
<page string="Maintenance Service" attrs="{'invisible':[('service_type', '!=', 'home_maintenance')]}">
|
||||
<field name="maintenance_items_ids" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="maintenance_items_id"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Home Restoration Service" attrs="{'invisible':[('service_type', '!=', 'home_restoration')]}">
|
||||
<page string="Home Restoration Service" attrs="{'invisible':[('service_type', '!=', 'home_restoration')]}">
|
||||
<group>
|
||||
<field name="restoration_max_amount"/>
|
||||
<field name="has_money_field_is_appearance" invisible="1"/>
|
||||
<field name="has_money_to_pay_first_payment" attrs="{'invisible':[('has_money_field_is_appearance', '=', False)],'required':[('has_money_field_is_appearance', '=', True)]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Complete Building House" attrs="{'invisible':[('service_type', '!=', 'complete_building_house')]}">
|
||||
<page string="Complete Building House" attrs="{'invisible':[('service_type', '!=', 'complete_building_house')]}">
|
||||
<group>
|
||||
<field name="max_complete_building_house_amount"/>
|
||||
<field name="has_money_for_payment" attrs="{'invisible':[('has_money_for_payment_is_appearance', '=', False)],'required':[('has_money_for_payment_is_appearance', '=', True)]}"/>
|
||||
<field name="has_money_for_payment_is_appearance" invisible="1"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Alternative Housing Service" attrs="{'invisible':[('service_type', '!=', 'alternative_housing')]}">
|
||||
<page string="Alternative Housing Service" attrs="{'invisible':[('service_type', '!=', 'alternative_housing')]}">
|
||||
<group>
|
||||
<field name="providing_alternative_housing_based_rent"/>
|
||||
<field name="rent_for_alternative_housing"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Electrical Devices Service" attrs="{'invisible':[('service_type', '!=', 'electrical_devices')]}">
|
||||
<page string="Electrical Devices Service" attrs="{'invisible':[('service_type', '!=', 'electrical_devices')]}">
|
||||
<group>
|
||||
<field name="device_id" attrs="{'required':[('service_type', '=', 'electrical_devices')]}"/>
|
||||
<field name="requested_quantity" attrs="{'required':[('service_type', '=', 'electrical_devices')]}"/>
|
||||
|
|
@ -212,7 +214,7 @@
|
|||
<field name="exception_or_steal_attach" widget="many2many_attachment_preview" attrs="{'invisible':[('exception_or_steal', '=', False)]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Home Furnishing Service" attrs="{'invisible':[('service_type', '!=', 'home_furnishing')]}">
|
||||
<page string="Home Furnishing Service" attrs="{'invisible':[('service_type', '!=', 'home_furnishing')]}">
|
||||
<group>
|
||||
<field name="home_furnishing_exception"/>
|
||||
</group>
|
||||
|
|
@ -228,19 +230,24 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Transportation Insurance Service" attrs="{'invisible':[('service_type', '!=', 'transportation_insurance')]}">
|
||||
<page string="Transportation Insurance Service" attrs="{'invisible':[('service_type', '!=', 'transportation_insurance')]}">
|
||||
<group>
|
||||
<field name="service_reason_id" options="{'no_create': True, 'no_open': True, 'no_create_edit': True}"/>
|
||||
<field name="max_amount" readonly="1" force_save="1"/>
|
||||
<field name="requests_counts"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Marriage Service" attrs="{'invisible':[('service_type','!=','marriage')]}">
|
||||
<page string="Marriage Service" attrs="{'invisible':[('service_type','!=','marriage')]}">
|
||||
<group>
|
||||
<field name="member_age"/>
|
||||
<field name="member_payroll"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Eligibility Criteria">
|
||||
<group>
|
||||
<field name="service_conditions"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
|
|
@ -262,11 +269,12 @@
|
|||
<field name="family_id"/>
|
||||
<field name="researcher_id"/>
|
||||
<field name="need_status"/>
|
||||
<field name="main_service_category"/>
|
||||
<field name="sub_service_category"/>
|
||||
<field name="main_service_category" invisible="1"/>
|
||||
<field name="sub_service_category" invisible="1"/>
|
||||
<field name="service_cat"/>
|
||||
<field name="payment_order_id" groups="odex_benefit.group_benefit_accounting_accept"/>
|
||||
<field name="vendor_bill" groups="odex_benefit.group_benefit_accounting_accept"/>
|
||||
<field name="requested_service_amount" />
|
||||
<field name="payment_order_id" invisible="1" groups="odex_benefit.group_benefit_accounting_accept"/>
|
||||
<field name="vendor_bill" invisible="1" groups="odex_benefit.group_benefit_accounting_accept"/>
|
||||
<field name="state" widget="badge" decoration-success="state in ['second_approve']" decoration-muted="state == 'draft'"
|
||||
decoration-danger="state in ['refused']" decoration-info="state in ['first_approve','send_request']" decoration-warning="state in ['researcher']"/>
|
||||
</tree>
|
||||
|
|
@ -320,7 +328,8 @@
|
|||
<filter string="Family Received Device" name="family_received_device" domain="[('state','=','family_received_device')]"/>
|
||||
<separator/>
|
||||
<searchpanel>
|
||||
<field name="service_cat" string="Categories" enable_counters="1" />
|
||||
<field name="state" string="State" enable_counters="1"/>
|
||||
<field name="service_cat" string="Categories" enable_counters="1"/>
|
||||
</searchpanel>
|
||||
</search>
|
||||
</field>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
<group>
|
||||
<group>
|
||||
<field name="service_number"/>
|
||||
<field name="service_type" attrs="{'invisible':[('is_main_service','=',True)]}"/>
|
||||
<field name="service_type"/>
|
||||
<field name="benefit_type"/>
|
||||
<field name="service_producer_id"
|
||||
attrs="{'invisible':['|',('is_main_service','=',True),('is_service_producer','=',False)]}"/>
|
||||
</group>
|
||||
|
|
@ -76,10 +77,7 @@
|
|||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Description and Details">
|
||||
<group>
|
||||
<field name="service_description"/>
|
||||
</group>
|
||||
<page string="Eligibility Criteria">
|
||||
<group>
|
||||
<field name="service_conditions"/>
|
||||
</group>
|
||||
|
|
@ -322,12 +320,11 @@
|
|||
<field name="model">services.settings</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Services Settings">
|
||||
<field name="service_number"/>
|
||||
<field name="service_name"/>
|
||||
<field name="service_category"/>
|
||||
<field name="parent_service"/>
|
||||
<field name="is_main_service"/>
|
||||
<field name="service_type"/>
|
||||
<field name="max_amount_for_student"/>
|
||||
<field name="raise_amount_for_orphan"/>
|
||||
<field name="show_in_portal" widget="boolean_toggle"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
|
|
@ -54,354 +54,355 @@ class ServiceRequestInherit(models.Model):
|
|||
date_before_ten_years = today - timedelta(days=3650)
|
||||
date_before_month = today - timedelta(days=30)
|
||||
for rec in self:
|
||||
# Validation for 'member' benefit type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'rent':
|
||||
max_requested_amount = rec.service_cat.max_amount_for_student
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Validation for 'family' benefit type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'rent':
|
||||
rent_line_id = rec.service_cat.rent_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id \
|
||||
and r.benefit_count == rec.benefit_member_count
|
||||
)
|
||||
max_requested_amount = rent_line_id.estimated_rent_branches if rec.branch_custom_id.branch_type == 'branches' else rent_line_id.estimated_rent_governorate
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
if not rec.exception and not rec.exception_attach:
|
||||
# Validation for 'member' benefit type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'rent':
|
||||
max_requested_amount = rec.service_cat.max_amount_for_student
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Validation for 'family and member' benefit type with 'home_maintenance'
|
||||
if rec.service_cat.service_type == 'home_maintenance':
|
||||
max_requested_amount = rec.service_cat.max_maintenance_amount
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'rent':
|
||||
rent_line_id = rec.service_cat.rent_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id \
|
||||
and r.benefit_count == rec.benefit_member_count
|
||||
)
|
||||
max_requested_amount = rent_line_id.estimated_rent_branches if rec.branch_custom_id.branch_type == 'branches' else rent_line_id.estimated_rent_governorate
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(_("You cannot request this service more than once a year."))
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You cannot request this service with restoration service in the same year."))
|
||||
# Validation for 'family' benefit type with 'home_restoration'
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_restoration':
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_ten_years),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service more than once a ten years."))
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance')
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(
|
||||
_("You cannot request this service with maintenance service in the same year."))
|
||||
if rec.has_money_to_pay_first_payment == 'no':
|
||||
home_restoration_line_id = rec.service_cat.home_restoration_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id)
|
||||
if rec.requested_service_amount > home_restoration_line_id.max_amount:
|
||||
# Validation for 'family and member' benefit type with 'home_maintenance'
|
||||
if rec.service_cat.service_type == 'home_maintenance':
|
||||
max_requested_amount = rec.service_cat.max_maintenance_amount
|
||||
if rec.requested_service_amount > max_requested_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(_("You cannot request this service more than once a year."))
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You cannot request more than %s") % home_restoration_line_id.max_amount
|
||||
)
|
||||
_("You cannot request this service with restoration service in the same year."))
|
||||
# Validation for 'family' benefit type with 'home_restoration'
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_restoration':
|
||||
# Prevent multiple 'home_maintenance' requests within the same year
|
||||
existing_request_restoration = self.search([
|
||||
('date', '>', date_before_ten_years),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'), ('id', '!=', self._origin.id)
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(_("You cannot request this service more than once a ten years."))
|
||||
existing_request_maintenance = self.search([
|
||||
('date', '>', date_before_year),
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_maintenance')
|
||||
], limit=1)
|
||||
if existing_request_maintenance:
|
||||
raise UserError(
|
||||
_("You cannot request this service with maintenance service in the same year."))
|
||||
if rec.has_money_to_pay_first_payment == 'no':
|
||||
home_restoration_line_id = rec.service_cat.home_restoration_lines.filtered(lambda r: r.benefit_category_id.id == rec.family_category.id)
|
||||
if rec.requested_service_amount > home_restoration_line_id.max_amount:
|
||||
raise UserError(
|
||||
_("You cannot request more than %s") % home_restoration_line_id.max_amount
|
||||
)
|
||||
|
||||
# Validation for 'family' benefit type with 'complete_building_house' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'complete_building_house':
|
||||
# Check for existing request of the same type
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'complete_building_house'),
|
||||
], limit=1)
|
||||
if existing_request:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice"))
|
||||
existing_request_restoration = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You Cannot request this service and home restoration twice"))
|
||||
# Validation for 'family' benefit type with 'electrical_devices' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electrical_devices':
|
||||
# Check for existing request of the same type in seven years and not exception or steal
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'electrical_devices'),
|
||||
('date', '>', date_before_seven_years),('device_id','=',rec.device_id.id)
|
||||
], limit=1)
|
||||
if existing_request and not rec.exception_or_steal:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice in seven years"))
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'alternative_housing' and not rec.providing_alternative_housing_based_rent:
|
||||
if rec.requested_service_amount > rec.service_cat.rent_amount_for_alternative_housing:
|
||||
raise UserError(
|
||||
_("You Cannot request amount more than %s") % rec.service_cat.rent_amount_for_alternative_housing)
|
||||
elif rec.rent_period > rec.service_cat.rent_period:
|
||||
raise UserError(
|
||||
_("You Cannot request this service for period more than %s") % rec.service_cat.rent_period)
|
||||
# Validation for 'family' benefit type with 'complete_building_house' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'complete_building_house':
|
||||
# Check for existing request of the same type
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'complete_building_house'),
|
||||
], limit=1)
|
||||
if existing_request:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice"))
|
||||
existing_request_restoration = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
], limit=1)
|
||||
if existing_request_restoration:
|
||||
raise UserError(
|
||||
_("You Cannot request this service and home restoration twice"))
|
||||
# Validation for 'family' benefit type with 'electrical_devices' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electrical_devices':
|
||||
# Check for existing request of the same type in seven years and not exception or steal
|
||||
existing_request = self.search([
|
||||
('family_id', '=', rec.family_id.id),
|
||||
('service_cat.service_type', '=', 'electrical_devices'),
|
||||
('date', '>', date_before_seven_years),('device_id','=',rec.device_id.id)
|
||||
], limit=1)
|
||||
if existing_request and not rec.exception_or_steal:
|
||||
raise UserError(
|
||||
_("You Cannot request this service twice in seven years"))
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'alternative_housing' and not rec.providing_alternative_housing_based_rent:
|
||||
if rec.requested_service_amount > rec.service_cat.rent_amount_for_alternative_housing:
|
||||
raise UserError(
|
||||
_("You Cannot request amount more than %s") % rec.service_cat.rent_amount_for_alternative_housing)
|
||||
elif rec.rent_period > rec.service_cat.rent_period:
|
||||
raise UserError(
|
||||
_("You Cannot request this service for period more than %s") % rec.service_cat.rent_period)
|
||||
|
||||
# Validation for 'family' benefit type with 'home_furnishing' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_furnishing':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_furnishing'),
|
||||
('date', '>', date_before_three_years),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# if self.id:
|
||||
# domain.append(('id', '!=', self.id)) # Exclude current record if already saved
|
||||
# Validation for 'family' benefit type with 'home_furnishing' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_furnishing':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_furnishing'),
|
||||
('date', '>', date_before_three_years),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# if self.id:
|
||||
# domain.append(('id', '!=', self.id)) # Exclude current record if already saved
|
||||
|
||||
# Search for existing requests
|
||||
existing_requests_within_three_years = self.search(domain)
|
||||
# Search for existing requests
|
||||
existing_requests_within_three_years = self.search(domain)
|
||||
|
||||
# Include current record in the calculation
|
||||
total_amount_in_three_years = sum(existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years += sum(self.furnishing_items_ids.mapped('furnishing_cost'))
|
||||
if not rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount:
|
||||
# Include current record in the calculation
|
||||
total_amount_in_three_years = sum(existing_requests_within_three_years.mapped('requested_service_amount'))
|
||||
total_amount_in_three_years += sum(self.furnishing_items_ids.mapped('furnishing_cost'))
|
||||
if not rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
return res
|
||||
if rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount_if_exception:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'electricity_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electricity_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'electricity_bill'),
|
||||
('date', '>', date_before_month),('id', '!=', self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_month = self.search(domain)
|
||||
if existing_requests_within_month:
|
||||
raise UserError(_("You cannot request this service agin in this month"))
|
||||
if rec.requested_service_amount > rec.max_electricity_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount}
|
||||
"You cannot request more than %s") % rec.max_electricity_bill_amount}
|
||||
return res
|
||||
if rec.home_furnishing_exception:
|
||||
if total_amount_in_three_years > rec.service_cat.max_furnishing_amount_if_exception:
|
||||
# Validation for 'family' benefit type with 'water_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'water_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'water_bill'),
|
||||
('date', '>', date_before_year),('id','!=',self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service agin in this year"))
|
||||
if rec.requested_service_amount > rec.max_water_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within 3 years") % rec.service_cat.max_furnishing_amount_if_exception}
|
||||
"You cannot request more than %s") % rec.max_water_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'electricity_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'electricity_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'electricity_bill'),
|
||||
('date', '>', date_before_month),('id', '!=', self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_month = self.search(domain)
|
||||
if existing_requests_within_month:
|
||||
raise UserError(_("You cannot request this service agin in this month"))
|
||||
if rec.requested_service_amount > rec.max_electricity_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_electricity_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'water_bill' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'water_bill':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'water_bill'),
|
||||
('date', '>', date_before_year),('id','!=',self._origin.id)
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service agin in this year"))
|
||||
if rec.requested_service_amount > rec.max_water_bill_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.max_water_bill_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_car' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_car':
|
||||
if rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you had a car"))
|
||||
if rec.benefit_member_count < rec.service_cat.min_count_member:
|
||||
raise UserError(_("You cannot request this service because you are less than %s")%rec.service_cat.min_count_member)
|
||||
if rec.requested_service_amount > rec.service_cat.max_buy_car_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_buy_car_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'recruiting_driver':
|
||||
recruiting_driver_existing_request = self.search([
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_driver'), ('id', '!=', self._origin.id)], limit=1)
|
||||
son_members_above_age = rec.family_id.mapped('member_ids').filtered(lambda x:x.relationn.relation_type == 'son' and x.age > 18)
|
||||
daughter_members_above_age = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'daughter' and x.age > 18)
|
||||
disable_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'mother')
|
||||
work_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'mother' and x.benefit_id.is_mother_work)
|
||||
disable_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'replacement_mother')
|
||||
work_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'replacement_mother' and x.replacement_is_mother_work)
|
||||
if not rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you do not have a car"))
|
||||
if son_members_above_age or daughter_members_above_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service because children above 18 years"))
|
||||
if rec.family_id.add_replacement_mother and not disable_replacement_mother and not work_replacement_mother :
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if not rec.family_id.add_replacement_mother and not disable_mother and not work_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if recruiting_driver_existing_request:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again"))
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_driver_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_recruiting_driver_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'transportation_insurance' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'transportation_insurance':
|
||||
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {
|
||||
'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.max_amount
|
||||
}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'health_care':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'health_care'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
# Validation for 'family' benefit type with 'buy_car' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_car':
|
||||
if rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you had a car"))
|
||||
if rec.benefit_member_count < rec.service_cat.min_count_member:
|
||||
raise UserError(_("You cannot request this service because you are less than %s")%rec.service_cat.min_count_member)
|
||||
if rec.requested_service_amount > rec.service_cat.max_buy_car_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_buy_car_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'recruiting_driver':
|
||||
recruiting_driver_existing_request = self.search([
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_driver'), ('id', '!=', self._origin.id)], limit=1)
|
||||
son_members_above_age = rec.family_id.mapped('member_ids').filtered(lambda x:x.relationn.relation_type == 'son' and x.age > 18)
|
||||
daughter_members_above_age = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'daughter' and x.age > 18)
|
||||
disable_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'mother')
|
||||
work_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'mother' and x.benefit_id.is_mother_work)
|
||||
disable_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'replacement_mother')
|
||||
work_replacement_mother = rec.family_id.mapped('member_ids').filtered(lambda x: x.relationn.relation_type == 'replacement_mother' and x.replacement_is_mother_work)
|
||||
if not rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you do not have a car"))
|
||||
if son_members_above_age or daughter_members_above_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service because children above 18 years"))
|
||||
if rec.family_id.add_replacement_mother and not disable_replacement_mother and not work_replacement_mother :
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if not rec.family_id.add_replacement_mother and not disable_mother and not work_mother:
|
||||
raise UserError(
|
||||
_("You cannot request this service because mother should be worked or has disability"))
|
||||
if recruiting_driver_existing_request:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again"))
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_driver_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_recruiting_driver_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'transportation_insurance' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'transportation_insurance':
|
||||
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {
|
||||
'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.max_amount
|
||||
}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'recruiting_driver' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'debits':
|
||||
if rec.requested_service_amount > rec.service_cat.max_debits_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.max_debits_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'health_care':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'health_care'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
|
||||
# Include current record in the calculation
|
||||
total_amount_in_year = sum(existing_requests_within_year.mapped('requested_service_amount'))
|
||||
total_amount_in_year += rec.requested_service_amount
|
||||
if total_amount_in_year > rec.service_cat.max_health_care_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_health_care_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'recruiting_domestic_worker_or_nurse':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_domestic_worker_or_nurse'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service more than once Within year."))
|
||||
# Include current record in the calculation
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount}
|
||||
return res
|
||||
# Validation for 'member' benefit type with 'marriage' service type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'marriage':
|
||||
if rec.member_age > rec.service_cat.member_max_age:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Age should be less than %s ") % rec.service_cat.member_max_age}
|
||||
return res
|
||||
if rec.member_payroll > rec.service_cat.member_max_payroll:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Payroll should be less than %s ") % rec.service_cat.member_max_payroll}
|
||||
return res
|
||||
if not rec.family_id.mother_marital_conf.is_dead and rec.requested_service_amount > rec.service_cat.fatherless_member_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s ") % rec.service_cat.fatherless_member_amount}
|
||||
return res
|
||||
if rec.family_id.mother_marital_conf.is_dead and rec.requested_service_amount > rec.service_cat.orphan_member_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s ") % rec.service_cat.orphan_member_amount}
|
||||
return res
|
||||
if rec.has_marriage_course == 'no':
|
||||
raise UserError(_("You Should take a course"))
|
||||
# Validation for 'family' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.eid_gift_benefit_count == 0:
|
||||
raise UserError(_("You cannot request this service because family should have members his age less than %s")%rec.service_cat.eid_gift_max_age)
|
||||
# Validation for 'member' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.member_id.age > rec.service_cat.eid_gift_max_age:
|
||||
raise UserError(_("You cannot request this service because your age should be less than %s")%rec.service_cat.eid_gift_max_age)
|
||||
# Validation for 'family and member' benefit type with 'natural_disasters' service type
|
||||
if rec.service_cat.service_type == 'natural_disasters':
|
||||
if rec.requested_service_amount > rec.service_cat.natural_disasters_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message':_("You cannot request more than %s") % rec.service_cat.natural_disasters_max_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'legal_arguments' service type
|
||||
if rec.service_cat.service_type == 'legal_arguments':
|
||||
if rec.requested_service_amount > rec.service_cat.legal_arguments_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.service_cat.legal_arguments_max_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_home' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_home':
|
||||
# Search for existing requests
|
||||
existing_buy_home_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=','buy_home'),
|
||||
('id', '!=', self._origin.id)])
|
||||
existing_home_restoration_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
('id', '!=', self._origin.id)])
|
||||
if rec.requested_service_amount > rec.service_cat.buy_home_max_total_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.buy_home_max_total_amount}
|
||||
return res
|
||||
if existing_buy_home_requests:
|
||||
raise UserError(_("You cannot request this service Again"))
|
||||
if existing_home_restoration_requests:
|
||||
raise UserError(_("You cannot request this service Again Because you request Home restoration service"))
|
||||
if rec.home_age > rec.service_cat.home_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because the home Age More than %s") % rec.service_cat.home_age)
|
||||
# Include current record in the calculation
|
||||
total_amount_in_year = sum(existing_requests_within_year.mapped('requested_service_amount'))
|
||||
total_amount_in_year += rec.requested_service_amount
|
||||
if total_amount_in_year > rec.service_cat.max_health_care_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_health_care_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'health_care' service type
|
||||
if rec.service_cat.service_type == 'recruiting_domestic_worker_or_nurse':
|
||||
# Add current record conditionally
|
||||
domain = [
|
||||
('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'recruiting_domestic_worker_or_nurse'),
|
||||
('date', '>', date_before_year),
|
||||
('id', '!=', self._origin.id),
|
||||
]
|
||||
# Search for existing requests
|
||||
existing_requests_within_year = self.search(domain)
|
||||
if existing_requests_within_year:
|
||||
raise UserError(_("You cannot request this service more than once Within year."))
|
||||
# Include current record in the calculation
|
||||
if rec.requested_service_amount > rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s within year") % rec.service_cat.max_recruiting_domestic_worker_or_nurse_amount}
|
||||
return res
|
||||
# Validation for 'member' benefit type with 'marriage' service type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'marriage':
|
||||
if rec.member_age > rec.service_cat.member_max_age:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Age should be less than %s ") % rec.service_cat.member_max_age}
|
||||
return res
|
||||
if rec.member_payroll > rec.service_cat.member_max_payroll:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"Member Payroll should be less than %s ") % rec.service_cat.member_max_payroll}
|
||||
return res
|
||||
if not rec.family_id.mother_marital_conf.is_dead and rec.requested_service_amount > rec.service_cat.fatherless_member_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s ") % rec.service_cat.fatherless_member_amount}
|
||||
return res
|
||||
if rec.family_id.mother_marital_conf.is_dead and rec.requested_service_amount > rec.service_cat.orphan_member_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s ") % rec.service_cat.orphan_member_amount}
|
||||
return res
|
||||
if rec.has_marriage_course == 'no':
|
||||
raise UserError(_("You Should take a course"))
|
||||
# Validation for 'family' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.eid_gift_benefit_count == 0:
|
||||
raise UserError(_("You cannot request this service because family should have members his age less than %s")%rec.service_cat.eid_gift_max_age)
|
||||
# Validation for 'member' benefit type with 'eid_gift' service type
|
||||
if rec.benefit_type == 'member' and rec.service_cat.service_type == 'eid_gift':
|
||||
if rec.member_id.age > rec.service_cat.eid_gift_max_age:
|
||||
raise UserError(_("You cannot request this service because your age should be less than %s")%rec.service_cat.eid_gift_max_age)
|
||||
# Validation for 'family and member' benefit type with 'natural_disasters' service type
|
||||
if rec.service_cat.service_type == 'natural_disasters':
|
||||
if rec.requested_service_amount > rec.service_cat.natural_disasters_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message':_("You cannot request more than %s") % rec.service_cat.natural_disasters_max_amount}
|
||||
return res
|
||||
# Validation for 'family and member' benefit type with 'legal_arguments' service type
|
||||
if rec.service_cat.service_type == 'legal_arguments':
|
||||
if rec.requested_service_amount > rec.service_cat.legal_arguments_max_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % rec.service_cat.legal_arguments_max_amount}
|
||||
return res
|
||||
# Validation for 'family' benefit type with 'buy_home' service type
|
||||
if rec.benefit_type == 'family' and rec.service_cat.service_type == 'buy_home':
|
||||
# Search for existing requests
|
||||
existing_buy_home_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=','buy_home'),
|
||||
('id', '!=', self._origin.id)])
|
||||
existing_home_restoration_requests = self.search([('family_id', '=', self.family_id.id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
('id', '!=', self._origin.id)])
|
||||
if rec.requested_service_amount > rec.service_cat.buy_home_max_total_amount:
|
||||
self.benefit_type = False
|
||||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _(
|
||||
"You cannot request more than %s") % rec.service_cat.buy_home_max_total_amount}
|
||||
return res
|
||||
if existing_buy_home_requests:
|
||||
raise UserError(_("You cannot request this service Again"))
|
||||
if existing_home_restoration_requests:
|
||||
raise UserError(_("You cannot request this service Again Because you request Home restoration service"))
|
||||
if rec.home_age > rec.service_cat.home_age:
|
||||
raise UserError(
|
||||
_("You cannot request this service Again Because the home Age More than %s") % rec.service_cat.home_age)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,11 +6,9 @@
|
|||
<field name="model">services.settings</field>
|
||||
<field name="inherit_id" ref="odex_benefit.services_settings_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='accountant_id']" position="after">
|
||||
<field name="category_id" attrs="{'invisible': ['|',('is_main_service','=',True),('project_create', '=', False)]}"/>
|
||||
</xpath>
|
||||
<xpath expr="//field[@name='is_this_service_for_student']" position="after">
|
||||
<field name="project_create" attrs="{'invisible':[('is_main_service','=',True)]}"/>
|
||||
<field name="project_create" attrs="{'invisible':[('service_type','=','main_service')]}"/>
|
||||
<field name="category_id" attrs="{'invisible': ['|',('service_type','=','main_service'),('project_create', '=', False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
Loading…
Reference in New Issue