Merge pull request #1608 from expsa/odex25_realstate_dev

modifications on units and contract
This commit is contained in:
esraa8mostafa 2024-10-23 11:29:14 +03:00 committed by GitHub
commit f31117b64b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 86 additions and 45 deletions

View File

@ -78,6 +78,12 @@ class RentalContract(models.Model):
if record.state == 'renewed': if record.state == 'renewed':
record.is_today_end_date = False record.is_today_end_date = False
@api.onchange('unit_ids')
def get_units_accounts(self):
self.journal_id = self.unit_ids.journal_id
self.debit_account_id = self.unit_ids.debit_account_id
self.accrued_account_id = self.unit_ids.accrued_account_id
self.revenue_account_id = self.unit_ids.revenue_account_id
@api.onchange('rent_method') @api.onchange('rent_method')
def onchange_rent_method(self): def onchange_rent_method(self):

View File

@ -90,6 +90,22 @@ msgstr ""
"<span class=\"o_stat_text\" attrs=\"{'invisible': [('unlock', '=', False)]}\">فتح</span>\n" "<span class=\"o_stat_text\" attrs=\"{'invisible': [('unlock', '=', False)]}\">فتح</span>\n"
" <span class=\"o_stat_text\" attrs=\"{'invisible': [('unlock', '=', True)]}\">إغلاق</span>" " <span class=\"o_stat_text\" attrs=\"{'invisible': [('unlock', '=', True)]}\">إغلاق</span>"
#. module: real_estate
#: model_terms:ir.ui.view,arch_db:real_estate.unit_form_view
msgid "Accounts"
msgstr "الحسابات"
#. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__accrued_account_id
#: model:ir.model.fields,field_description:real_estate.field_re_unit__debit_account_id
msgid "Accrued Account"
msgstr "تأمين لدى الغير"
#. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__debit_account_id
msgid "Debit Account"
msgstr "حساب المدين"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_internal_property__message_needaction #: model:ir.model.fields,field_description:real_estate.field_internal_property__message_needaction
#: model:ir.model.fields,field_description:real_estate.field_internal_property_type__message_needaction #: model:ir.model.fields,field_description:real_estate.field_internal_property_type__message_needaction
@ -509,6 +525,12 @@ msgstr "سعر متر المساحة الخارجية"
msgid "External Space" msgid "External Space"
msgstr "المساحة الخارجية" msgstr "المساحة الخارجية"
#. module: real_estate
#: model_terms:ir.ui.view,arch_db:real_estate.property_form_view
#: model_terms:ir.ui.view,arch_db:real_estate.unit_form_view
msgid "First Stamping"
msgstr "الصك الأول"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields.selection,name:real_estate.selection__internal_property__company_profit__number #: model:ir.model.fields.selection,name:real_estate.selection__internal_property__company_profit__number
msgid "Fixed amount" msgid "Fixed amount"
@ -706,6 +728,11 @@ msgstr "هل العقار جديد؟"
msgid "Is Unit Count Fixed in Floor" msgid "Is Unit Count Fixed in Floor"
msgstr "هل عدد الوحدات ثابت في الأدوار؟" msgstr "هل عدد الوحدات ثابت في الأدوار؟"
#. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__journal_id
msgid "Journal"
msgstr "القيد"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_internal_property_type__is_land #: model:ir.model.fields,field_description:real_estate.field_internal_property_type__is_land
msgid "Land" msgid "Land"
@ -1454,6 +1481,11 @@ msgstr "المستخدم"
msgid "Responsible User" msgid "Responsible User"
msgstr "المستخدم المسئول" msgstr "المستخدم المسئول"
#. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__revenue_account_id
msgid "Revenue Account"
msgstr "حساب اﻹيراد"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__role_id #: model:ir.model.fields,field_description:real_estate.field_re_unit__role_id
msgid "Role" msgid "Role"
@ -1571,7 +1603,7 @@ msgstr "مرفق الصك الجديد"
#: model:ir.model.fields,field_description:real_estate.field_internal_property__stamping_count #: model:ir.model.fields,field_description:real_estate.field_internal_property__stamping_count
#: model:ir.model.fields,field_description:real_estate.field_re_unit__stamping_count #: model:ir.model.fields,field_description:real_estate.field_re_unit__stamping_count
msgid "Stamping Count" msgid "Stamping Count"
msgstr "رقم الصك" msgstr "عدد الصكوك"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_internal_property__stamping_date #: model:ir.model.fields,field_description:real_estate.field_internal_property__stamping_date
@ -1749,7 +1781,7 @@ msgstr "معلومات الوحدة"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__unit_market_type #: model:ir.model.fields,field_description:real_estate.field_re_unit__unit_market_type
msgid "Unit Market Type" msgid "Unit Market Type"
msgstr "نوع العقار" msgstr "صفة العقار"
#. module: real_estate #. module: real_estate
#: model:ir.model.fields,field_description:real_estate.field_re_unit__name #: model:ir.model.fields,field_description:real_estate.field_re_unit__name

View File

@ -464,14 +464,3 @@ class PropertyUnitDetails(models.Model):
record.total = record.no_of_house + record.no_of_shop + record.no_of_other_unit record.total = record.no_of_house + record.no_of_shop + record.no_of_other_unit
class PropertyContentDetails(models.Model):
_name = 'property.content.details'
_description = 'Property Unit Details'
property_id = fields.Many2one('internal.property', string='Property', required=True, ondelete='cascade')
content_id = fields.Many2one('property.contents','Property Content')
qty = fields.Integer('QTY')
desc = fields.Char('Description')
attachment = fields.Binary(string="Property Docs")

View File

@ -9,25 +9,27 @@
import base64 import base64
import re import re
from odoo import models, fields, api, exceptions, _ from odoo import models, fields, api, exceptions, _
class PropertyRole(models.Model): class PropertyRole(models.Model):
_name = 'property.role' _name = 'property.role'
_description = 'Property Role' _description = 'Property Role'
name = fields.Char('Name') name = fields.Char('Name')
class Unit(models.Model): class Unit(models.Model):
_name = 're.unit' _name = 're.unit'
_description = 'Property Unit' _description = 'Property Unit'
_inherit = ['mail.thread', 'mail.activity.mixin'] _inherit = ['mail.thread', 'mail.activity.mixin']
_order = "id desc" _order = "id desc"
unit_category = fields.Selection([ unit_category = fields.Selection([
('residential', 'Residential'), ('residential', 'Residential'),
('commercial', 'Commercial'), ('commercial', 'Commercial'),
('lands', 'Lands') ], string="Unit Category") ('lands', 'Lands')], string="Unit Category")
attach_nbr = fields.Integer(compute='get_attachments') attach_nbr = fields.Integer(compute='get_attachments')
content_ids= fields.One2many(comodel_name='property.content.details', inverse_name='property_id',string='') content_ids = fields.One2many(comodel_name='property.content.details', inverse_name='unit_id', string='')
active = fields.Boolean(default=True) active = fields.Boolean(default=True)
role_id = fields.Many2one('property.role', string='Role') role_id = fields.Many2one('property.role', string='Role')
unlock = fields.Boolean(default=True, string="Unlock") unlock = fields.Boolean(default=True, string="Unlock")
@ -40,6 +42,10 @@ class Unit(models.Model):
('reserved', 'Reserved'), ('reserved', 'Reserved'),
('rented', 'Rented'), ('rented', 'Rented'),
('sold', 'Sold')], string="Status", default='draft') ('sold', 'Sold')], string="Status", default='draft')
journal_id = fields.Many2one('account.journal', string='Journal')
accrued_account_id = fields.Many2one('account.account', string='Accrued Account')
debit_account_id = fields.Many2one('account.account', string='Debit Account')
revenue_account_id = fields.Many2one('account.account', string='Revenue Account')
unit_type_id = fields.Many2one('unit.type', string="Unit Type") unit_type_id = fields.Many2one('unit.type', string="Unit Type")
management_type = fields.Selection(related='property_id.management_type', string="Management Type", store=True) management_type = fields.Selection(related='property_id.management_type', string="Management Type", store=True)
market_type = fields.Selection(related="property_id.market_type", string="Market Type", store=True) market_type = fields.Selection(related="property_id.market_type", string="Market Type", store=True)
@ -57,7 +63,7 @@ class Unit(models.Model):
mezzanine = fields.Boolean(string="Mezzanine") mezzanine = fields.Boolean(string="Mezzanine")
mezzan_length = fields.Float(string="Mezzan Length") mezzan_length = fields.Float(string="Mezzan Length")
mezzan_width = fields.Float(string="Mezzan Width") mezzan_width = fields.Float(string="Mezzan Width")
meter_price = fields.Float(string="Meter Price", compute="get_rent_price" , store=True, digits=(16, 2)) meter_price = fields.Float(string="Meter Price", compute="get_rent_price", store=True, digits=(16, 2))
rent_price = fields.Float(string="Total Price") rent_price = fields.Float(string="Total Price")
limit_meter_price = fields.Float(string="Limit Meter Price", compute="get_limit_rent_price", store=True) limit_meter_price = fields.Float(string="Limit Meter Price", compute="get_limit_rent_price", store=True)
limit_rent = fields.Float(string="Limit Rent", store=True) limit_rent = fields.Float(string="Limit Rent", store=True)
@ -72,35 +78,37 @@ class Unit(models.Model):
bathroom_no = fields.Integer(string="Bathroom Count") bathroom_no = fields.Integer(string="Bathroom Count")
hall_no = fields.Integer(string="Hall Count") hall_no = fields.Integer(string="Hall Count")
kitchen_no = fields.Integer(string="kitchen Count") kitchen_no = fields.Integer(string="kitchen Count")
stamping_count = fields.Selection(string="Stamping Count",related='property_id.stamping_count') stamping_count = fields.Selection(string="Stamping Count", related='property_id.stamping_count')
stamping = fields.Char(string="Stamping Number",related='property_id.stamping') stamping = fields.Char(string="Stamping Number", related='property_id.stamping')
stamping_date = fields.Date(string="Stamping Date",related='property_id.stamping_date') stamping_date = fields.Date(string="Stamping Date", related='property_id.stamping_date')
# stamping_state = fields.Selection(related='property_id.stamping_state') # stamping_state = fields.Selection(related='property_id.stamping_state')
stamping_attach = fields.Binary("Stamping Attach", attachment=True,related='property_id.stamping_attach') stamping_attach = fields.Binary("Stamping Attach", attachment=True, related='property_id.stamping_attach')
stamping_2 = fields.Char(string="Stamping Number",related='property_id.stamping_2') stamping_2 = fields.Char(string="Stamping Number", related='property_id.stamping_2')
stamping_date_2 = fields.Date(string="Stamping Date",related='property_id.stamping_date_2') stamping_date_2 = fields.Date(string="Stamping Date", related='property_id.stamping_date_2')
stamping_attach_2 = fields.Binary("Stamping Attach", attachment=True,related='property_id.stamping_attach_2') stamping_attach_2 = fields.Binary("Stamping Attach", attachment=True, related='property_id.stamping_attach_2')
stamping_state_2 = fields.Selection([('updated', 'Updated'), ('not_updated', 'Not Updated')],related='property_id.stamping_state_2') stamping_state_2 = fields.Selection([('updated', 'Updated'), ('not_updated', 'Not Updated')],
related='property_id.stamping_state_2')
stamping_3 = fields.Char(string="Stamping Number",related='property_id.stamping_3') stamping_3 = fields.Char(string="Stamping Number", related='property_id.stamping_3')
stamping_date_3 = fields.Date(string="Stamping Date",related='property_id.stamping_date_3') stamping_date_3 = fields.Date(string="Stamping Date", related='property_id.stamping_date_3')
stamping_attach_3 = fields.Binary("Stamping Attach", attachment=True,related='property_id.stamping_attach_3') stamping_attach_3 = fields.Binary("Stamping Attach", attachment=True, related='property_id.stamping_attach_3')
stamping_state_3 = fields.Selection([('updated', 'Updated'), ('not_updated', 'Not Updated')],related='property_id.stamping_state_3') stamping_state_3 = fields.Selection([('updated', 'Updated'), ('not_updated', 'Not Updated')],
related='property_id.stamping_state_3')
stamping_new = fields.Char(string="Stamping Number New") stamping_new = fields.Char(string="Stamping Number New")
stamping_date_new = fields.Date(string="Stamping Date New") stamping_date_new = fields.Date(string="Stamping Date New")
stamping_attach_new = fields.Binary("Stamping Attach New", attachment=True) stamping_attach_new = fields.Binary("Stamping Attach New", attachment=True)
_sql_constraints = [ _sql_constraints = [
('name', 'unique(name)', _('Name must be unique.')), ('name', 'unique(name)', _('Name must be unique.')),
] ]
# Smart button to count related maintenance records # Smart button to count related maintenance records
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count') maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
def get_attachments(self): def get_attachments(self):
action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment') action = self.env['ir.actions.act_window']._for_xml_id('base.action_attachment')
action['domain'] = str([('res_model', '=', 're.unit'),('res_id', 'in', self.ids)]) action['domain'] = str([('res_model', '=', 're.unit'), ('res_id', 'in', self.ids)])
action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id) action['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
domain = [('res_model', '=', 're.unit'), ('res_id', '=', self.id)] domain = [('res_model', '=', 're.unit'), ('res_id', '=', self.id)]
self.attach_nbr = self.env['ir.attachment'].search_count(domain) self.attach_nbr = self.env['ir.attachment'].search_count(domain)
@ -144,7 +152,6 @@ class Unit(models.Model):
else: else:
rec.limit_rent = 0.0 rec.limit_rent = 0.0
def action_available(self): def action_available(self):
""" """
after checking meter price and limit price meter after checking meter price and limit price meter
@ -198,7 +205,6 @@ class Unit(models.Model):
if white_space.search(self.electric_account): if white_space.search(self.electric_account):
raise exceptions.ValidationError(_("Electric account (cannot accept white space)")) raise exceptions.ValidationError(_("Electric account (cannot accept white space)"))
@api.constrains('limit_meter_price', 'space', 'meter_price', 'mezzan_width', 'mezzan_length') @api.constrains('limit_meter_price', 'space', 'meter_price', 'mezzan_width', 'mezzan_length')
def check_number(self): def check_number(self):
""" """
@ -223,7 +229,6 @@ class Unit(models.Model):
if record.space != 0.0: if record.space != 0.0:
record.meter_price = record.rent_price / record.space record.meter_price = record.rent_price / record.space
def action_toggle_is_locked(self): def action_toggle_is_locked(self):
self.ensure_one() self.ensure_one()
if self.unlock: if self.unlock:
@ -232,15 +237,12 @@ class Unit(models.Model):
self.write({'unlock': True}) self.write({'unlock': True})
class PropertyContentDetails(models.Model): class PropertyContentDetails(models.Model):
_name = 'property.content.details' _name = 'property.content.details'
_description = 'Property Unit Details' _description = 'Property Unit Details'
property_id = fields.Many2one('internal.property', string='Property', required=True, ondelete='cascade') unit_id = fields.Many2one('re.unit', string='Property', required=True, ondelete='cascade')
content_id = fields.Many2one('property.contents','Property Content') content_id = fields.Many2one('property.contents', 'Property Content')
qty = fields.Integer('QTY') qty = fields.Integer('QTY')
desc = fields.Char('Description') desc = fields.Char('Description')
attachment = fields.Binary(string="Property Docs") attachment = fields.Binary(string="Property Docs")

View File

@ -199,7 +199,7 @@
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group> </group>
<group attrs="{'readonly':[('state','=','approve')]}" colspan="2" col="4"> <group attrs="{'readonly':[('state','=','approve')]}" colspan="2" col="4" string="First Stamping">
<field name="stamping_count" required="1" <field name="stamping_count" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="stamping" required="1" <field name="stamping" required="1"

View File

@ -115,7 +115,7 @@
</page> </page>
<page name="stamping_info" string="Stamping"> <page name="stamping_info" string="Stamping">
<group> <group>
<group> <group string="First Stamping">
<field name="stamping_count" <field name="stamping_count"
readonly="1"/> readonly="1"/>
<field name="stamping"/> <field name="stamping"/>
@ -161,6 +161,18 @@
</tree> </tree>
</field> </field>
</page> </page>
<page attrs="{'readonly':[('state','=','approve')]}" name="accounts"
string="Accounts">
<group col="4" colspan="2">
<field name="journal_id"/>
<field name="accrued_account_id"/>
<field name="debit_account_id"/>
<field name="revenue_account_id"/>
</group>
</page>
</notebook> </notebook>
</sheet> </sheet>