[IMP] odex_benefit: IMP benefit

This commit is contained in:
younes 2025-12-22 13:25:56 +01:00
parent 83285c22de
commit 203653b117
9 changed files with 129 additions and 41 deletions

View File

@ -75,7 +75,6 @@
- **معلومات السكن:** - **معلومات السكن:**
- `housing_type`: نوع السكن (apartment/villa/popular_house/tent) - `housing_type`: نوع السكن (apartment/villa/popular_house/tent)
- `property_type`: نوع الملكية (ownership/rent/charitable/ownership_shared/rent_shared)
- `rent_amount`: مبلغ الإيجار - `rent_amount`: مبلغ الإيجار
- `contract_num`: رقم عقد الإيجار - `contract_num`: رقم عقد الإيجار
- `rent_start_date`: تاريخ بداية الإيجار - `rent_start_date`: تاريخ بداية الإيجار

View File

@ -9029,7 +9029,6 @@ msgstr "زيادة الوزن"
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__ownership_shared #: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__ownership_shared
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__property_type__ownership_shared
msgid "Ownership Shared" msgid "Ownership Shared"
msgstr "سكن مشترك ملك" msgstr "سكن مشترك ملك"
@ -9390,7 +9389,6 @@ msgstr "رقم الصك"
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields,field_description:odex_benefit.field_benefit_housing__property_type #: model:ir.model.fields,field_description:odex_benefit.field_benefit_housing__property_type
#: model:ir.model.fields,field_description:odex_benefit.field_grant_benefit__property_type
msgid "Property Type" msgid "Property Type"
msgstr "نوع العقار" msgstr "نوع العقار"
@ -9875,7 +9873,6 @@ msgstr ""
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__rent_shared #: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__rent_shared
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__property_type__rent_shared
msgid "Rent Shared" msgid "Rent Shared"
msgstr "سكن مشترك إيجار" msgstr "سكن مشترك إيجار"
@ -12617,7 +12614,6 @@ msgstr "طلبات النقل"
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__charitable #: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__charitable
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__property_type__charitable
msgid "charitable" msgid "charitable"
msgstr "وقف خيري" msgstr "وقف خيري"
@ -13361,7 +13357,6 @@ msgstr ""
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__ownership #: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__ownership
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__property_type__ownership
msgid "ownership" msgid "ownership"
msgstr "ملك" msgstr "ملك"
@ -13497,7 +13492,6 @@ msgstr "مرفوض"
#. module: odex_benefit #. module: odex_benefit
#: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__rent #: model:ir.model.fields.selection,name:odex_benefit.selection__benefit_housing__property_type__rent
#: model:ir.model.fields.selection,name:odex_benefit.selection__grant_benefit__property_type__rent
msgid "rent" msgid "rent"
msgstr "إيجار" msgstr "إيجار"

View File

@ -478,6 +478,11 @@ class GrantBenefitProfile(models.Model):
('charitable', 'charitable'), ('charitable', 'charitable'),
('ownership_shared', 'Ownership Shared'), ('ownership_shared', 'Ownership Shared'),
('rent_shared', 'Rent Shared')]) ('rent_shared', 'Rent Shared')])
property_type_id = fields.Many2one('property.type.settings',string="Property Type",tracking=True)
property_type_code = fields.Selection([
('ownership', 'Ownership'),
('rent', 'Rent')
], string="Property Type Code",related='property_type_id.type', store=True)
room_ids = fields.One2many('benefit.housing.rooms', inverse_name='housing_id') room_ids = fields.One2many('benefit.housing.rooms', inverse_name='housing_id')
request_producer_id = fields.Many2one('res.partner',string='Request Producer', compute='_compute_request_producer_id') request_producer_id = fields.Many2one('res.partner',string='Request Producer', compute='_compute_request_producer_id')
request_producer = fields.Many2one('res.partner',string='Request Producer',default=lambda self: self.env.user.partner_id) request_producer = fields.Many2one('res.partner',string='Request Producer',default=lambda self: self.env.user.partner_id)
@ -747,11 +752,11 @@ class GrantBenefitProfile(models.Model):
"You can only archive the family if its status is: Refused, Final Suspension, or Blacklisted." "You can only archive the family if its status is: Refused, Final Suspension, or Blacklisted."
)) ))
@api.depends('rent_amount','property_type','benefit_member_count', 'branch_custom_id.branch_type') @api.depends('rent_amount','property_type_id','benefit_member_count', 'branch_custom_id.branch_type')
def _compute_estimated_rent_amount(self): def _compute_estimated_rent_amount(self):
for rec in self: for rec in self:
estimated_rent_amount = 0.0 estimated_rent_amount = 0.0
if rec.rent_amount > 0 and rec.property_type in ['rent','rent_shared']: if rec.rent_amount > 0 and rec.property_type_id and rec.property_type_code == 'rent':
if rec.branch_custom_id.branch_type == 'branches': if rec.branch_custom_id.branch_type == 'branches':
estimated_rent_amount = self.env['rent.lines'].search( estimated_rent_amount = self.env['rent.lines'].search(
[('benefit_count', '=', rec.benefit_member_count)], order="estimated_rent_branches desc",limit=1).estimated_rent_branches [('benefit_count', '=', rec.benefit_member_count)], order="estimated_rent_branches desc",limit=1).estimated_rent_branches

View File

@ -937,3 +937,21 @@ class HomeFurnishingItems(models.Model):
price_second = fields.Float(string='Price Second') 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") 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') service_request_id = fields.Many2one('service.request',string='Service Request')
class PropertyTypeSettings(models.Model):
_name = 'property.type.settings'
_description = 'Property Type Settings'
_order = 'name'
name = fields.Char(string="Name", required=True)
type = fields.Selection([
('ownership', 'Ownership'),
('rent', 'Rent')
], string="Property Type", required=True)
is_shared = fields.Boolean(string="Shared", default=False)
active = fields.Boolean(string="Active", default=True)
unavailable_service_ids = fields.Many2many(
'services.settings',
string="Unavailable Services",
help="Services that are not available for families or members with this property type"
)

View File

@ -713,8 +713,7 @@ class ServiceRequest(models.Model):
@api.onchange('service_cat', 'family_id') @api.onchange('service_cat', 'family_id')
def _onchange_service_cat(self): def _onchange_service_cat(self):
if self.service_cat.service_type == 'rent' and self.family_id.property_type not in ['rent', if self.service_cat.service_type == 'rent' and self.family_id.property_type_code == 'rent' and self.benefit_type == 'family':
'rent_shared'] and self.benefit_type == 'family':
raise UserError(_("You cannot benefit from this service (property type not rent)")) raise UserError(_("You cannot benefit from this service (property type not rent)"))
@api.onchange('start', 'end', 'rent_start_date', 'rent_end_date', 'payment_type') @api.onchange('start', 'end', 'rent_start_date', 'rent_end_date', 'payment_type')
@ -1091,10 +1090,17 @@ class ServiceRequest(models.Model):
for rec in self: for rec in self:
domain = [('is_seasonal_service', '=', False), ('service_type', '!=', 'main_service'), domain = [('is_seasonal_service', '=', False), ('service_type', '!=', 'main_service'),
('benefit_category_ids', 'in', [rec.family_category.id])] ('benefit_category_ids', 'in', [rec.family_category.id])]
if rec.family_id.property_type not in ['ownership', 'ownership_shared', 'charitable']:
if rec.family_id.property_type_id:
if rec.family_id.property_type_code != 'ownership':
domain.append(('service_type', '!=', 'home_restoration')) domain.append(('service_type', '!=', 'home_restoration'))
else: else:
domain.append(('service_type', '!=', 'buy_home')) domain.append(('service_type', '!=', 'buy_home'))
unavailable_services = rec.family_id.property_type_id.unavailable_service_ids
if unavailable_services:
domain.append(('id', 'not in', unavailable_services.ids))
rec.available_service_cats = rec.available_service_cats.sudo().search(domain) rec.available_service_cats = rec.available_service_cats.sudo().search(domain)
def action_set_to_draft(self): def action_set_to_draft(self):
@ -1233,7 +1239,11 @@ class ServiceRequest(models.Model):
# Determine rent amount based on branch type and property type # Determine rent amount based on branch type and property type
branch_type = rec.family_id.branch_family_id.branch_type branch_type = rec.family_id.branch_family_id.branch_type
is_shared_rent = rec.family_id.property_type == 'rent_shared' is_shared_rent = (
rec.family_id.property_type_id and
rec.family_id.property_type_id.type == 'rent' and
rec.family_id.property_type_id.is_shared
)
if branch_type == 'branches': if branch_type == 'branches':
rec.estimated_rent_amount = item.estimated_rent_branches * ( rec.estimated_rent_amount = item.estimated_rent_branches * (
@ -1249,7 +1259,11 @@ class ServiceRequest(models.Model):
# Determine rent amount based on branch type and property type # Determine rent amount based on branch type and property type
branch_type = rec.family_id.branch_custom_id.branch_type branch_type = rec.family_id.branch_custom_id.branch_type
is_shared_rent = rec.family_id.property_type == 'rent_shared' is_shared_rent = (
rec.family_id.property_type_id and
rec.family_id.property_type_id.type == 'rent' and
rec.family_id.property_type_id.is_shared
)
if branch_type == 'branches': if branch_type == 'branches':
rec.estimated_rent_amount = item.estimated_rent_branches * ( rec.estimated_rent_amount = item.estimated_rent_branches * (

View File

@ -172,3 +172,4 @@ access_expense_researcher,access_expense_researcher,model_benefit_expense_line,o
access_family_bank_report_wizard,access_family_bank_report_wizard,model_family_bank_report_wizard,base.group_user,1,1,1,1 access_family_bank_report_wizard,access_family_bank_report_wizard,model_family_bank_report_wizard,base.group_user,1,1,1,1
access_return_reason,access_return_reason,model_return_reason,base.group_user,1,1,1,1 access_return_reason,access_return_reason,model_return_reason,base.group_user,1,1,1,1
access_return_reason_wizard,access_return_reason_wizard,model_return_reason_wizard,base.group_user,1,1,1,1 access_return_reason_wizard,access_return_reason_wizard,model_return_reason_wizard,base.group_user,1,1,1,1
access_property_type_settings,access_property_type_settings,model_property_type_settings,base.group_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
172 access_family_bank_report_wizard access_family_bank_report_wizard model_family_bank_report_wizard base.group_user 1 1 1 1
173 access_return_reason access_return_reason model_return_reason base.group_user 1 1 1 1
174 access_return_reason_wizard access_return_reason_wizard model_return_reason_wizard base.group_user 1 1 1 1
175 access_property_type_settings access_property_type_settings model_property_type_settings base.group_user 1 1 1 1

View File

@ -760,6 +760,15 @@
<field name="domain">[('is_supporter','=', True)]</field> <field name="domain">[('is_supporter','=', True)]</field>
<field name="context">{'default_is_company':True,'default_is_supporter':True}</field> <field name="context">{'default_is_company':True,'default_is_supporter':True}</field>
</record> </record>
<record id="action_property_type_settings" model="ir.actions.act_window">
<field name="name">Property Type Settings</field>
<field name="res_model">property.type.settings</field>
<field name="view_mode">tree,form</field>
<field name="help" type="html">
<p class="oe_view_nocontent_create">Create the Property Type
</p>
</field>
</record>
<!--###########################################################--> <!--###########################################################-->
<!--Benefit Menus--> <!--Benefit Menus-->
@ -901,12 +910,19 @@
action="member_location_action" action="member_location_action"
sequence="10" sequence="10"
/> />
<menuitem
id="menu_property_type_settings"
name="Property Type Settings"
parent="benefit_tools"
action="action_property_type_settings"
sequence="11"
/>
<menuitem <menuitem
id="family_validation_location" id="family_validation_location"
name="Family Validation Setting" name="Family Validation Setting"
parent="benefit_tools" parent="benefit_tools"
action="family_validation_action" action="family_validation_action"
sequence="11" sequence="12"
/> />
<menuitem id="benefit_category_menu" name="category" parent="menu_benefits_config_organizing" <menuitem id="benefit_category_menu" name="category" parent="menu_benefits_config_organizing"
action="category_action" action="category_action"
@ -988,7 +1004,7 @@
id="menu_benefits_config_benefits" id="menu_benefits_config_benefits"
name="benefits" name="benefits"
parent="benefit_tools" parent="benefit_tools"
sequence="5"/> sequence="6"/>
<menuitem id="res_bank_menu" name="Banks" parent="menu_benefits_config_benefits" action="res_bank_list_action" <menuitem id="res_bank_menu" name="Banks" parent="menu_benefits_config_benefits" action="res_bank_list_action"
sequence="1"/> sequence="1"/>
<!-- <menuitem id="hospital_menu" name="Hospital" parent="menu_benefits_config_benefits" action="hospital_action"--> <!-- <menuitem id="hospital_menu" name="Hospital" parent="menu_benefits_config_benefits" action="hospital_action"-->
@ -1011,7 +1027,7 @@
id="menu_benefits_config_contact" id="menu_benefits_config_contact"
name="contact" name="contact"
parent="benefit_tools" parent="benefit_tools"
sequence="5"/> sequence="7"/>
<menuitem id="sms_config_menu" name="SMS Template" sequence="12" <menuitem id="sms_config_menu" name="SMS Template" sequence="12"
parent="menu_benefits_config_contact" action="benefit_sms_configuration_action"/> parent="menu_benefits_config_contact" action="benefit_sms_configuration_action"/>
<menuitem id="email_menu" name="Email Template" sequence="13" <menuitem id="email_menu" name="Email Template" sequence="13"
@ -1020,7 +1036,7 @@
id="menu_benefits_config_others" id="menu_benefits_config_others"
name="others" name="others"
parent="benefit_tools" parent="benefit_tools"
sequence="6" sequence="8"
/> />
<!-- <menuitem id="main_service_menu" name="Service Types" parent="benefit_tools"--> <!-- <menuitem id="main_service_menu" name="Service Types" parent="benefit_tools"-->
<!-- action="main_service_action" sequence="7"/>--> <!-- action="main_service_action" sequence="7"/>-->

View File

@ -1457,5 +1457,45 @@
</tree> </tree>
</field> </field>
</record> </record>
<record id="view_property_type_settings_tree" model="ir.ui.view">
<field name="name">property.type.settings.tree</field>
<field name="model">property.type.settings</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="type"/>
<field name="is_shared"/>
<field name="unavailable_service_ids" widget="many2many_tags"/>
</tree>
</field>
</record>
<record id="view_property_type_settings_form" model="ir.ui.view">
<field name="name">property.type.settings.form</field>
<field name="model">property.type.settings</field>
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_title">
<h1>
<field placeholder="Name" name="name" class="oe_inline"/>
</h1>
</div>
<group>
<group>
<field name="type"/>
</group>
<group>
<field name="is_shared" widget="boolean_toggle"/>
</group>
</group>
<notebook>
<page string="Unavailable Services">
<field name="unavailable_service_ids"/>
</page>
</notebook>
</sheet>
</form>
</field>
</record>
</data> </data>
</odoo> </odoo>

View File

@ -59,7 +59,7 @@
<field name="branch_custom_id"/> <field name="branch_custom_id"/>
<field name="last_visit_date"/> <field name="last_visit_date"/>
<field name="currency_id"/> <field name="currency_id"/>
<field name="property_type"/> <field name="property_type_id"/>
<field name="total_service_requests"/> <field name="total_service_requests"/>
<field name="city_id"/> <field name="city_id"/>
<field name="non_member_count"/> <field name="non_member_count"/>
@ -454,7 +454,7 @@
attrs="{'invisible': [('state', '!=', 'temporary_suspended')]}" attrs="{'invisible': [('state', '!=', 'temporary_suspended')]}"
groups="odex_benefit.group_benefit_manager"/> groups="odex_benefit.group_benefit_manager"/>
<button name="action_reject_resume" type="object" <button name="action_reject_resume" type="object"
string="Reject Resume" class="oe_highlight" string="Reject Resume" class="btn btn-danger"
attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve','first_approve','family_services_manager'])]}" attrs="{'invisible': ['|',('action_type','not in',['resume_from_final','resume_from_temporary']),('state', 'not in', ['waiting_approve','first_approve','family_services_manager'])]}"
/> />
<button name="action_suspend_refuse" type="object" <button name="action_suspend_refuse" type="object"
@ -1420,30 +1420,31 @@
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="housing_cat" <field name="housing_cat"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="property_type" <field name="property_type_code" invisible="1"/>
<field name="property_type_id" options="{'no_create': True, 'no_create_edit': True,'no_quick_create': True, 'no_open': True}"
attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/> attrs="{'required':[('state','not in',['draft','new'])],'readonly':[('state','not in',['draft','new','complete_info'])]}"/>
<field name="payment_type" <field name="payment_type"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"/>
<field name="rent_amount" <field name="rent_amount"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"/>
<field name="contract_num" <field name="contract_num"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"/>
<field name="rent_start_date" <field name="rent_start_date"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"/>
<field name="rent_end_date" <field name="rent_end_date"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"/>
<field name="rent_attachment" <field name="rent_attachment"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}" attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','rent')]}"
widget="many2many_attachment_preview"/> widget="many2many_attachment_preview"/>
<field name="property_instrument_number" <field name="property_instrument_number"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','ownership'),('property_type','!=','charitable'),('property_type','!=','ownership_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','ownership')]}"/>
<field name="property_instrument_attach" <field name="property_instrument_attach"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','ownership'),('property_type','!=','charitable'),('property_type','!=','ownership_shared')]}" attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','ownership')]}"
widget="many2many_attachment_preview"/> widget="many2many_attachment_preview"/>
<field name="property_instrument_date" <field name="property_instrument_date"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','!=','ownership'),('property_type','!=','charitable'),('property_type','!=','ownership_shared')]}"/> attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','!=','ownership')]}"/>
<field name="electricity_attach" <field name="electricity_attach"
attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type','=',False)]}" attrs="{'readonly':[('state','not in',['draft','new','complete_info'])],'invisible':[('property_type_code','=',False)]}"
widget="many2many_attachment_preview"/> widget="many2many_attachment_preview"/>
</group> </group>
<group string="National address"> <group string="National address">
@ -1618,10 +1619,10 @@
<field name="total_expenses" nolabel="1" widget="monetary" <field name="total_expenses" nolabel="1" widget="monetary"
options="{'currency_field': 'currency_id'}"/> options="{'currency_field': 'currency_id'}"/>
<label for="estimated_rent_amount" <label for="estimated_rent_amount"
attrs="{'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'invisible':[('property_type_code','!=','rent')]}"/>
<field name="estimated_rent_amount" nolabel="1" widget="monetary" <field name="estimated_rent_amount" nolabel="1" widget="monetary"
options="{'currency_field': 'currency_id'}" readonly="1" force_save="1" options="{'currency_field': 'currency_id'}" readonly="1" force_save="1"
attrs="{'invisible':[('property_type','!=','rent'),('property_type','!=','rent_shared')]}"/> attrs="{'invisible':[('property_type_code','!=','rent')]}"/>
<field name="member_income" widget="monetary" <field name="member_income" widget="monetary"
options="{'currency_field': 'currency_id'}" readonly="1" force_save="1"/> options="{'currency_field': 'currency_id'}" readonly="1" force_save="1"/>
<field name="benefit_category_id" readonly="1" force_save="1"/> <field name="benefit_category_id" readonly="1" force_save="1"/>