[UPDATE]UPDATE properrty

This commit is contained in:
zainab8585 2024-08-29 17:22:58 +02:00
parent 0b720fad5e
commit af8b2e12fd
6 changed files with 127 additions and 72 deletions

View File

@ -218,7 +218,7 @@ class PropertyManagementMaintenance(models.Model):
def _prepare_invoice_values(self, maintenance, amount): def _prepare_invoice_values(self, maintenance, amount):
origin = _( origin = _(
'Maintenance Order') + ' ' + maintenance.name + ' ' + maintenance.partner_id.name if maintenance.partner_id else \ 'Maintenance Order') + ' ' + maintenance.name + ' '+maintenance.property_id.name+' ' +maintenance.unit_ids[0].name+' ' +maintenance.partner_id.name if maintenance.partner_id else \
_('Maintenance Order') + ' ' + maintenance.name + ' ' + maintenance.vendor_id.name _('Maintenance Order') + ' ' + maintenance.name + ' ' + maintenance.vendor_id.name
line_data = [] line_data = []
for line in maintenance.end_line_ids: for line in maintenance.end_line_ids:
@ -226,6 +226,7 @@ class PropertyManagementMaintenance(models.Model):
'product_id': line.product_id.id, 'product_id': line.product_id.id,
'name': origin + ' - ' + str(maintenance.date), 'name': origin + ' - ' + str(maintenance.date),
'account_id': line.product_id.property_account_expense_id.id, 'account_id': line.product_id.property_account_expense_id.id,
'analytic_account_id': maintenance.property_id.analytic_account_id.id if maintenance.analytic_account_id else False,
'quantity': line.qty, 'quantity': line.qty,
'price_unit': line.cost, 'price_unit': line.cost,
})) }))

View File

@ -101,35 +101,38 @@ class RentPayment(models.Model):
line_journal = [] line_journal = []
if payment.amount>0.00: if payment.amount>0.00:
print('go on....')
line_invoice.append((0, 0, { line_invoice.append((0, 0, {
'name':'قيمة الإيجار '+' - '+payment.contract_id.name+'- '+ self.name + ' - ' + payment.code + ' - ' + str(payment.due_date), 'name':'قيمة الإيجار '+' - '+payment.contract_id.name+'- '+self.property_id.name+' - '+self.unit_ids[0].name+' - ' + self.name + ' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': self.amount, 'price_unit': self.amount,
'quantity': 1.0, 'quantity': 1.0,
'account_id': payment.contract_id.revenue_account_id.id, 'account_id': payment.contract_id.revenue_account_id.id,
'analytic_account_id': payment.property_id.analytic_account_id.id if property_id.analytic_account_id else False,
'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids
})) }))
if payment.water_cost>0.00: if payment.water_cost>0.00:
line_invoice.append((0, 0, { line_invoice.append((0, 0, {
'name': 'تكلفة المياه'+' -'+self.name + ' - '+payment.contract_id.name +' - ' + payment.code + ' - ' + str(payment.due_date), 'name': 'تكلفة المياه'+' -'+self.name + ' - '+payment.contract_id.name +' - ' +self.property_id.name+' - '+self.unit_ids[0].name+' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit':self.water_cost, 'price_unit':self.water_cost,
'quantity': 1.0, 'quantity': 1.0,
'account_id': payment.contract_id.revenue_account_id.id, 'account_id': payment.contract_id.revenue_account_id.id,
'analytic_account_id': payment.property_id.analytic_account_id.id if property_id.analytic_account_id else False,
'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids
}),) }),)
if payment.service_cost>0.00: if payment.service_cost>0.00:
line_invoice.append((0, 0, { line_invoice.append((0, 0, {
'name':'قيمة الخدمات'+' - '+ self.name+' - '+payment.contract_id.name + ' - ' + payment.code + ' - ' + str(payment.due_date), 'name':'قيمة الخدمات'+' - '+ self.name+' - '+payment.contract_id.name + ' - '+self.property_id.name+' - '+self.unit_ids[0].name+' - ' + payment.code + ' - ' + str(payment.due_date),
'price_unit': self.service_cost, 'price_unit': self.service_cost,
'quantity': 1.0, 'quantity': 1.0,
'analytic_account_id': payment.property_id.analytic_account_id.id if property_id.analytic_account_id else False,
'account_id': payment.contract_id.revenue_account_id.id, 'account_id': payment.contract_id.revenue_account_id.id,
'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids
})) }))
if payment.amount==0.00 and payment.service_cost==0.00 and payment.water_cost==0.00: if payment.amount==0.00 and payment.service_cost==0.00 and payment.water_cost==0.00:
line_invoice.append((0, 0, { line_invoice.append((0, 0, {
'name':self.name + ' - ' +payment.contract_id.name + ' - '+payment.code + ' - ' + str(payment.due_date), 'name':self.name + ' - ' +payment.contract_id.name + ' - '+self.property_id.name+' - '+self.unit_ids[0].name+' - '+payment.code + ' - ' + str(payment.due_date),
'price_unit':self.total_amount, 'price_unit':self.total_amount,
'quantity': 1.0, 'quantity': 1.0,
'analytic_account_id': payment.property_id.analytic_account_id.id if property_id.analytic_account_id else False,
'account_id': payment.contract_id.revenue_account_id.id, 'account_id': payment.contract_id.revenue_account_id.id,
'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids 'tax_ids': [(6, 0, [payment.tax_id.id])] if payment.tax_id else False, # Assigning tax_id to tax_ids
})) }))

View File

@ -557,7 +557,7 @@ class RentalContract(models.Model):
water_amount_per_payment = self.water_cost / (rent_factor / service_months) water_amount_per_payment = self.water_cost / (rent_factor / service_months)
services_amount_per_payment = self.service_amount / (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, 2)
tax_amount = round(self.tax_id.amount / 100 * rent_amount_per_payment, 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) total_amount = round(untaxed_amount + tax_amount, 2)
@ -587,7 +587,7 @@ class RentalContract(models.Model):
self.user_id.id, self.user_id.id,
self.env.user.company_id.id, self.env.user.company_id.id,
'draft', 'draft',
self.tax_id.id, self.tax_id.id if self.tax_id else None, # Handle None value for tax_id
untaxed_amount, untaxed_amount,
tax_amount tax_amount
)) ))
@ -602,7 +602,7 @@ class RentalContract(models.Model):
# Update amounts (e.g., tax calculations) for each rent payment line # Update amounts (e.g., tax calculations) for each rent payment line
for line in self.rent_payment_ids: for line in self.rent_payment_ids:
line.write({'tax_id': self.tax_id.id}) line.write({'tax_id': self.tax_id.id if self.tax_id else None})
line.get_untaxed_amount() line.get_untaxed_amount()
line.get_total_amount() line.get_total_amount()

View File

@ -22,6 +22,9 @@ class Property(models.Model):
# 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')
is_unit_count_fixed = fields.Boolean(string="Is Unit Count Fixed in Floor")
floor_ids= fields.One2many(comodel_name='floor.unit.details', inverse_name='property_id',string='')
analytic_account_id = fields.Many2one('account.analytic.account', string='Analytic Account')
is_new = fields.Boolean(string="Is New Property?", default=False) is_new = fields.Boolean(string="Is New Property?", default=False)
suitability_for_residence = fields.Selection([ suitability_for_residence = fields.Selection([
('residential', 'Residential'), ('residential', 'Residential'),
@ -383,4 +386,20 @@ class Property(models.Model):
self.write({'unlock':False}) self.write({'unlock':False})
else: else:
self.write({'unlock':True}) self.write({'unlock':True})
class PropertyUnitDetails(models.Model):
_name = 'floor.unit.details'
_description = 'Floor Unit Details'
role_id= fields.Many2one(comodel_name='property.role', string='Roles',)
property_id = fields.Many2one('internal.property', string='Property', required=True, ondelete='cascade')
no_of_house = fields.Integer(string='No of Housees')
no_of_shop = fields.Integer(string='No of Shops')
no_of_other_unit = fields.Integer(string='No of Other Units')
description = fields.Char(string='Description')
total = fields.Integer(string='Total', compute='_compute_total', store=True, readonly=True)
@api.depends('no_of_house', 'no_of_shop', 'no_of_other_unit')
def _compute_total(self):
for record in self:
record.total = record.no_of_house + record.no_of_shop + record.no_of_other_unit

View File

@ -7,4 +7,5 @@ access_realestate_internal_property,internal.property,model_internal_property,re
access_realestate_re_unit,re.unit,model_re_unit,real_estate.group_real_estate_user,1,1,1,1 access_realestate_re_unit,re.unit,model_re_unit,real_estate.group_real_estate_user,1,1,1,1
access_realestate_configuration_property_sketchs,sketchs.sketchs,model_sketchs_sketchs,real_estate.group_real_estate_user,1,1,1,1 access_realestate_configuration_property_sketchs,sketchs.sketchs,model_sketchs_sketchs,real_estate.group_real_estate_user,1,1,1,1
access_realestate_role_property,role.property,model_property_role,,1,1,1,1 access_realestate_role_property,role.property,model_property_role,,1,1,1,1
access_realestate_floor_property,floor.property,model_floor_unit_details,,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
7 access_realestate_re_unit re.unit model_re_unit real_estate.group_real_estate_user 1 1 1 1
8 access_realestate_configuration_property_sketchs sketchs.sketchs model_sketchs_sketchs real_estate.group_real_estate_user 1 1 1 1
9 access_realestate_role_property role.property model_property_role 1 1 1 1
10 access_realestate_floor_property floor.property model_floor_unit_details 1 1 1 1
11

View File

@ -30,12 +30,14 @@
</button> </button>
<button class="oe_stat_button" name="get_unit" type="object" icon="fa-home"> <button class="oe_stat_button" name="get_unit" type="object" icon="fa-home">
<field string="Units" name="unit_counts" widget="statinfo"/> <field string="Units" name="unit_counts" widget="statinfo"/>
</button> </button>
<button class="oe_stat_button" string="Documents" name="get_attachments" type="object" icon="fa-file-text-o"/> <button class="oe_stat_button" string="Documents" name="get_attachments" type="object"
<button name="action_view_maintenance" type="object" class="oe_stat_button" icon="fa-wrench"> icon="fa-file-text-o"/>
<field name="maintenance_count" widget="statinfo" string="Maintenance"/> <button name="action_view_maintenance" type="object" class="oe_stat_button"
icon="fa-wrench">
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
</button> </button>
</div> </div>
@ -66,7 +68,7 @@
<group> <group>
<field name="market_type" <field name="market_type"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="property_type_id" required="1" <field name="property_type_id" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="company_profit" required="1"/> <field name="company_profit" required="1"/>
<field name="company_profit_amount" required="1"/> <field name="company_profit_amount" required="1"/>
@ -75,24 +77,29 @@
</group> </group>
<group name="other_info" colspan="2" col="4"> <group name="other_info" colspan="2" col="4">
<field name="branch_manager_id" required="1"/> <field name="branch_manager_id" required="1"/>
<field name="company_id" groups="base.group_multi_company" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> <field name="company_id" groups="base.group_multi_company"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group>
<group name="account" colspan="2" col="4">
<field name="analytic_account_id"/>
</group> </group>
<notebook> <notebook>
<page name="location_info" string="Property Face &amp; Location"> <page name="location_info" string="Property Face &amp; Location">
<group> <group>
<group col="4" colspan="2"> <group col="4" colspan="2">
<field name="city_id" required="1" <field name="city_id" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="district_id" required="1" domain="[('city_id','=',city_id)]" <field name="district_id" required="1" domain="[('city_id','=',city_id)]"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="street" required="1" <field name="street" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="location" required="1" widget="url" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> <field name="location" required="1" widget="url"
<field name="property_no" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="property_face_ids" widget="many2many_tags"
<field name="property_no" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="property_face_ids" widget="many2many_tags"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group> </group>
<group string="Building Length"> <group string="Building Length">
@ -125,10 +132,11 @@
<group> <group>
<group col="4" colspan="2"> <group col="4" colspan="2">
<field name="user_id" readonly="1"/> <field name="user_id" readonly="1"/>
<field name="marketer_id" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> <field name="marketer_id"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="block_no" required="1" <field name="block_no" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="licence_no" required="1" <field name="licence_no" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="plate_no" <field name="plate_no"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
@ -186,60 +194,16 @@
</group> </group>
</group> </group>
</page> </page>
<page name="unit_info" string="Unit Info">
<group>
<group>
<field name="unit_floor_count" required="1" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="property_unit_space" />
<field name="uexternal_space" />
<field name="uspace" />
</group>
<group>
<field name="room_no" readonly="1"/>
<field name="hall_no" readonly="1"/>
<field name="kitchen_no" readonly="1"/>
<field name="bathroom_no" readonly="1"/>
</group>
</group>
<field name="unit_ids">
<tree>
<field name="seq" readonly="1"/>
<field name="name" readonly="1"/>
<field name="unit_type_id" readonly="1"/>
<field name="action_type" readonly="1"/>
<field name="space" readonly="1"/>
<field name="state" readonly="1"/>
</tree>
</field>
</page>
<page name="prices" string="Prices">
<group col="4" colspan="2">
<field name="property_space" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group>
<group col="4" colspan="2">
<field name="pur_price"/>
<field name="meter_price" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="rent_price"/>
<field name="pur_meter_price"/>
<field name="curr_price"/>
</group>
</page>
<page name="other" string="Other Info"> <page name="other" string="Other Info">
<group col="4" colspan="2"> <group col="4" colspan="2">
<field name="no_rented_units"/>
<field name="suitability_for_residence"/> <field name="suitability_for_residence"/>
<field name="is_new"/> <field name="is_new"/>
<field name="no_available_units"/>
<field name="no_reserved_units"/>
</group> </group>
<group colspan="2" col="4"> <group colspan="2" col="4">
<field name="property_age" <field name="property_age"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="floors_count" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="appendices" <field name="appendices"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
@ -269,6 +233,73 @@
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/> attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group> </group>
</page> </page>
<page name="info_floor" string="Floor Info">
<group>
<group>
<field name="floors_count" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group>
<group>
<field name="is_unit_count_fixed"/>
<field name="unit_floor_count" required="1" required="1"
attrs="{'readonly': [('state', '!=', 'draft'), ('unlock', '=', True)],'invisible': [('is_unit_count_fixed', '=', False)]}"/>
</group>
<field name="unit_details_ids">
<tree>
<field name="no_of_house" sum="Total House"/>
<field name="no_of_shop" sum="Total Shop"/>
<field name="no_of_other_unit" sum="Total Other Units"/>
<field name="description"/>
<field name="total" readonly="1" sum="Total"/>
</tree>
</field>
</group>
</page>
<page name="unit_info" string="Unit Info">
<group>
<group>
<field name="no_rented_units"/>
<field name="no_available_units"/>
<field name="no_reserved_units"/>
<field name="property_unit_space"/>
<field name="uexternal_space"/>
<field name="uspace"/>
</group>
<group>
<field name="room_no" readonly="1"/>
<field name="hall_no" readonly="1"/>
<field name="kitchen_no" readonly="1"/>
<field name="bathroom_no" readonly="1"/>
</group>
</group>
<field name="unit_ids">
<tree>
<field name="seq" readonly="1"/>
<field name="name" readonly="1"/>
<field name="unit_type_id" readonly="1"/>
<field name="action_type" readonly="1"/>
<field name="space" readonly="1"/>
<field name="state" readonly="1"/>
</tree>
</field>
</page>
<page name="prices" string="Prices">
<group col="4" colspan="2">
<field name="property_space" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
</group>
<group col="4" colspan="2">
<field name="pur_price"/>
<field name="meter_price" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="rent_price"/>
<field name="pur_meter_price"/>
<field name="curr_price"/>
</group>
</page>
</notebook> </notebook>
</sheet> </sheet>