Benefit customization
This commit is contained in:
parent
340ca96931
commit
ea37855ba8
|
|
@ -685,7 +685,7 @@ 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')],string='Service Type',related="service_id.service_type")
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing')],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')
|
||||
|
|
@ -23,8 +23,8 @@ class ServiceRequest(models.Model):
|
|||
need_status = fields.Selection(string='Need Status',selection=[('urgent', 'urgent'),('not_urgent', 'Not urgent')])
|
||||
main_service_category = fields.Many2one('services.settings',domain="[('is_main_service','=',True)]",string="Main Service Category")
|
||||
sub_service_category = fields.Many2one('services.settings',domain="[('is_main_service','=',False),('service_type','=',False),('parent_service','=',main_service_category)]",string='Sub Service Category')
|
||||
service_cat = fields.Many2one('services.settings',domain="[('is_main_service','=',False),('service_type','!=',False),('parent_service','=',sub_service_category)]",string='Service Cat.')
|
||||
service_attach = fields.Binary(string="Service Attach")
|
||||
service_cat = fields.Many2one('services.settings',string='Service Cat.')
|
||||
service_attach = fields.Many2many('ir.attachment', 'rel_service_attachment_service_request', 'service_request_id','attachment_id', string='Service Attachment')
|
||||
requested_service_amount = fields.Float(string="Requested Service Amount")
|
||||
estimated_rent_amount = fields.Float(string="Estimated Rent Amount",compute="_get_estimated_rent_amount")
|
||||
paid_rent_amount = fields.Float(string="Paid Rent Amount",compute="_get_paid_rent_amount")
|
||||
|
|
@ -43,7 +43,7 @@ class ServiceRequest(models.Model):
|
|||
'attachment_id', string='Rent Attachment')
|
||||
added_amount_if_mother_dead = fields.Float(string="Added Amount (If mother dead)",compute="_get_added_amount_if_mother_dead")
|
||||
attachment_lines = fields.One2many('service.attachments.settings','service_request_id',related='service_cat.attachment_lines',readonly=False)
|
||||
account_id = fields.Many2one('account.account',string='Expenses Account')
|
||||
account_id = fields.Many2one('account.account',string='Expenses Account',domain="[('user_type_id.id','=',15)]")
|
||||
service_producer_id = fields.Many2one('res.partner',string='Service Producer')
|
||||
is_service_producer = fields.Boolean(string='Is Service Producer?',related='service_cat.is_service_producer')
|
||||
state = fields.Selection([
|
||||
|
|
@ -142,22 +142,21 @@ class ServiceRequest(models.Model):
|
|||
if rec.member_id and rec.member_id.member_location != 'study_inside_saudi_arabia':
|
||||
raise UserError(_("You Cannot request Service if you not study inside Saudi Arabia"))
|
||||
|
||||
# @api.onchange('family_id')
|
||||
# def _onchange_family_id(self):
|
||||
# domain = []
|
||||
# # Check if family_id is set
|
||||
# if self.benefit_type:
|
||||
# # Example condition: check if the family is eligible for benefits
|
||||
# if self.benefit_type == 'family': # Replace with your actual condition
|
||||
# domain = [('benefit_id', '=', self.family_id.id)]
|
||||
# else:
|
||||
# domain = []
|
||||
#
|
||||
# return {
|
||||
# 'domain': {
|
||||
# 'member_id': domain
|
||||
# }
|
||||
# }
|
||||
|
||||
@api.onchange('family_category', 'sub_service_category')
|
||||
def _onchange_service_cat_domain(self):
|
||||
# Build the dynamic domain
|
||||
domain = [
|
||||
'|',
|
||||
('rent_lines.benefit_category_id', 'in', [self.family_category.id]),
|
||||
('home_restoration_lines.benefit_category_id', 'in', [self.family_category.id]),
|
||||
('is_main_service', '=', False),
|
||||
('service_type', '!=', False),
|
||||
('parent_service', '=', self.sub_service_category.id)
|
||||
]
|
||||
# Apply the domain dynamically
|
||||
return {'domain': {'service_cat': domain}}
|
||||
|
||||
def action_set_to_draft(self):
|
||||
for rec in self:
|
||||
rec.state= 'draft'
|
||||
|
|
|
|||
|
|
@ -9,11 +9,15 @@ class ServicesSettings(models.Model):
|
|||
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?')
|
||||
service_type = fields.Selection([('rent', 'Rent')],string='Service Type')
|
||||
service_type = fields.Selection([('rent', 'Rent'),('home_restoration', 'Home Restoration'),('alternative_housing', 'Alternative Housing')],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')
|
||||
attachment_lines = fields.One2many('service.attachments.settings','service_id')
|
||||
#Fields for home restoration
|
||||
home_restoration_lines = fields.One2many('home.restoration.lines','services_settings_id')
|
||||
rent_amount_for_alternative_housing = fields.Float(string='Rent Amount For Alternative Housing')
|
||||
rent_period = fields.Integer('Rent Period')
|
||||
|
||||
class RentLines(models.Model):
|
||||
_name = 'rent.lines'
|
||||
|
|
@ -21,12 +25,13 @@ class RentLines(models.Model):
|
|||
benefit_category_id = fields.Many2one('benefit.category', string='Benefit Category')
|
||||
services_settings_id = fields.Many2one('services.settings', string='Services Settings')
|
||||
benefit_count = fields.Integer('Benefit Count')
|
||||
# branch_type = fields.Selection(
|
||||
# selection=[
|
||||
# ('branches', 'Branches'),
|
||||
# ('governorates', 'Governorates')],
|
||||
# string='Branch Type')
|
||||
estimated_rent_branches = fields.Float(string='Estimated Rent Branches')
|
||||
estimated_rent_governorate = fields.Float(string='Estimated Rent Governorate')
|
||||
# is_shared_housing = fields.Boolean(string='Is Shared Housing?')
|
||||
discount_rate_shared_housing = fields.Float(string='Discount Rate For Shared housing')
|
||||
discount_rate_shared_housing = fields.Float(string='Discount Rate For Shared housing')
|
||||
|
||||
class HomeRestorationLines(models.Model):
|
||||
_name = 'home.restoration.lines'
|
||||
|
||||
benefit_category_id = fields.Many2one('benefit.category', string='Benefit Category')
|
||||
services_settings_id = fields.Many2one('services.settings', string='Services Settings')
|
||||
max_amount = fields.Float(string='Max Amount')
|
||||
|
|
@ -124,4 +124,5 @@ access_exception_wizard,access_exception_wizard,model_exception_wizard,base.grou
|
|||
access_exception_reason,access_exception_reason,model_exception_reason,base.group_user,1,1,1,1
|
||||
access_service_request,access_service_request,model_service_request,base.group_user,1,1,1,1
|
||||
access_marital_status,access_marital_status,model_marital_status,base.group_user,1,1,1,1
|
||||
access_service_attachments_settings,access_service_attachments_settings,model_service_attachments_settings,base.group_user,1,1,1,1
|
||||
access_service_attachments_settings,access_service_attachments_settings,model_service_attachments_settings,base.group_user,1,1,1,1
|
||||
access_home_restoration_lines,access_home_restoration_lines,model_home_restoration_lines,base.group_user,1,1,1,1
|
||||
|
|
|
@ -295,7 +295,7 @@
|
|||
<field name="father_family_name"
|
||||
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" required="1"/>
|
||||
<field name="father_id_number"
|
||||
attrs="{'required':[('state','=','complete_info')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" required="1"/>
|
||||
<field name="father_birth_date"
|
||||
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="father_country_id"
|
||||
|
|
@ -320,7 +320,7 @@
|
|||
<field name="mother_second_name"
|
||||
attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="mother_id_number"
|
||||
attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
attrs="{'readonly':[('state','not in',['draft','complete_info','edit_info'])]}" required="1"/>
|
||||
<field name="mother_birth_date"
|
||||
attrs="{'required':[('state','!=','draft')],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="mother_country_id"
|
||||
|
|
@ -423,7 +423,7 @@
|
|||
<field name="replacement_mother_second_name"
|
||||
attrs="{'required':[('state','!=','draft'),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="replacement_mother_id_number"
|
||||
attrs="{'required':[('state','!=','draft'),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
attrs="{'required':[('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="replacement_mother_birth_date"
|
||||
attrs="{'required':[('state','!=','draft'),('add_replacement_mother','=',True)],'readonly':[('state','not in',['draft','complete_info','edit_info'])]}"/>
|
||||
<field name="replacement_mother_country_id"
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@
|
|||
<field name="member_id" attrs="{'invisible':[('benefit_type','!=','member')],'readonly':[('state','not in',['draft','send_request'])],'required':[('benefit_type','=','member')]}"/>
|
||||
<field name="requested_service_amount" attrs="{'readonly':[('state','not in',['draft','send_request'])]}" required="1"/>
|
||||
<field name="account_id" attrs="{'readonly':[('state','not in',['draft','send_request'])]}"/>
|
||||
<field name="service_producer_id" invisible="1"/>
|
||||
<field name="service_producer_id" attrs="{'readonly':[('state','not in',['draft','send_request'])],'invisible':[('service_producer_id','=',False)]}"/>
|
||||
<field name="is_service_producer" invisible="1"/>
|
||||
<field name="service_producer_id" attrs="{'readonly':[('state','not in',['draft','send_request'])],'invisible':[('is_service_producer','=',False)]}"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="need_status" attrs="{'readonly':[('state','not in',['draft','send_request'])]}"/>
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
<field name="service_cat" attrs="{'readonly':[('state','not in',['draft','send_request'])]}" required="1"/>
|
||||
<field name="date" attrs="{'readonly':[('state','not in',['draft','send_request'])]}"/>
|
||||
<field name="description" attrs="{'readonly':[('state','not in',['draft','send_request'])]}"/>
|
||||
<field name="service_attach" attrs="{'readonly':[('state','not in',['draft','send_request'])]}"/>
|
||||
<field name="service_attach" attrs="{'readonly':[('state','not in',['draft','send_request'])]}" widget="many2many_attachment_preview"/>
|
||||
<field name="service_type" invisible="1"/>
|
||||
</group>
|
||||
</group>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,15 @@
|
|||
</group>
|
||||
</group>
|
||||
<notebook>
|
||||
<page string="Services Attachments Settings">
|
||||
<field name="attachment_lines" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="notes"/>
|
||||
<field name="service_type" invisible="1"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Family Rent Service Settings" attrs="{'invisible':[('service_type','!=','rent')]}">
|
||||
<field name="rent_lines" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
|
|
@ -36,15 +45,20 @@
|
|||
<field name="raise_amount_for_orphan"/>
|
||||
</group>
|
||||
</page>
|
||||
<page string="Services Attachments Settings">
|
||||
<field name="attachment_lines" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="notes"/>
|
||||
<field name="service_type" invisible="1"/>
|
||||
<page string="Home Restoration Service Settings" attrs="{'invisible':[('service_type','!=','home_restoration')]}">
|
||||
<field name="home_restoration_lines" widget="one2many_list">
|
||||
<tree editable="bottom">
|
||||
<field name="benefit_category_id"/>
|
||||
<field name="max_amount"/>
|
||||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page string="Alternative Housing Settings" attrs="{'invisible':[('service_type','!=','alternative_housing')]}">
|
||||
<group>
|
||||
<field name="rent_amount_for_alternative_housing"/>
|
||||
<field name="rent_period"/>
|
||||
</group>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
|
|
|
|||
Loading…
Reference in New Issue