diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index af2801dbd..bad15c483 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -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): """ @@ -91,8 +103,10 @@ class RentalContract(models.Model): else: 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: diff --git a/odex25_realstate/property_management/views/end_rent_views.xml b/odex25_realstate/property_management/views/end_rent_views.xml index b412c6e81..f06a08926 100644 --- a/odex25_realstate/property_management/views/end_rent_views.xml +++ b/odex25_realstate/property_management/views/end_rent_views.xml @@ -170,7 +170,7 @@ +

@@ -53,38 +58,38 @@ placeholder="Property Name"/>

- - + + - + - + - + - - + + - - + + - - - + + + - + - + - - + + - - - + + + @@ -160,7 +165,7 @@ - + - + - + - - + + - + @@ -231,20 +236,20 @@ attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> - - - + + + - + - - + + @@ -255,9 +260,9 @@ - - - + + + @@ -266,14 +271,14 @@ - + - + @@ -284,18 +289,18 @@ - - + + - - - + + - - - + + + diff --git a/odex25_realstate/real_estate/views/real_estate_menu.xml b/odex25_realstate/real_estate/views/real_estate_menu.xml index 0da7a3e3c..0e9f4e0ba 100644 --- a/odex25_realstate/real_estate/views/real_estate_menu.xml +++ b/odex25_realstate/real_estate/views/real_estate_menu.xml @@ -1,15 +1,46 @@ - - + + + role_view_form + property.role + +
+ + + + + +
+
+
+ + role_view_tree + property.role + + + + + + + + role.action.view + property.role + tree,form + + + + + parent="real_estate_main_menu" sequence="4"/> + parent="real_estate_main_menu" sequence="4"/> + +