diff --git a/odex25_realstate/property_management/i18n/ar_001.po b/odex25_realstate/property_management/i18n/ar_001.po
index 16e4fba4d..9a4287f12 100644
--- a/odex25_realstate/property_management/i18n/ar_001.po
+++ b/odex25_realstate/property_management/i18n/ar_001.po
@@ -451,6 +451,11 @@ msgstr "تاريخ بداية العقد"
msgid "Contract Transfer"
msgstr "نقل العقد"
+#. module: property_management
+#: model:ir.model.fields,field_description:property_management.field_rental_contract__contract_type
+msgid "Contract Type"
+msgstr "نوع العقد"
+
#. module: property_management
#: model:ir.model.fields,field_description:property_management.field_re_unit__contract_counts
#: model_terms:ir.ui.view,arch_db:property_management.contract_unit_view
@@ -2049,6 +2054,7 @@ msgstr "الضريبة"
#. module: property_management
#: model:ir.model.fields,field_description:property_management.field_rent_payment__tax_amount
+#: model:ir.model.fields,field_description:property_management.field_rental_contract__tax_amount
#: model_terms:ir.ui.view,arch_db:property_management.rental_contract_form_view
msgid "Tax Amount"
msgstr "قيمة الضريبة"
@@ -2119,6 +2125,11 @@ msgstr "الإجمالي"
msgid "Total Amount"
msgstr "القيمة الإجمالية"
+#. module: property_management
+#: model:ir.model.fields,field_description:property_management.field_rental_contract__total_amount_with_tax
+msgid "Total Amount With Tax"
+msgstr "القيمة الإجمالية مع الضريبة"
+
#. module: property_management
#: model_terms:ir.ui.view,arch_db:property_management.rent_payment_list_view
msgid "Total Commission"
diff --git a/odex25_realstate/property_management/models/rental_contract.py b/odex25_realstate/property_management/models/rental_contract.py
index 1a5739ab2..341c6ae3b 100644
--- a/odex25_realstate/property_management/models/rental_contract.py
+++ b/odex25_realstate/property_management/models/rental_contract.py
@@ -127,6 +127,10 @@ class RentalContract(models.Model):
('unit', 'Unit')], string="Rent Method")
property_id = fields.Many2one('internal.property', string="Property", tracking=True,)
unit_ids = fields.Many2many('re.unit', string="Units", tracking=True)
+ contract_type = fields.Selection(
+ [('residential', 'Residential'), ('commercial', 'Commercial'), ('lands', 'Lands')],
+ default=lambda self: self._get_default_contract_type()
+ )
partner_id = fields.Many2one('res.partner', string="Renter", domain=[('is_tenant', '=', True)])
identification_type = fields.Selection(related="partner_id.identification_type", string='Identification Type')
identification_number = fields.Char(related="partner_id.identification_number", string='Identification NUmber')
@@ -221,11 +225,33 @@ class RentalContract(models.Model):
annual_raise_on_type = fields.Selection([('meter', _('Meter')), ('rent_amount', _('Rent amount'))],
_('الزيادة علي'), default='rent_amount')
# Add Sales Tax Field
- tax_id = fields.Many2one('account.tax', string="Tax", domain=[('type_tax_use', '=', 'sale')],compute='compute_tax_id')
+ tax_id = fields.Many2one(
+ 'account.tax',
+ string="Tax",
+ domain=[('type_tax_use', '=', 'sale')],
+ # compute='compute_tax_id'
+ default=lambda self: self._get_default_tax_id()
+ )
+ tax_amount = fields.Float(compute="_compute_amounts")
+ total_amount_with_tax = fields.Float(compute="_compute_amounts")
+
+
+ @api.depends('tax_id', 'cal_rent_amount')
+ def _compute_amounts(self):
+ for rec in self:
+ rec.tax_amount = rec.tax_id._compute_amount(rec.cal_rent_amount, rec.cal_rent_amount) if rec.tax_id else 0.0
+ rec.total_amount_with_tax = rec.cal_rent_amount + rec.tax_amount
+
+ def _get_default_contract_type(self):
+ self.contract_type = self.unit_ids[0].unit_category if self.unit_ids else False
+
+ def _get_default_tax_id(self):
+ self.tax_id = self.unit_ids[0].tax_id if self.unit_ids else False
+
+ # @api.onchange('unit_ids')
+ # def compute_tax_id(self):
+ # self.tax_id = self.unit_ids[0].tax_id if self.unit_ids else False
- @api.onchange('unit_ids')
- def compute_tax_id(self):
- self.tax_id = self.unit_ids.tax_id
@api.onchange('tax_id')
def _onchange_sales_tax_id(self):
"""
diff --git a/odex25_realstate/property_management/views/rental_contract_views.xml b/odex25_realstate/property_management/views/rental_contract_views.xml
index 8e374881f..447356e78 100644
--- a/odex25_realstate/property_management/views/rental_contract_views.xml
+++ b/odex25_realstate/property_management/views/rental_contract_views.xml
@@ -85,6 +85,7 @@
('state','=','available'),
('action_type', '=', 'rent')]" widget="many2many_tags" attrs="{'readonly':[('state','!=','draft')], 'invisible':[('rent_method','in',['property', False])],
'required':[('rent_method','not in',['property', False])]}"/>
+