Odex takaful (kafel registration)
This commit is contained in:
parent
786ee30be9
commit
4b5dc4d93c
|
|
@ -685,7 +685,8 @@ class ServiceAttachmentsSettings(models.Model):
|
|||
|
||||
name = fields.Char(string='name')
|
||||
service_attach = fields.Many2many('ir.attachment','rel_service_attachments', 'service_id', 'attach_id',string="Attachment")
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing'),('home_maintenance','Home Maintenance')],string='Service Type',related="service_id.service_type")
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing'),('home_maintenance','Home Maintenance')
|
||||
,('complete_building_house','Complete Building House'),('electrical_devices','Electrical Devices'),('home_furnishing','Home furnishing')],string='Service Type',related="service_id.service_type")
|
||||
service_id = fields.Many2one('services.settings',string='Service')
|
||||
service_request_id = fields.Many2one('service.request',string='Service Request')
|
||||
notes = fields.Text(string='Notes')
|
||||
|
|
@ -694,4 +695,16 @@ class HomeMaintenanceItems(models.Model):
|
|||
_name = 'home.maintenance.items'
|
||||
|
||||
maintenance_items_id = fields.Many2one('home.maintenance.lines', string="Maintenance Items")
|
||||
service_request_id = fields.Many2one('service.request',string='Service Request')
|
||||
service_request_id = fields.Many2one('service.request',string='Service Request')
|
||||
|
||||
class HomeFurnishingItems(models.Model):
|
||||
_name = 'home.furnishing.items'
|
||||
|
||||
home_furnishing_items = fields.Many2one('home.furnishing.lines', string='Furnishing Items')
|
||||
furnishing_cost = fields.Float(string='Furnishing Cost')
|
||||
# max_furnishing_cost = fields.Float(string='Furnishing Cost',related='home_furnishing_items.max_furnishing_amount')
|
||||
price_first = fields.Float(string='Price First')
|
||||
price_first_attach = fields.Many2many('ir.attachment','rel_first_price_attachments', 'furnishing_id', 'attach_id',string="First Price Attachment")
|
||||
price_second = fields.Float(string='Price Second')
|
||||
price_second_attach = fields.Many2many('ir.attachment','rel_second_price_attachments', 'furnishing_id', 'attach_id',string="Second Price Attachment")
|
||||
service_request_id = fields.Many2one('service.request',string='Service Request')
|
||||
|
|
|
|||
|
|
@ -94,6 +94,9 @@ class ServiceRequest(models.Model):
|
|||
vendor_bill = fields.Many2one('account.move')
|
||||
requested_quantity = fields.Integer(string='Requested Quantity')
|
||||
exception_or_steal = fields.Boolean(string='Exception Or Steal?')
|
||||
#Home furnishing Exception
|
||||
home_furnishing_exception = fields.Boolean(string='Exception(Fire Or Steal or Natural disaster)')
|
||||
furnishing_items_ids = fields.One2many('home.furnishing.items','service_request_id', string="Furnishing Items",)
|
||||
state = fields.Selection( selection = [
|
||||
('draft', 'Draft'),
|
||||
('researcher', 'Researcher'),
|
||||
|
|
@ -338,36 +341,21 @@ class ServiceRequest(models.Model):
|
|||
new_month_before_rent_payment_date = rec.new_rent_payment_date - timedelta(days=30)
|
||||
if today_date > new_month_before_rent_payment_date:
|
||||
raise UserError(_("You Should request At least a month ago rent payment date"))
|
||||
# @api.onchange('requested_service_amount','benefit_type','date')
|
||||
# def onchange_requested_service_amount(self):
|
||||
# res = {}
|
||||
# for rec in self:
|
||||
# today = fields.Date.today()
|
||||
# date_before_year = today - timedelta(days=365)
|
||||
# if rec.requested_service_amount and rec.benefit_type == 'member':
|
||||
# max_requested_amount = rec.service_cat.max_amount_for_student
|
||||
# if rec.requested_service_amount > max_requested_amount:
|
||||
# raise UserError(_("You Cannot request More than %s") % max_requested_amount)
|
||||
# if rec.requested_service_amount and rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_maintenance':
|
||||
# max_requested_amount = rec.service_cat.max_maintenance_amount
|
||||
# if rec.requested_service_amount > max_requested_amount:
|
||||
# raise UserError(_("You Cannot request More than %s") % max_requested_amount)
|
||||
# if rec.benefit_type == 'family' and rec.service_cat.service_type == 'home_maintenance':
|
||||
# if self.search([('date','>',date_before_year),('family_id','=',rec.family_id.id)]):
|
||||
# raise UserError(_("You Cannot request this service twice in same year"))
|
||||
# if rec.benefit_type == 'family' and rec.service_cat.service_type == 'complete_building_house':
|
||||
# if self.search([('family_id','=',rec.family_id.id),('service_type','=','complete_building_house'),('id','!=',self._origin.id)]):
|
||||
# self.benefit_type = False
|
||||
# res['warning'] = {'title': _('ValidationError'),
|
||||
# 'message': _("You Cannot request this service twice")}
|
||||
# return res
|
||||
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date','service_cat','family_id','exception_or_steal')
|
||||
@api.onchange('furnishing_items_ids')
|
||||
def _onchange_home_furnishing_cost(self):
|
||||
furnishing_cost_sum = 0
|
||||
for rec in self.furnishing_items_ids:
|
||||
furnishing_cost_sum += rec.furnishing_cost
|
||||
self.requested_service_amount = furnishing_cost_sum
|
||||
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date','service_cat','family_id','exception_or_steal','home_furnishing_exception')
|
||||
def onchange_requested_service_amount(self):
|
||||
res = {}
|
||||
today = fields.Date.today()
|
||||
date_before_year = today - timedelta(days=365)
|
||||
date_before_seven_years = today - relativedelta(years=7)
|
||||
date_before_three_years = today - relativedelta(years=3)
|
||||
date_before_ten_years = today - timedelta(days=3650)
|
||||
for rec in self:
|
||||
# Validation for 'member' benefit type
|
||||
|
|
@ -452,6 +440,39 @@ class ServiceRequest(models.Model):
|
|||
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)
|
||||
]
|
||||
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)
|
||||
|
||||
# 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 += self.requested_service_amount or 0
|
||||
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
|
||||
|
||||
|
||||
@api.onchange('requested_quantity','benefit_type')
|
||||
def onchange_requested_quantity(self):
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ServicesSettings(models.Model):
|
|||
service_producer_id = fields.Many2one('res.partner',string='Service Producer')
|
||||
is_this_service_for_student = fields.Boolean(string='Is Service For Student?')
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing'),('home_maintenance','Home Maintenance')
|
||||
,('complete_building_house','Complete Building House'),('electrical_devices','Electrical Devices')],string='Service Type')
|
||||
,('complete_building_house','Complete Building House'),('electrical_devices','Electrical Devices'),('home_furnishing','Home furnishing')],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')
|
||||
rent_lines = fields.One2many('rent.lines','services_settings_id')
|
||||
|
|
@ -30,6 +30,10 @@ class ServicesSettings(models.Model):
|
|||
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
|
||||
home_furnishing_lines = fields.One2many('home.furnishing.lines','services_settings_id')
|
||||
max_furnishing_amount = fields.Float(string='Max Furnishing Amount')
|
||||
max_furnishing_amount_if_exception = fields.Float(string='Max Furnishing Amount (Exception)')
|
||||
|
||||
class RentLines(models.Model):
|
||||
_name = 'rent.lines'
|
||||
|
|
@ -65,3 +69,11 @@ class ElectricalDevices(models.Model):
|
|||
allowed_quantity = fields.Integer(string='Allowed Quantity')
|
||||
account_id = fields.Many2one('account.account',string='Expenses Account',domain="[('user_type_id.id','=',15)]")
|
||||
services_settings_id = fields.Many2one('services.settings')
|
||||
|
||||
class HomeFurnishingLines(models.Model):
|
||||
_name = 'home.furnishing.lines'
|
||||
|
||||
services_settings_id = fields.Many2one('services.settings')
|
||||
name = fields.Char(string="Furnishing Name")
|
||||
max_furnishing_amount = fields.Float(string='Furnishing Amount')
|
||||
|
||||
|
|
|
|||
|
|
@ -130,4 +130,6 @@ access_home_maintenance_lines,access_home_maintenance_lines,model_home_maintenan
|
|||
access_home_maintenance_items,access_home_maintenance_items,model_home_maintenance_items,base.group_user,1,1,1,1
|
||||
access_exchange_order_wizard,access_exchange_order_wizard,model_exchange_order_wizard,base.group_user,1,1,1,1
|
||||
access_payment_orders,access_payment_orders,model_payment_orders,base.group_user,1,1,1,1
|
||||
access_electrical_devices,access_electrical_devices,model_electrical_devices,base.group_user,1,1,1,1
|
||||
access_electrical_devices,access_electrical_devices,model_electrical_devices,base.group_user,1,1,1,1
|
||||
access_home_furnishing_lines,access_home_furnishing_lines,model_home_furnishing_lines,base.group_user,1,1,1,1
|
||||
access_home_furnishing_items,access_home_furnishing_items,model_home_furnishing_items,base.group_user,1,1,1,1
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<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="service_cat" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="requested_service_amount" attrs="{'readonly':[('state','not in',['draft','researcher','send_request'])]}" required="1"/>
|
||||
<field name="requested_service_amount" attrs="{'readonly':['|',('state','not in',['draft','researcher','send_request']),('service_type','=','home_furnishing')]}" force_save="1" required="1"/>
|
||||
<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"/>
|
||||
|
|
@ -191,6 +191,22 @@
|
|||
<field name="exception_or_steal" widget="boolean_toggle"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Home Furnishing Service" attrs="{'invisible':[('service_type', '!=', 'home_furnishing')]}">
|
||||
<group>
|
||||
<field name="home_furnishing_exception"/>
|
||||
</group>
|
||||
<field name="furnishing_items_ids" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="home_furnishing_items"/>
|
||||
<field name="furnishing_cost"/>
|
||||
<!-- <field name="max_furnishing_cost"/>-->
|
||||
<field name="price_first"/>
|
||||
<field name="price_first_attach" widget="many2many_attachment_preview"/>
|
||||
<field name="price_second"/>
|
||||
<field name="price_second_attach" widget="many2many_attachment_preview"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
<div class="oe_chatter">
|
||||
|
|
|
|||
|
|
@ -94,6 +94,19 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Home furnishing Settings" attrs="{'invisible':[('service_type','!=','home_furnishing')]}">
|
||||
<group>
|
||||
<field name="benefit_category_ids" widget="many2many_tags"/>
|
||||
<field name="max_furnishing_amount"/>
|
||||
<field name="max_furnishing_amount_if_exception"/>
|
||||
</group>
|
||||
<field name="home_furnishing_lines" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="max_furnishing_amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -33,12 +33,13 @@ class ServiceRequestInherit(models.Model):
|
|||
)
|
||||
rec.project_id = project
|
||||
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date', 'service_cat','family_id','device_id','exception_or_steal')
|
||||
@api.onchange('requested_service_amount', 'benefit_type', 'date', 'service_cat','family_id','device_id','exception_or_steal','home_furnishing_exception')
|
||||
def onchange_requested_service_amount(self):
|
||||
res = {}
|
||||
today = fields.Date.today()
|
||||
date_before_year = today - timedelta(days=365)
|
||||
date_before_seven_years = today - relativedelta(years=7)
|
||||
date_before_three_years = today - relativedelta(years=3)
|
||||
date_before_ten_years = today - timedelta(days=3650)
|
||||
for rec in self:
|
||||
# Validation for 'member' benefit type
|
||||
|
|
@ -129,3 +130,33 @@ class ServiceRequestInherit(models.Model):
|
|||
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)
|
||||
]
|
||||
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)
|
||||
|
||||
# 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 += self.requested_service_amount or 0
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue