[IMP] IMP benefit services
This commit is contained in:
parent
1dc5c16e72
commit
2f53ea7cd7
|
|
@ -8634,7 +8634,6 @@ msgstr "نوع النشاط التالي"
|
|||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__has_marriage_course__no
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__has_money_for_payment__no
|
||||
msgid "No"
|
||||
msgstr "لا"
|
||||
|
||||
|
|
@ -12344,7 +12343,6 @@ msgstr ""
|
|||
|
||||
#. module: odex_benefit
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__has_marriage_course__yes
|
||||
#: model:ir.model.fields.selection,name:odex_benefit.selection__service_request__has_money_for_payment__yes
|
||||
msgid "Yes"
|
||||
msgstr "نعم"
|
||||
|
||||
|
|
|
|||
|
|
@ -105,11 +105,6 @@ class ServiceRequest(models.Model):
|
|||
#Fields for alternative house
|
||||
providing_alternative_housing_based_rent = fields.Boolean(string='Providing alternative housing based on rent')
|
||||
rent_for_alternative_housing = fields.Many2one('services.settings',compute='_get_rent_for_alternative_housing')
|
||||
|
||||
# this field for complete building house service
|
||||
has_money_for_payment_is_appearance = fields.Boolean(string='Has money Field is appearance?',compute='_get_money_for_payment_is_appearance')
|
||||
has_money_for_payment = fields.Selection([('yes', 'Yes'), ('no', 'No')], string='Has money for payment?')
|
||||
max_complete_building_house_amount = fields.Float(string='Max Complete Building House Amount',related='service_cat.max_complete_building_house_amount')
|
||||
#Fields for electrical_devices service
|
||||
device_id = fields.Many2one('electrical.devices',string='Device',domain="[('min_count_member','<=',benefit_member_count),('max_count_member','>=',benefit_member_count)]")
|
||||
vendor_bill = fields.Many2one('account.move')
|
||||
|
|
@ -143,7 +138,7 @@ class ServiceRequest(models.Model):
|
|||
#Eid Gift
|
||||
eid_gift_benefit_count = fields.Integer(string='Eid Gift Benefit Count',compute="_get_eid_gift_benefit_count")
|
||||
#Buy home
|
||||
amount_for_buy_home_for_member_count = fields.Float(string="Amount For Buy Home for member count",compute='_get_amount_for_buy_home')
|
||||
amount_for_buy_home_for_member_count = fields.Float(string="Amount For Buy Home for member count")
|
||||
home_age = fields.Integer(string='Home Age')
|
||||
required_attach = fields.Boolean(string='Required Attach',related='service_cat.required_attach')
|
||||
state = fields.Selection( selection = [
|
||||
|
|
@ -373,14 +368,6 @@ class ServiceRequest(models.Model):
|
|||
if rec.family_id.mother_marital_conf.is_dead:
|
||||
rec.added_amount_if_mother_dead = rec.service_cat.raise_amount_for_orphan
|
||||
|
||||
@api.depends('requested_service_amount', 'max_complete_building_house_amount')
|
||||
def _get_money_for_payment_is_appearance(self):
|
||||
for rec in self:
|
||||
if rec.requested_service_amount and rec.max_complete_building_house_amount and rec.requested_service_amount > rec.max_complete_building_house_amount:
|
||||
rec.has_money_for_payment_is_appearance = True
|
||||
else:
|
||||
rec.has_money_for_payment_is_appearance = False
|
||||
|
||||
def _get_aid_amount(self):
|
||||
for rec in self:
|
||||
if rec.service_type == 'rent':
|
||||
|
|
@ -406,13 +393,6 @@ class ServiceRequest(models.Model):
|
|||
for rec in self:
|
||||
rec.max_amount = rec.requests_counts * rec.service_reason_id.limit_amount
|
||||
|
||||
@api.depends('service_cat','family_id')
|
||||
def _get_amount_for_buy_home(self):
|
||||
for rec in self:
|
||||
rec.amount_for_buy_home_for_member_count = 0
|
||||
if rec.service_type == 'buy_home':
|
||||
rec.amount_for_buy_home_for_member_count = (rec.service_cat.buy_home_lines.filtered(lambda x : x.min_count_member <= rec.benefit_member_count <= rec.benefit_member_count)).amount_for_buy_home
|
||||
|
||||
def action_send_to_researcher(self):
|
||||
for rec in self:
|
||||
rec.state = 'researcher'
|
||||
|
|
@ -536,7 +516,8 @@ class ServiceRequest(models.Model):
|
|||
'home_age',
|
||||
'service_reason_id',
|
||||
'device_id',
|
||||
'requested_quantity'
|
||||
'requested_quantity',
|
||||
'amount_for_buy_home_for_member_count'
|
||||
)
|
||||
def onchange_requested_service_amount(self):
|
||||
res = {}
|
||||
|
|
@ -585,7 +566,8 @@ class ServiceRequest(models.Model):
|
|||
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 service_type == 'home_maintenance':
|
||||
# check if 'home_restoration' service
|
||||
if service_type in ['home_maintenance','complete_building_house','buy_home']:
|
||||
existing_request_restoration = Service.search([
|
||||
('family_id', '=', family_id),
|
||||
('service_cat.service_type', '=', 'home_restoration'),
|
||||
|
|
@ -594,20 +576,34 @@ class ServiceRequest(models.Model):
|
|||
], order='date desc', limit=1)
|
||||
|
||||
if existing_request_restoration and existing_request_restoration.date:
|
||||
restoration_date = existing_request_restoration.date.date()
|
||||
next_allowed_restoration_date = (
|
||||
restoration_date + relativedelta(months=interval)
|
||||
if period == 'months'
|
||||
else restoration_date + relativedelta(years=interval)
|
||||
)
|
||||
|
||||
if today < next_allowed_restoration_date:
|
||||
if service_type == 'buy_home':
|
||||
raise UserError(_(
|
||||
"You cannot request this service together with 'home_restoration' within the same recurrence period."
|
||||
))
|
||||
else:
|
||||
restoration_date = existing_request_restoration.date.date()
|
||||
next_allowed_restoration_date = (
|
||||
restoration_date + relativedelta(months=interval)
|
||||
if period == 'months'
|
||||
else restoration_date + relativedelta(years=interval)
|
||||
)
|
||||
|
||||
if today < next_allowed_restoration_date:
|
||||
raise UserError(_(
|
||||
"You cannot request this service together with 'home_restoration' within the same recurrence period."
|
||||
))
|
||||
if service_type == 'transportation_insurance':
|
||||
if rec.family_id.has_car:
|
||||
raise UserError(_("You cannot request this service because you have a car."))
|
||||
if service_type == 'buy_home':
|
||||
if rec.service_cat.buy_home_max_total_amount < rec.amount_for_buy_home_for_member_count:
|
||||
raise UserError(_(
|
||||
"You can request this service because the total housing amount (%.2f) "
|
||||
"is still under the maximum limit of %.2f."
|
||||
) % (rec.amount_for_buy_home_for_member_count, rec.service_cat.buy_home_max_total_amount))
|
||||
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)
|
||||
|
||||
if allowed:
|
||||
base_domain = [
|
||||
|
|
@ -688,12 +684,15 @@ class ServiceRequest(models.Model):
|
|||
lambda r: r.benefit_category_id.id == rec.family_category.id).mapped('max_amount'),
|
||||
default=0.0)
|
||||
elif max_limit_type == 'category_person':
|
||||
rec.service_max_amount = max(self.service_cat.bill_lines.filtered(
|
||||
lambda x: x.benefit_category_id.id == self.family_category.id and
|
||||
x.min_count_member <= self.benefit_member_count <= x.max_count_member).mapped(
|
||||
rec.service_max_amount = max(rec.service_cat.bill_lines.filtered(
|
||||
lambda x: x.benefit_category_id.id == rec.family_category.id and
|
||||
x.min_count_member <= rec.benefit_member_count <= x.max_count_member).mapped(
|
||||
'max_amount_for_bill'), default=0.0)
|
||||
elif max_limit_type == 'service':
|
||||
pass
|
||||
elif max_limit_type == 'amount_person':
|
||||
rec.service_max_amount = max(rec.service_cat.limit_person_line_ids.filtered(
|
||||
lambda x: x.min_count_member <= rec.benefit_member_count <= x.max_count_member)).amount
|
||||
|
||||
if service_type == 'transportation_insurance':
|
||||
if rec.service_reason_id and rec.requested_service_amount > rec.max_amount:
|
||||
|
|
@ -737,24 +736,6 @@ class ServiceRequest(models.Model):
|
|||
res['warning'] = {'title': _('ValidationError'),
|
||||
'message': _("You cannot request more than %s") % max_requested_amount}
|
||||
return res
|
||||
|
||||
# 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"))
|
||||
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(
|
||||
|
|
@ -857,30 +838,6 @@ class ServiceRequest(models.Model):
|
|||
'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('member_id')
|
||||
def onchange_member_id(self):
|
||||
|
|
@ -905,11 +862,6 @@ class ServiceRequest(models.Model):
|
|||
raise UserError(
|
||||
"The Start Date and End Date must be within the Rent Start Date and Rent End Date range.")
|
||||
|
||||
# @api.onchange('main_service_category', 'sub_service_category', 'benefit_type', 'family_id', 'member_id')
|
||||
# def _reset_service_cat(self):
|
||||
# if self.service_cat:
|
||||
# self.service_cat = False
|
||||
|
||||
@api.depends('family_category','member_id')
|
||||
def _compute_available_service_cats(self):
|
||||
for rec in self:
|
||||
|
|
@ -918,6 +870,8 @@ class ServiceRequest(models.Model):
|
|||
domain = [('service_type', '!=', 'main_service'),('benefit_type','!=','member'),('benefit_category_ids', 'in', [rec.family_category.id])]
|
||||
if rec.family_id.property_type not in ['ownership','ownership_shared','charitable']:
|
||||
domain.append(('service_type','!=','home_restoration'))
|
||||
else:
|
||||
domain.append(('service_type', '!=', 'buy_home'))
|
||||
rec.available_service_cats = rec.available_service_cats.sudo().search(domain)
|
||||
elif rec.benefit_type == 'member' and rec.member_id:
|
||||
domain = [
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ class ServicesSettings(models.Model):
|
|||
benefit_category_ids = fields.Many2many('benefit.category', string='Allowed Categories')
|
||||
account_id = fields.Many2one('account.account',string='Expenses Account',domain="[('user_type_id.id','=',15)]")
|
||||
accountant_id = fields.Many2one('res.users',string='Accountant')
|
||||
#Fields for Complete Building House
|
||||
max_complete_building_house_amount = fields.Float(string='Max Complete Building House Amount')
|
||||
#For Electrical Devices
|
||||
electrical_devices_lines = fields.One2many('electrical.devices','services_settings_id')
|
||||
#Home Furnishing
|
||||
|
|
@ -66,7 +64,7 @@ class ServicesSettings(models.Model):
|
|||
# Legal Arguments
|
||||
legal_arguments_max_amount = fields.Float(string='Legal Arguments Max Amount')
|
||||
#Buy Home
|
||||
buy_home_lines = fields.One2many('buy.home.lines', 'services_settings_id')
|
||||
limit_person_line_ids = fields.One2many('service.limit.person.line', 'services_settings_id')
|
||||
buy_home_max_total_amount = fields.Float(string='Buy Home Max Total Amount')
|
||||
home_age = fields.Integer(string='Home Age')
|
||||
required_attach = fields.Boolean(string='Required Attach')
|
||||
|
|
@ -105,6 +103,7 @@ class ServicesSettings(models.Model):
|
|||
)
|
||||
max_limit_type = fields.Selection([
|
||||
('fixed', 'Fixed Amount'),
|
||||
('amount_person', 'Amount by Individuals'),
|
||||
('category', 'Amount by Category'),
|
||||
('category_person', 'Amount by Category and Individuals'),
|
||||
('region', 'Amount by Region'),
|
||||
|
|
@ -177,12 +176,12 @@ class BillLines(models.Model):
|
|||
max_amount_for_bill = fields.Float(string='Max Amount For Bill')
|
||||
services_settings_id = fields.Many2one('services.settings', string='Services Settings')
|
||||
|
||||
class BuyHomeLines(models.Model):
|
||||
_name = 'buy.home.lines'
|
||||
class ServiceLimitByPersonLine(models.Model):
|
||||
_name = 'service.limit.person.line'
|
||||
|
||||
min_count_member = fields.Integer(string='From')
|
||||
max_count_member = fields.Integer(string='To')
|
||||
amount_for_buy_home = fields.Float(string='Amount For Buy Home')
|
||||
min_count_member = fields.Integer(string='Minimum Number of Persons')
|
||||
max_count_member = fields.Integer(string='Maximum Number of Persons')
|
||||
amount = fields.Float(string='Amount')
|
||||
services_settings_id = fields.Many2one('services.settings', string='Services Settings')
|
||||
|
||||
class TransportationInsurance(models.Model):
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ access_bill_lines,access_bill_lines,model_bill_lines,base.group_user,1,1,1,1
|
|||
access_age_category,access_age_category,model_age_category,base.group_user,1,1,1,1
|
||||
access_complaints_category,access_complaints_category,model_complaints_category,base.group_user,1,1,1,1
|
||||
access_family_complaints,access_family_complaints,model_family_complaints,base.group_user,1,1,1,1
|
||||
access_buy_home_lines,access_buy_home_lines,model_buy_home_lines,base.group_user,1,1,1,1
|
||||
access_service_limit_person_line,access_service_limit_person_line,model_service_limit_person_line,base.group_user,1,1,1,1
|
||||
access_location_settings,access_location_settings,model_location_settings,base.group_user,1,1,1,1
|
||||
access_service_refuse_reason,access_service_refuse_reason,model_service_refuse_reason,base.group_user,1,1,1,1
|
||||
access_service_refuse_reason_wizard,access_service_refuse_reason_wizard,model_service_refuse_reason_wizard,base.group_user,1,1,1,1
|
||||
|
|
|
|||
|
|
|
@ -160,8 +160,7 @@
|
|||
('service_type', 'in', ['marriage', 'eid_gift', 'winter_clothing', 'ramadan_basket']),
|
||||
('service_type', 'in', ['electrical_devices', 'home_furnishing'])
|
||||
]}" force_save="1" required="1"/>
|
||||
<field name="service_max_amount"
|
||||
attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="service_max_amount" force_save="1" readonly="1"/>
|
||||
<field name="exception"
|
||||
attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}"/>
|
||||
<field name="exception_attach" attrs="{'invisible': [('exception', '=', False)]}"
|
||||
|
|
@ -319,15 +318,6 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<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')]}">
|
||||
<group>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,10 @@
|
|||
<field name="max_limit_type"/>
|
||||
<field name="max_amount"
|
||||
attrs="{'invisible': [('max_limit_type', '!=', 'fixed')]}"/>
|
||||
<field name="min_count_member" attrs="{'invisible':[('service_type','!=','buy_car')]}"/>
|
||||
<field name="min_count_member"
|
||||
attrs="{'invisible':[('service_type','!=','buy_car')]}"/>
|
||||
<field name="buy_home_max_total_amount" attrs="{'invisible':['|',('service_type','!=','buy_home'),('max_limit_type', '!=', 'amount_person')]}"/>
|
||||
<field name="home_age" attrs="{'invisible':['|',('service_type','!=','buy_home'),('max_limit_type', '!=', 'amount_person')]}"/>
|
||||
<field name="currency_id" invisible="1"/>
|
||||
</group>
|
||||
<group>
|
||||
|
|
@ -145,12 +148,6 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Complete Building House Settings"
|
||||
attrs="{'invisible':[('service_type','!=','complete_building_house')]}">
|
||||
<group>
|
||||
<field name="max_complete_building_house_amount"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Electrical Devices Settings"
|
||||
attrs="{'invisible':[('service_type','!=','electrical_devices')]}">
|
||||
<field name="electrical_devices_lines" widget="one2many_list">
|
||||
|
|
@ -249,16 +246,13 @@
|
|||
<field name="legal_arguments_max_amount"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Buy Home Settings" attrs="{'invisible':[('service_type','!=','buy_home')]}">
|
||||
<group>
|
||||
<field name="buy_home_max_total_amount"/>
|
||||
<field name="home_age"/>
|
||||
</group>
|
||||
<field name="buy_home_lines" widget="one2many_list">
|
||||
<page string="Amounts by Number of Persons"
|
||||
attrs="{'invisible':['|',('service_type','!=','buy_home'),('max_limit_type', '!=', 'amount_person')]}">
|
||||
<field name="limit_person_line_ids" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="min_count_member"/>
|
||||
<field name="max_count_member"/>
|
||||
<field name="amount_for_buy_home"/>
|
||||
<field name="amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ class ProjectProjectInherit(models.Model):
|
|||
#Fields for 'Home restoration' service and 'alternative_housing' service
|
||||
requested_service_amount = fields.Float(string="Requested Service Amount")
|
||||
is_family_need_evacuate = fields.Boolean(string='Is family need evacuate?')
|
||||
#Fields for 'complete building house' service
|
||||
max_complete_building_house_amount = fields.Float(string='Max Complete Building House Amount')
|
||||
has_money_for_payment_is_appearance = fields.Boolean(string='Has money Field is appearance?')
|
||||
has_money_for_payment = fields.Selection([('yes', 'Yes'), ('no', 'No')], string='Has money for payment?')
|
||||
service_type = fields.Selection(
|
||||
[('rent', 'Rent'), ('home_restoration', 'Home Restoration'), ('alternative_housing', 'Alternative Housing'),
|
||||
('home_maintenance', 'Home Maintenance')
|
||||
|
|
|
|||
|
|
@ -25,9 +25,6 @@ class ServiceRequestInherit(models.Model):
|
|||
'category_id': rec.service_cat.category_id.id,
|
||||
'requested_service_amount': rec.requested_service_amount,
|
||||
'service_type': rec.service_cat.service_type,
|
||||
'max_complete_building_house_amount': rec.max_complete_building_house_amount,
|
||||
'has_money_for_payment_is_appearance': rec.has_money_for_payment_is_appearance,
|
||||
'has_money_for_payment': rec.has_money_for_payment,
|
||||
'department_execute_id': rec.family_id.branch_custom_id.branch.id,
|
||||
'project_latitude': rec.family_id.lat,
|
||||
'project_longitude': rec.family_id.lon,
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@
|
|||
<group>
|
||||
<field name="service_type" readonly="1" force_save="1"/>
|
||||
<field name="requested_service_amount" readonly="1" force_save="1"/>
|
||||
<field name="max_complete_building_house_amount" readonly="1" force_save="1"/>
|
||||
<field name="has_money_for_payment_is_appearance" invisible="1"/>
|
||||
<field name="has_money_for_payment" attrs="{'invisible':[('has_money_for_payment_is_appearance', '=', False)]}" readonly="1" force_save="1"/>
|
||||
</group>
|
||||
</page>
|
||||
</xpath>
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
<field name="rent_period"
|
||||
attrs="{'invisible': [('service_type', '!=', 'alternative_housing')],'required':[('service_type', '=','alternative_housing')]}"/>
|
||||
<field name="project_create" invisible="1"/>
|
||||
<field name="project_id" readonly="1" attrs="{'invisible': [('project_create', '=',False)]}"/>
|
||||
<field name="project_expected_delivery_date" readonly="1" attrs="{'invisible': [('project_create', '=',False)]}"/>
|
||||
<field name="project_id" readonly="1"
|
||||
attrs="{'invisible': ['|',('project_create', '=',False),('project_id', '=',False)]}"/>
|
||||
<field name="project_expected_delivery_date" readonly="1"
|
||||
attrs="{'invisible': ['|',('project_create', '=',False),('project_expected_delivery_date', '=',False)]}"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
|
|
|||
Loading…
Reference in New Issue