Merge remote-tracking branch 'origin/dev_odex25_realstate' into dev_odex25_realstate
# Conflicts: # odex25_realstate/property_management/models/end_rental_contract.py
This commit is contained in:
commit
fb5a940c6d
|
|
@ -5,6 +5,7 @@ import calendar
|
|||
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from datetime import date
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from odoo.tools import exception_to_unicode
|
||||
from odoo import models, fields, api, exceptions, tools, _
|
||||
|
|
@ -67,6 +68,17 @@ class RentalContract(models.Model):
|
|||
_inherit = ['mail.thread', 'mail.activity.mixin']
|
||||
_order = "id desc"
|
||||
|
||||
|
||||
@api.depends('date_to', 'state')
|
||||
def _compute_is_today_end_date(self):
|
||||
for record in self:
|
||||
record.is_today_end_date = False
|
||||
if record.date_to and isinstance(record.date_to, date):
|
||||
record.is_today_end_date = record.date_to <= date.today()
|
||||
if record.state == 'renewed':
|
||||
record.is_today_end_date = False
|
||||
|
||||
|
||||
@api.onchange('rent_method')
|
||||
def onchange_rent_method(self):
|
||||
"""
|
||||
|
|
@ -92,7 +104,9 @@ class RentalContract(models.Model):
|
|||
if not self.property_id:
|
||||
self.property_id = False
|
||||
|
||||
|
||||
active = fields.Boolean(default=True)
|
||||
is_today_end_date = fields.Boolean(string="Is Today End Date", compute="_compute_is_today_end_date",)
|
||||
name = fields.Char(string="Name")
|
||||
date = fields.Date(string="Contract Date")
|
||||
seq = fields.Char(string="Sequence", default="/", index=True)
|
||||
|
|
@ -349,7 +363,7 @@ class RentalContract(models.Model):
|
|||
|
||||
def action_review(self):
|
||||
full = True
|
||||
if self.property_id.state in ['reserve', 'rent']:
|
||||
if self.property_id.state in ['reserve', 'rent'] and self.property_id.contract_counts>1:
|
||||
raise exceptions.ValidationError(_("Property is already reserved or rented"))
|
||||
#
|
||||
for units in self.property_id.unit_ids:
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@
|
|||
|
||||
<button name="action_rest_draft" string="RE-SET To Draft"
|
||||
groups="property_management.group_property_manager"
|
||||
states="cancel,submit"
|
||||
states="submit"
|
||||
type="object"/>
|
||||
|
||||
<field name="state" widget="statusbar"/>
|
||||
|
|
|
|||
|
|
@ -60,8 +60,11 @@
|
|||
|
||||
<field name="state" widget="statusbar"
|
||||
statusbar_visible="draft,submit,confirm,review,close,cancel"/>
|
||||
|
||||
</header>
|
||||
<sheet>
|
||||
<field name="is_today_end_date" invisible="1"/> <!-- Add this line -->
|
||||
<widget name="web_ribbon" title="Expired" bg_color="bg-danger" attrs="{'invisible': [('is_today_end_date', '!=', True)]}"/>
|
||||
<h1>
|
||||
<field name="seq" readonly="1"/>
|
||||
</h1>
|
||||
|
|
@ -308,6 +311,8 @@
|
|||
<separator/>
|
||||
|
||||
<filter string="Draft" name="draft" domain="[('state','=','draft')]"/>
|
||||
<separator/>
|
||||
<filter name="expired_contracts" string="Expired" domain="[('date_to', '<', context_today().strftime('%Y-%m-%d'))]"/>
|
||||
<separator/>
|
||||
<filter string="Review" name="review" domain="[('state','in',('submit','review') )]"/>
|
||||
<separator/>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,29 @@ class Property(models.Model):
|
|||
('residential', 'Residential'),
|
||||
('non_residential', 'Non-Residential'),
|
||||
], string="Property Suitability for Residence")
|
||||
contract_counts = fields.Integer(string='Contracts', compute='count_contracts_number')
|
||||
def count_contracts_number(self):
|
||||
contract_count = self.env['rental.contract'].search([('property_id', '=', self.id)])
|
||||
self.contract_counts = len(contract_count)
|
||||
|
||||
def get_contract(self):
|
||||
contract_id = self.env['rental.contract'].search(
|
||||
[('property_id', '=', self.id)])
|
||||
form_id = self.env.ref('property_management.rental_contract_form_view').id
|
||||
list_id = self.env.ref('property_management.rental_contract_list_view').id
|
||||
domain = [('id', 'in', contract_id.ids)]
|
||||
return {
|
||||
'name': _('Rental Contract'),
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'rental.contract',
|
||||
'views': [(list_id, 'tree'), (form_id, 'form')],
|
||||
'type': 'ir.actions.act_window',
|
||||
'target': 'current',
|
||||
'domain': domain,
|
||||
}
|
||||
|
||||
|
||||
|
||||
# @api.model
|
||||
# def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
|
||||
|
|
@ -44,6 +67,28 @@ class Property(models.Model):
|
|||
# res['arch'] = etree.tostring(doc, encoding='unicode')
|
||||
# return res
|
||||
|
||||
@api.onchange('floors_count')
|
||||
def _onchange_no_of_floor(self):
|
||||
if self.floors_count>0:
|
||||
# Clear existing lines
|
||||
self.floor_ids = [(5, 0, 0)]
|
||||
# Create floor records based on the number of floors
|
||||
floors = []
|
||||
for i in range(1, self.floors_count + 1):
|
||||
|
||||
floor_name = _('Floor') + ' ' + str(i) # Construct the floor name
|
||||
|
||||
# Search for the role with the given floor name
|
||||
role_record = self.env['property.role'].search([('name', '=', floor_name)], limit=1)
|
||||
|
||||
if not role_record:
|
||||
# If not found, create a new role with the corresponding name
|
||||
role_record = self.env['property.role'].create({
|
||||
'name': floor_name,
|
||||
})
|
||||
# Append the record to One2many field
|
||||
floors.append((0, 0, {'role_id': role_record.id}))
|
||||
self.floor_ids = floors
|
||||
|
||||
def _compute_maintenance_count(self):
|
||||
for record in self:
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@
|
|||
icon="fa-wrench">
|
||||
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
|
||||
</button>
|
||||
<button width="200" class="oe_stat_button" name="get_contract"
|
||||
type="object"
|
||||
icon="fa-files" attrs="{'invisible':[('state','=','draft')]}">
|
||||
<field string="Contracts" name="contract_counts" widget="statinfo"/>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
<h4>
|
||||
|
|
@ -53,38 +58,38 @@
|
|||
placeholder="Property Name"/>
|
||||
</h1>
|
||||
</div>
|
||||
<group name="p_info" string="Property Info">
|
||||
<group>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" name="p_info" string="Property Info">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="property_state_id" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
|
||||
<field name="management_type" required="1"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="management_type" required="1"/>
|
||||
<field name="owner_id"
|
||||
attrs="{'invisible':[('management_type', '!=', 'include')], 'required':[('management_type','=','include')]}"/>
|
||||
<field name="action_type" required="1"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="action_type" required="1"/>
|
||||
|
||||
</group>
|
||||
<group>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="account_analy_id"/>
|
||||
<field name="market_type"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="property_type_id" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="company_profit" required="1"/>
|
||||
<field name="company_profit_amount" required="1"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="company_profit" required="1"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="company_profit_amount" required="1"/>
|
||||
</group>
|
||||
|
||||
</group>
|
||||
<group name="other_info" colspan="2" col="4">
|
||||
<field name="branch_manager_id" required="1"/>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" name="other_info" colspan="2" col="4">
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="branch_manager_id" required="1"/>
|
||||
<field name="company_id" groups="base.group_multi_company"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
|
||||
<notebook>
|
||||
<page name="location_info" string="Property Face & Location">
|
||||
<group>
|
||||
<group col="4" colspan="2">
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="location_info" string="Property Face & Location">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" col="4" colspan="2">
|
||||
<field name="city_id" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="district_id" required="1" domain="[('city_id','=',city_id)]"
|
||||
|
|
@ -100,7 +105,7 @@
|
|||
<field name="property_face_ids" widget="many2many_tags"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
<group string="Building Length">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" string="Building Length">
|
||||
<field name="north"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="south"
|
||||
|
|
@ -110,7 +115,7 @@
|
|||
<field name="west"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
<group string="Building Street Position">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" string="Building Street Position">
|
||||
<field name="north_street"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="south_street"
|
||||
|
|
@ -122,13 +127,13 @@
|
|||
|
||||
</group>
|
||||
</group>
|
||||
<group string="Note">
|
||||
<field name="note"/>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" string="Note">
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="note"/>
|
||||
</group>
|
||||
</page>
|
||||
<page name="regis_info" string="Registration Info">
|
||||
<group>
|
||||
<group col="4" colspan="2">
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="regis_info" string="Registration Info">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" col="4" colspan="2">
|
||||
<field name="user_id" readonly="1"/>
|
||||
<field name="marketer_id"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
|
|
@ -160,7 +165,7 @@
|
|||
<field name="offered"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
<group colspan="2" col="4">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" colspan="2" col="4">
|
||||
<field name="water_count"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="water_serial"
|
||||
|
|
@ -170,8 +175,8 @@
|
|||
<field name="water_account"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
<group string="Second Water Meter"
|
||||
attrs="{'invisible':['|',('water_count','=','1'),('water_count','=',False)]}">
|
||||
<group string="Second Water Meter"
|
||||
attrs="{'invisible':['|',('water_count','=','1'),('water_count','=',False)],'readonly':[('state','=','approve')]}">
|
||||
<field name="water_serial2"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="water_subscription2"
|
||||
|
|
@ -180,8 +185,8 @@
|
|||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
|
||||
</group>
|
||||
<group string="Third Water Meter"
|
||||
attrs="{'invisible':['|','|',('water_count','=','1'),('water_count','=','2'),('water_count','=',False)]}">
|
||||
<group string="Third Water Meter"
|
||||
attrs="{'invisible':['|','|',('water_count','=','1'),('water_count','=','2'),('water_count','=',False)],'readonly':[('state','=','approve')]}">
|
||||
<field name="water_serial3"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="water_subscription3"
|
||||
|
|
@ -192,14 +197,14 @@
|
|||
</group>
|
||||
</group>
|
||||
</page>
|
||||
<page name="other" string="Other Info">
|
||||
<group col="4" colspan="2">
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="other" string="Other Info">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" col="4" colspan="2">
|
||||
|
||||
<field name="suitability_for_residence"/>
|
||||
<field name="is_new"/>
|
||||
|
||||
</group>
|
||||
<group colspan="2" col="4">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" colspan="2" col="4">
|
||||
<field name="property_age"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
|
||||
|
|
@ -231,20 +236,20 @@
|
|||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
</page>
|
||||
<page name="info_floor" string="Floor Info">
|
||||
<group>
|
||||
<group>
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="info_floor" string="Floor Info">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="floors_count" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
|
||||
</group>
|
||||
<group>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="is_unit_count_fixed"/>
|
||||
<field name="unit_floor_count" required="1"
|
||||
attrs="{'readonly': [('state', '!=', 'draft'), ('unlock', '=', True)],'invisible': [('is_unit_count_fixed', '=', False)]}"/>
|
||||
</group>
|
||||
<field name="floor_ids">
|
||||
<tree editable="bottom">
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="floor_ids">
|
||||
<tree editable="bottom">
|
||||
<field name="role_id"/>
|
||||
<field name="no_of_house" sum="Total House"/>
|
||||
<field name="no_of_shop" sum="Total Shop"/>
|
||||
|
|
@ -255,9 +260,9 @@
|
|||
</field>
|
||||
</group>
|
||||
</page>
|
||||
<page name="unit_info" string="Unit Info">
|
||||
<group>
|
||||
<group>
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="unit_info" string="Unit Info">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="no_units" readonly="1"/>
|
||||
<field name="no_rented_units"/>
|
||||
<field name="no_available_units"/>
|
||||
|
|
@ -266,14 +271,14 @@
|
|||
<field name="uexternal_space"/>
|
||||
<field name="uspace"/>
|
||||
</group>
|
||||
<group>
|
||||
<group attrs="{'readonly':[('state','=','approve')]}">
|
||||
<field name="room_no" readonly="1"/>
|
||||
<field name="hall_no" readonly="1"/>
|
||||
<field name="kitchen_no" readonly="1"/>
|
||||
<field name="bathroom_no" readonly="1"/>
|
||||
</group>
|
||||
</group>
|
||||
<field name="unit_ids">
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="unit_ids">
|
||||
<tree>
|
||||
<field name="seq" readonly="1"/>
|
||||
<field name="name" readonly="1"/>
|
||||
|
|
@ -284,18 +289,18 @@
|
|||
</tree>
|
||||
</field>
|
||||
</page>
|
||||
<page name="prices" string="Prices">
|
||||
<group col="4" colspan="2">
|
||||
<page attrs="{'readonly':[('state','=','approve')]}" name="prices" string="Prices">
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" col="4" colspan="2">
|
||||
<field name="property_space" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
</group>
|
||||
<group col="4" colspan="2">
|
||||
<field name="pur_price"/>
|
||||
<field name="meter_price" required="1"
|
||||
<group attrs="{'readonly':[('state','=','approve')]}" col="4" colspan="2">
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="pur_price"/>
|
||||
<field name="meter_price" required="1"
|
||||
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
|
||||
<field name="rent_price"/>
|
||||
<field name="pur_meter_price"/>
|
||||
<field name="curr_price"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="rent_price"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="pur_meter_price"/>
|
||||
<field attrs="{'readonly':[('state','=','approve')]}" name="curr_price"/>
|
||||
</group>
|
||||
</page>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<odoo>
|
||||
<data>
|
||||
|
||||
<!-- odoo role view -->
|
||||
<record id="role_view_form" model="ir.ui.view">
|
||||
<field name="name">role_view_form</field>
|
||||
<field name="model">property.role</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="role_form">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="name"/>
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
<record id="role_view_tree" model="ir.ui.view">
|
||||
<field name="name">role_view_tree</field>
|
||||
<field name="model">property.role</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="_tree">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
<record id="role_action" model="ir.actions.act_window">
|
||||
<field name="name">role.action.view</field>
|
||||
<field name="res_model">property.role</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
<!-- This Menu Item must have a parent and an action -->
|
||||
<!-- end -->
|
||||
<menuitem name="Real Estate" id="real_estate_main_menu"
|
||||
web_icon="real_estate,static/description/icon.png"/>
|
||||
web_icon="real_estate,static/description/icon.png"/>
|
||||
|
||||
<menuitem name="Real Estate & Units" id="real_estate_menu"
|
||||
parent="real_estate_main_menu" sequence="4"/>
|
||||
parent="real_estate_main_menu" sequence="4"/>
|
||||
|
||||
<menuitem name="Configuration" id="configuration_main_menu"
|
||||
parent="real_estate_main_menu" sequence="4"/>
|
||||
parent="real_estate_main_menu" sequence="4"/>
|
||||
<menuitem id="role_menu" name="Roles" parent="configuration_main_menu" action="role_action" sequence="4"/>
|
||||
|
||||
|
||||
|
||||
</data>
|
||||
|
|
|
|||
Loading…
Reference in New Issue