Merge pull request #1690 from expsa/odex25_realstate_dev

[Add] electricity service in rental contract
This commit is contained in:
esraa8mostafa 2024-11-05 12:17:49 +02:00 committed by GitHub
commit 2bb29266fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 33 additions and 31 deletions

View File

@ -68,7 +68,6 @@ 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:
@ -110,7 +109,6 @@ 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")
@ -195,7 +193,10 @@ class RentalContract(models.Model):
('user_type_id.id', '=', self.env.ref('account.data_account_type_receivable').id)], store=True)
# Debit
accrued_account_id = fields.Many2one('account.account', string="Accrued Account", domain=lambda self: [
('user_type_id.id', 'in', (self.env.ref('account.data_account_type_current_liabilities').id,self.env.ref('account.data_account_type_non_current_liabilities').id,self.env.ref('account.data_account_type_revenue').id,self.env.ref('account.data_account_type_other_income').id))], store=True)
('user_type_id.id', 'in', (self.env.ref('account.data_account_type_current_liabilities').id,
self.env.ref('account.data_account_type_non_current_liabilities').id,
self.env.ref('account.data_account_type_revenue').id,
self.env.ref('account.data_account_type_other_income').id))], store=True)
revenue_account_id = fields.Many2one('account.account', string="Revenue Account", domain=lambda self: [
('user_type_id.id', 'in', (self.env.ref('account.data_account_type_revenue').id,
self.env.ref('account.data_account_type_other_income').id))], store=True)
@ -426,6 +427,7 @@ class RentalContract(models.Model):
self.insurance_amount = (self.insurance_cost / 100.0) * self.cal_rent_amount
elif self.insurance and self.insurance == 'fixed':
self.insurance_amount = self.insurance_cost
def action_draft(self):
self.write({'state': 'draft'})
@ -581,11 +583,12 @@ class RentalContract(models.Model):
rent_amount_per_payment = self.cal_rent_amount / (rent_factor / months)
water_amount_per_payment = self.water_cost / (rent_factor / service_months)
services_amount_per_payment = self.service_amount / (rent_factor / service_months)
untaxed_amount = round(rent_amount_per_payment + water_amount_per_payment + services_amount_per_payment, 2)
untaxed_amount = round(
rent_amount_per_payment + water_amount_per_payment + services_amount_per_payment + self.electricity_cost + self.sanitation_cost,
2)
tax_amount = round(self.tax_id.amount / 100 * rent_amount_per_payment, 2) if self.tax_id else 0.0
total_amount = round(untaxed_amount + tax_amount, 2)
next_date = date_from
service_next_date = date_from
payment = 0

View File

@ -35,11 +35,11 @@
<group string="Payment Details">
<field name="name" readonly="1"/>
<field name="amount" readonly="1"/>
<field name="electricity_cost" readonly="1"/>
<field name="sanitation_cost" readonly="1"/>
<field name="water_cost" readonly="1"/>
<field name="service_cost" readonly="1"/>
<field name="service_note" readonly="1"/>
<field name="electricity_cost" readonly="1"/>
<field name="sanitation_cost" readonly="1"/>
<field name="profit" invisible="1"/>
<field name="untaxed_amount" readonly="1" invisible="0"/>
<field name="tax_id" readonly="1"/>

View File

@ -123,17 +123,16 @@
<group>
<group string="Contract Service">
<!-- <field name="separate_service"/>-->
<label for="service"/>
<field name="electricity_cost"
attrs="{'readonly':[('state', '!=', 'draft')], 'required':[('service','!=',False)]}"/>
<field name="sanitation_cost"
attrs="{'readonly':[('state', '!=', 'draft')], 'required':[('service','!=',False)]}"/>
<field name="water_cost"/>
<field name="service" attrs="{'readonly':[('state','!=','draft')]}"/>
<field name="service_cost"
attrs="{'readonly':[('state', '!=', 'draft')], 'required':[('service','!=',False)]}"/>
<field name="service_note"/>
<field name="service_amount" readonly="1"/>
<field name="water_cost"/>
<field name="tax_id"/>
<div attrs="{'invisible': [('management_type', '!=', 'included')]}">
<field name="company_profit"
@ -194,11 +193,11 @@
<field name="name" readonly="1"/>
<field name="due_date" readonly="1"/>
<field name="amount" sum="Rent Amount" readonly="1"/>
<field name="electricity_cost" sum="Electricity Cost" readonly="1"/>
<field name="sanitation_cost" sum="Sanitation Cost" readonly="1"/>
<field name="water_cost" sum="Water Amount" readonly="1"/>
<field name="service_cost" sum="Service Amount" readonly="1"/>
<field name="service_note" readonly="1"/>
<field name="sanitation_cost" sum="Sanitation Cost" readonly="1"/>
<field name="electricity_cost" sum="Electricity Cost" readonly="1"/>
<field name="tax_id" required="1"/>
<field name="untaxed_amount" sum="Untaxed Amount" readonly="1"/>
<field name="tax_amount" sum="Tax Amount" readonly="1"/>