From f074230f9087173e46ed50d000ae293d924fd71f Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:38:08 +0300 Subject: [PATCH 01/36] Update end_rental_contract.py --- .../models/end_rental_contract.py | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index cbdfbe80b..01c85eeff 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -58,11 +58,11 @@ class EndOfRent(models.Model): 'account_id': end.contract_id.debit_account_id.id, })], - 'line_ids': [(0, 0, {'account_id':end.contract_id.debit_account_id.id, 'debit': 0.0, 'credit': amount, - 'name': end.name + ' - ' + str(end.date), - 'quantity': 1}), - (0, 0, - {'account_id': end.contract_id.accrued_account_id.id , 'debit': amount, 'credit': 0.0, 'quantity': 1})] + # 'line_ids': [(0, 0, {'account_id':end.contract_id.debit_account_id.id, 'debit': 0.0, 'credit': amount, + # 'name': end.name + ' - ' + str(end.date), + # 'quantity': 1}), + # (0, 0, + # {'account_id': end.contract_id.accrued_account_id.id , 'debit': amount, 'credit': 0.0, 'quantity': 1})] } return invoice_vals @@ -84,11 +84,11 @@ class EndOfRent(models.Model): })], - 'line_ids': [(0, 0, {'account_id':end.contract_id.revenue_account_id.id, 'debit': 0.0, 'credit': amount, - 'name': end.name + ' - ' + str(end.date), - 'quantity': 1}), - (0, 0, - {'account_id': end.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})] + # 'line_ids': [(0, 0, {'account_id':end.contract_id.revenue_account_id.id, 'debit': 0.0, 'credit': amount, + # 'name': end.name + ' - ' + str(end.date), + # 'quantity': 1}), + # (0, 0, + # {'account_id': end.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})] } return invoice_vals @@ -109,10 +109,10 @@ class EndOfRent(models.Model): if (rec.remain_amount > 0.0) or (rec.remain_amount > 0.0 and rec.maintenance): invoice_vals = rec._prepare_out_refund_invoice_values(rec, rec.remain_amount) invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - if len(invoice.invoice_line_ids) > 1: - line_id = invoice.invoice_line_ids[1].id - commands = [(2, line_id, 0)] - invoice.write({'invoice_line_ids': commands}) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) rec.invoice_id = invoice.id rec.write({'state': 'done'}) elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: @@ -120,20 +120,20 @@ class EndOfRent(models.Model): elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and rec.maintenance: invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - if len(invoice.invoice_line_ids) > 1: - line_id = invoice.invoice_line_ids[1].id - commands = [(2, line_id, 0)] - invoice.write({'invoice_line_ids': commands}) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) rec.invoice_id = invoice.id rec.write({'state': 'done'}) elif (rec.remain_amount < 0.0) or (rec.remain_amount<0.0 and rec.maintenance): invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - if len(invoice.invoice_line_ids) > 1: - line_id = invoice.invoice_line_ids[1].id - commands = [(2, line_id, 0)] - invoice.write({'invoice_line_ids': commands}) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) rec.invoice_id = invoice.id rec.write({'state': 'done'}) if rec.contract_state == 'before': @@ -281,8 +281,8 @@ class PropertyManagementMaintenance(models.Model): _('Hand Cost') + ' ' + maintenance.name +' '+self.property_id.name+' ' +unit_name+' ' + maintenance.vendor_id.name, 'quantity': 1.0, 'price_unit': self.hand_cost, - 'account_id': payment.contract_id.revenue_account_id.id, - 'analytic_account_id': payment.property_id.account_analy_id.id if payment.property_id.account_analy_id else False, + # 'account_id': maintenance.contract_id.revenue_account_id.id, + 'analytic_account_id': maintenance.property_id.account_analy_id.id if payment.property_id.account_analy_id else False, 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids })) invoice_vals = { @@ -351,6 +351,5 @@ class PropertyManagementMaintenance(models.Model): @api.depends('maintenance_cost', 'hand_cost', 'end_line_ids','end_line_ids.cost', 'end_line_ids.total') def _get_total_amount(self): for rec in self: - # تأكد من إعادة حساب maintenance_cost باستخدام المجموع الصحيح لجميع الأسطر rec.maintenance_cost = sum(line.total for line in rec.end_line_ids) rec.total_amount = rec.maintenance_cost + rec.hand_cost From 04240c6c41bd4fb5b467e70ae7346a1b9b7fff68 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:32:04 +0300 Subject: [PATCH 02/36] Update rental_contract.py --- .../property_management/models/rental_contract.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index af2801dbd..7de50e681 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,11 @@ class RentalContract(models.Model): _inherit = ['mail.thread', 'mail.activity.mixin'] _order = "id desc" + @api.depends('contract_end_date') + def _compute_is_today_end_date(self): + for record in self: + record.is_today_end_date = record.date_to == date.today() + @api.onchange('rent_method') def onchange_rent_method(self): """ @@ -91,8 +97,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) From 43af5e7997cb8d77b7f071d8dfa604c9af1091f4 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:39:00 +0300 Subject: [PATCH 03/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index 9b70a56e9..554c7d11a 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -62,6 +62,7 @@ statusbar_visible="draft,submit,confirm,review,close,cancel"/> +

@@ -94,6 +95,7 @@ + From d404662a79faaa1ac761a6fc882e62546ec5cbdc Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:40:43 +0300 Subject: [PATCH 04/36] Update rental_contract.py --- odex25_realstate/property_management/models/rental_contract.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index 7de50e681..cee62c8f1 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -72,6 +72,8 @@ class RentalContract(models.Model): def _compute_is_today_end_date(self): for record in self: 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): From 4c55cc66707aefa02ecb58e377bcc4521e8e36b0 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 12:51:56 +0300 Subject: [PATCH 05/36] Update rental_contract.py --- odex25_realstate/property_management/models/rental_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index cee62c8f1..eeadcf399 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -68,7 +68,7 @@ class RentalContract(models.Model): _inherit = ['mail.thread', 'mail.activity.mixin'] _order = "id desc" - @api.depends('contract_end_date') + @api.depends('date_to','state') def _compute_is_today_end_date(self): for record in self: record.is_today_end_date = record.date_to == date.today() From 7b87de1bc003c8eaa4ac5fda5b17f76dc0ba0ab8 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:01:55 +0300 Subject: [PATCH 06/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index 554c7d11a..cbaef7eda 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -60,8 +60,10 @@ + +

@@ -95,7 +97,6 @@ - From 358d798a66c55b629da07cc6f5855fab8b24bdca Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:10:41 +0300 Subject: [PATCH 07/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index cbaef7eda..4d947a296 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -64,7 +64,7 @@ - +

From 31a1d1708f914cf3e9162ed31bb338426ae387ac Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 11:03:42 +0300 Subject: [PATCH 11/36] Update rental_contract.py --- odex25_realstate/property_management/models/rental_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index eeadcf399..02727bd05 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -71,7 +71,7 @@ class RentalContract(models.Model): @api.depends('date_to','state') def _compute_is_today_end_date(self): for record in self: - record.is_today_end_date = record.date_to == date.today() + record.is_today_end_date = record.date_to <= date.today() if record.state=='renewed': record.is_today_end_date = False From 799753af6b4b48564c735f8625f77f0bd3ff5ac1 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 12:25:12 +0300 Subject: [PATCH 12/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index 4d947a296..79c0b8157 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -312,6 +312,8 @@ + + From 7f2e3bd4325b57016040c2033305afa7565d12ad Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:06:24 +0300 Subject: [PATCH 13/36] Update internal_property_views.xml --- .../real_estate/views/internal_property_views.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/odex25_realstate/real_estate/views/internal_property_views.xml b/odex25_realstate/real_estate/views/internal_property_views.xml index 0296f5dca..51c0d7901 100644 --- a/odex25_realstate/real_estate/views/internal_property_views.xml +++ b/odex25_realstate/real_estate/views/internal_property_views.xml @@ -39,6 +39,11 @@ icon="fa-wrench"> +

From 87bfae6a14653953d9f16acf106a297a4256c8bf Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:13:32 +0300 Subject: [PATCH 14/36] Update internal_property.py --- .../real_estate/models/internal_property.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/odex25_realstate/real_estate/models/internal_property.py b/odex25_realstate/real_estate/models/internal_property.py index ff6c7217d..1dd5d8d72 100644 --- a/odex25_realstate/real_estate/models/internal_property.py +++ b/odex25_realstate/real_estate/models/internal_property.py @@ -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): From 7a1999a7f92e1f15f14532c7d02c913ae38e03a4 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:20:24 +0300 Subject: [PATCH 15/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index 79c0b8157..b954e1003 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -312,8 +312,8 @@ - - + + From 760e86d1f2243d6fe6e8af11619becc17d149220 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:28:22 +0300 Subject: [PATCH 16/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index b954e1003..061079892 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -312,7 +312,7 @@ - + From ad796ca6183e712543e1a16fd53a10a6a45860c9 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Sun, 29 Sep 2024 13:29:02 +0300 Subject: [PATCH 17/36] Update rental_contract_views.xml --- .../property_management/views/rental_contract_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml index 061079892..74d273e45 100644 --- a/odex25_realstate/property_management/views/rental_contract_views.xml +++ b/odex25_realstate/property_management/views/rental_contract_views.xml @@ -63,7 +63,7 @@ - +

From bf6e554853a4d64d3785cd5ba330af7262544f05 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Wed, 2 Oct 2024 16:35:21 +0300 Subject: [PATCH 18/36] Update rental_contract.py --- .../property_management/models/rental_contract.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index 02727bd05..dc0b58c66 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -68,13 +68,16 @@ class RentalContract(models.Model): _inherit = ['mail.thread', 'mail.activity.mixin'] _order = "id desc" - @api.depends('date_to','state') + + @api.depends('date_to', 'state') def _compute_is_today_end_date(self): for record in self: - record.is_today_end_date = record.date_to <= date.today() - if record.state=='renewed': + 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): """ From 7b32ef8e5ce47fa347b33e302f827e7a2fcf7261 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Wed, 2 Oct 2024 17:50:24 +0300 Subject: [PATCH 19/36] Update rental_contract.py --- odex25_realstate/property_management/models/rental_contract.py | 1 + 1 file changed, 1 insertion(+) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index dc0b58c66..c7a47346b 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -72,6 +72,7 @@ class RentalContract(models.Model): @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': From fd7f96152e123387c935327d2abaac3e8d8bb44b Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:19:56 +0300 Subject: [PATCH 20/36] Update rental_contract.py --- odex25_realstate/property_management/models/rental_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py index c7a47346b..bad15c483 100644 --- a/odex25_realstate/property_management/models/rental_contract.py +++ b/odex25_realstate/property_management/models/rental_contract.py @@ -363,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: From 25929a82b8ae7bf48c969dd9cdf0bbc94aa52b72 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:34:48 +0300 Subject: [PATCH 21/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 01c85eeff..caf68f30f 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -252,7 +252,7 @@ class PropertyManagementMaintenance(models.Model): request_id = fields.Many2one('sale.order', string="Request Item") def action_rest_draft(self): - rec.write({'state': 'draft'}) + self.write({'state': 'draft'}) @api.onchange('renter_invoice') @@ -282,7 +282,7 @@ class PropertyManagementMaintenance(models.Model): 'quantity': 1.0, 'price_unit': self.hand_cost, # 'account_id': maintenance.contract_id.revenue_account_id.id, - 'analytic_account_id': maintenance.property_id.account_analy_id.id if payment.property_id.account_analy_id else False, + 'analytic_account_id': maintenance.property_id.account_analy_id.id if maintenance.property_id.account_analy_id else False, 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids })) invoice_vals = { From 405aaffa9ad804c3a3b395d42d271b86edf2ad9c Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:36:16 +0300 Subject: [PATCH 22/36] Update end_rent_views.xml --- odex25_realstate/property_management/views/end_rent_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@

- - + + - + - + - + - - + + - - + + - - - + + + - + - + - - + + - - - + + + @@ -165,7 +165,7 @@ - + - @@ -185,7 +185,7 @@ attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> - @@ -197,14 +197,14 @@ - - + + - + @@ -236,20 +236,20 @@ attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> - - - + + + - + - - + + @@ -260,9 +260,9 @@ - - - + + + @@ -271,14 +271,14 @@ - + - + @@ -289,18 +289,18 @@ - - + + - - - + + - - - + + + From bddf6704b67bbd6d0f7eb71ffaa4fde1ec67db97 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:19:21 +0300 Subject: [PATCH 26/36] Update internal_property_views.xml --- .../real_estate/views/internal_property_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odex25_realstate/real_estate/views/internal_property_views.xml b/odex25_realstate/real_estate/views/internal_property_views.xml index 3232c89f8..4e25cafbe 100644 --- a/odex25_realstate/real_estate/views/internal_property_views.xml +++ b/odex25_realstate/real_estate/views/internal_property_views.xml @@ -175,8 +175,8 @@ - + Date: Thu, 3 Oct 2024 21:22:01 +0300 Subject: [PATCH 27/36] Update internal_property_views.xml --- .../real_estate/views/internal_property_views.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odex25_realstate/real_estate/views/internal_property_views.xml b/odex25_realstate/real_estate/views/internal_property_views.xml index 4e25cafbe..e68af9725 100644 --- a/odex25_realstate/real_estate/views/internal_property_views.xml +++ b/odex25_realstate/real_estate/views/internal_property_views.xml @@ -185,8 +185,8 @@ attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> - + Date: Thu, 3 Oct 2024 21:25:55 +0300 Subject: [PATCH 28/36] Update internal_property_views.xml --- odex25_realstate/real_estate/views/internal_property_views.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/real_estate/views/internal_property_views.xml b/odex25_realstate/real_estate/views/internal_property_views.xml index e68af9725..f9e997c2a 100644 --- a/odex25_realstate/real_estate/views/internal_property_views.xml +++ b/odex25_realstate/real_estate/views/internal_property_views.xml @@ -296,7 +296,7 @@ - From d8513d782cbaa5341095066315cde2f001783871 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:40:09 +0300 Subject: [PATCH 29/36] Update end_rental_contract.py --- .../models/end_rental_contract.py | 124 ++++++++++-------- 1 file changed, 69 insertions(+), 55 deletions(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 850417f6d..868ec4b6c 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -41,33 +41,7 @@ class EndOfRent(models.Model): note = fields.Text(string="Note") invoice_id = fields.Many2one('account.move', string="Invoice") - def _prepare_out_refund_invoice_values(self, end, amount): - self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id - invoice_vals = { - 'ref': end.name, - 'move_type': 'out_refund', - 'invoice_origin': _('Insurance Refund') + ' ' + end.name + ' ' + end.contract_id.partner_id.name, - 'invoice_user_id': end.user_id.id, - 'invoice_date': end.date, - 'narration': end.note, - 'partner_id': end.contract_id.partner_id.id, - 'invoice_line_ids': [(0, 0, { - 'name': end.name + ' - ' + str(end.date), - 'price_unit': amount, - 'quantity': 1.0, - 'account_id': end.contract_id.debit_account_id.id, - - })], - # 'line_ids': [(0, 0, {'account_id':end.contract_id.debit_account_id.id, 'debit': 0.0, 'credit': amount, - # 'name': end.name + ' - ' + str(end.date), - # 'quantity': 1}), - # (0, 0, - # {'account_id': end.contract_id.accrued_account_id.id , 'debit': amount, 'credit': 0.0, 'quantity': 1})] - } - return invoice_vals - def _prepare_invoice_values(self, end, amount): - self.contract_id.partner_id.property_account_receivable_id = end.contract_id.debit_account_id.id invoice_vals = { 'ref': end.name, 'move_type': 'out_invoice', @@ -80,18 +54,31 @@ class EndOfRent(models.Model): 'name': end.name + ' - ' + str(end.date), 'price_unit': amount, 'quantity': 1.0, - 'account_id': end.contract_id.revenue_account_id.id, - })], - # 'line_ids': [(0, 0, {'account_id':end.contract_id.revenue_account_id.id, 'debit': 0.0, 'credit': amount, - # 'name': end.name + ' - ' + str(end.date), - # 'quantity': 1}), - # (0, 0, - # {'account_id': end.contract_id.debit_account_id.id, 'debit': amount, 'credit': 0.0, 'quantity': 1})] } return invoice_vals + def _prepare_out_refund_invoice_values(self, end, amount): + invoice_vals = { + 'ref': end.name, + 'move_type': 'out_refund', + 'invoice_origin': _('Insurance Refund') + ' ' + end.name + ' ' + end.contract_id.partner_id.name, + 'invoice_user_id': end.user_id.id, + 'invoice_date': end.date, + 'narration': end.note, + 'partner_id': end.contract_id.partner_id.id, + 'invoice_line_ids': [(0, 0, { + 'name': end.name + ' - ' + str(end.date), + 'price_unit': amount, + 'quantity': 1.0, + + })], + } + return invoice_vals + + + @api.depends('insurance_amount', 'total_amount') def get_remain_amount(self): for rec in self: @@ -103,37 +90,21 @@ class EndOfRent(models.Model): def action_cancel(self): if self.state not in ['check', 'done']: self.write({'state': 'cancel'}) - + def action_done(self): for rec in self: - if (rec.remain_amount > 0.0) or (rec.remain_amount > 0.0 and rec.maintenance): + if rec.remain_amount > 0.0: invoice_vals = rec._prepare_out_refund_invoice_values(rec, rec.remain_amount) invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - # if len(invoice.invoice_line_ids) > 1: - # line_id = invoice.invoice_line_ids[1].id - # commands = [(2, line_id, 0)] - # invoice.write({'invoice_line_ids': commands}) - rec.invoice_id = invoice.id - rec.write({'state': 'done'}) - elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: - rec.write({'state': 'done'}) - elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and rec.maintenance: - invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) - invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - # if len(invoice.invoice_line_ids) > 1: - # line_id = invoice.invoice_line_ids[1].id - # commands = [(2, line_id, 0)] - # invoice.write({'invoice_line_ids': commands}) rec.invoice_id = invoice.id rec.write({'state': 'done'}) - elif (rec.remain_amount < 0.0) or (rec.remain_amount<0.0 and rec.maintenance): + elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: + rec.write({'state': 'done'}) + + elif rec.remain_amount < 0.0: invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) - # if len(invoice.invoice_line_ids) > 1: - # line_id = invoice.invoice_line_ids[1].id - # commands = [(2, line_id, 0)] - # invoice.write({'invoice_line_ids': commands}) rec.invoice_id = invoice.id rec.write({'state': 'done'}) if rec.contract_state == 'before': @@ -146,6 +117,49 @@ class EndOfRent(models.Model): unit.write({'state': 'available'}) rec.contract_id.write({'state': 'close'}) + + # def action_done(self): + # for rec in self: + # if (rec.remain_amount > 0.0) or (rec.remain_amount > 0.0 and rec.maintenance): + # invoice_vals = rec._prepare_out_refund_invoice_values(rec, rec.remain_amount) + # invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) + # rec.invoice_id = invoice.id + # rec.write({'state': 'done'}) + # elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: + # rec.write({'state': 'done'}) + # elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and rec.maintenance: + # invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) + # invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) + # rec.invoice_id = invoice.id + # rec.write({'state': 'done'}) + + # elif (rec.remain_amount < 0.0) or (rec.remain_amount<0.0 and rec.maintenance): + # invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) + # invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) + # if len(invoice.invoice_line_ids) > 1: + # line_id = invoice.invoice_line_ids[1].id + # commands = [(2, line_id, 0)] + # invoice.write({'invoice_line_ids': commands}) + # rec.invoice_id = invoice.id + # rec.write({'state': 'done'}) + # if rec.contract_state == 'before': + # for rent_payment in rec.rent_payment_ids: + # if rent_payment.due_date > rec.date and rent_payment.state != 'paid': + # rent_payment.write({'state': 'cancel'}) + # elif rent_payment.due_date < rec.date and rent_payment.state != 'paid': + # rent_payment.write({'state': 'cancel'}) + # for unit in rec.contract_id.unit_ids: + # unit.write({'state': 'available'}) + # rec.contract_id.write({'state': 'close'}) + def action_check(self): for rec in self: if rec.contract_state == 'before': From aab63f1309e241f23c8c8718d10afe340bab55ed Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:42:56 +0300 Subject: [PATCH 30/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 868ec4b6c..93767bbd3 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -99,7 +99,7 @@ class EndOfRent(models.Model): rec.invoice_id = invoice.id rec.write({'state': 'done'}) - elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: + elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: rec.write({'state': 'done'}) elif rec.remain_amount < 0.0: From 7b855b7f8fec15ad1a472395f95da1ddf9826154 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:54:52 +0300 Subject: [PATCH 31/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 93767bbd3..00fe8ee09 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -101,6 +101,12 @@ class EndOfRent(models.Model): elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and not rec.maintenance: rec.write({'state': 'done'}) + + elif (rec.insurance_amount == 0.0 or rec.remain_amount==0.0) and rec.maintenance: + invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) + invoice = self.env['account.move'].sudo().create(invoice_vals).with_user(self.env.uid) + rec.invoice_id = invoice.id + rec.write({'state': 'done'}) elif rec.remain_amount < 0.0: invoice_vals = rec._prepare_invoice_values(rec, abs(rec.remain_amount)) From 2471fa21608615b17b68f3c8dfd21ae7cb087e55 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:03:38 +0300 Subject: [PATCH 32/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 00fe8ee09..935b4c849 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -42,6 +42,7 @@ class EndOfRent(models.Model): invoice_id = fields.Many2one('account.move', string="Invoice") def _prepare_invoice_values(self, end, amount): + self.contract_id.partner_id.property_account_receivable_id = end.contract_id.debit_account_id.id invoice_vals = { 'ref': end.name, 'move_type': 'out_invoice', @@ -54,12 +55,14 @@ class EndOfRent(models.Model): 'name': end.name + ' - ' + str(end.date), 'price_unit': amount, 'quantity': 1.0, + 'account_id': end.contract_id.revenue_account_id.id, })], } return invoice_vals def _prepare_out_refund_invoice_values(self, end, amount): + self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id invoice_vals = { 'ref': end.name, 'move_type': 'out_refund', @@ -72,6 +75,7 @@ class EndOfRent(models.Model): 'name': end.name + ' - ' + str(end.date), 'price_unit': amount, 'quantity': 1.0, + 'account_id': end.contract_id.debit_account_id.id, })], } From 8ce9c45a98b640164eeeb81d756ebbb2411f3926 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:07:14 +0300 Subject: [PATCH 33/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 935b4c849..48db25bd9 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -62,7 +62,7 @@ class EndOfRent(models.Model): return invoice_vals def _prepare_out_refund_invoice_values(self, end, amount): - self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id + # self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id invoice_vals = { 'ref': end.name, 'move_type': 'out_refund', From 57ab6d88496b422774ef26a4e8af3eafc0b6d742 Mon Sep 17 00:00:00 2001 From: zainab2097 <149927291+zainab2097@users.noreply.github.com> Date: Thu, 3 Oct 2024 22:08:57 +0300 Subject: [PATCH 34/36] Update end_rental_contract.py --- .../property_management/models/end_rental_contract.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odex25_realstate/property_management/models/end_rental_contract.py b/odex25_realstate/property_management/models/end_rental_contract.py index 48db25bd9..7aeaed37b 100644 --- a/odex25_realstate/property_management/models/end_rental_contract.py +++ b/odex25_realstate/property_management/models/end_rental_contract.py @@ -62,7 +62,7 @@ class EndOfRent(models.Model): return invoice_vals def _prepare_out_refund_invoice_values(self, end, amount): - # self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id + self.contract_id.partner_id.property_account_receivable_id = end.contract_id.accrued_account_id.id invoice_vals = { 'ref': end.name, 'move_type': 'out_refund', @@ -75,7 +75,7 @@ class EndOfRent(models.Model): 'name': end.name + ' - ' + str(end.date), 'price_unit': amount, 'quantity': 1.0, - 'account_id': end.contract_id.debit_account_id.id, + # 'account_id': end.contract_id.debit_account_id.id, })], } From b63e092c565d1e5bb837337f08c194ba7428f360 Mon Sep 17 00:00:00 2001 From: zainab8585 Date: Mon, 7 Oct 2024 12:49:42 +0200 Subject: [PATCH 35/36] [UPDATE]UPDATE floor base on count --- .../real_estate/models/internal_property.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/odex25_realstate/real_estate/models/internal_property.py b/odex25_realstate/real_estate/models/internal_property.py index 1dd5d8d72..d95281299 100644 --- a/odex25_realstate/real_estate/models/internal_property.py +++ b/odex25_realstate/real_estate/models/internal_property.py @@ -67,7 +67,29 @@ 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: record.maintenance_count = self.env['property.management.maintenance'].search_count([ From 122e6335e9718c1793d3fe780f604a15cf55cf03 Mon Sep 17 00:00:00 2001 From: zainab8585 Date: Mon, 7 Oct 2024 12:55:59 +0200 Subject: [PATCH 36/36] [UPDATE]UPDATE --- .../real_estate/views/real_estate_menu.xml | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) 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"/> + +