Merge pull request #905 from expsa/zainab_test_property

Zainab test property
This commit is contained in:
zainab2097 2024-08-28 15:51:51 +03:00 committed by GitHub
commit d3ebb7ab1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 64 additions and 10 deletions

View File

@ -17,7 +17,7 @@ class ResPartner(models.Model):
is_tenant = fields.Boolean(string="Is Tenant?")
#
class RentalContractTemplate(models.Model):
_name = 'rental.contract.template'

View File

@ -232,6 +232,7 @@
<field name="date"/>
<field name="contract_id"/>
<field name="property_id"/>
<field name="unit_ids" widget="many2many_tags"/>
<field name="total_amount"/>
</tree>

View File

@ -72,6 +72,7 @@
<field name="contract_id"/>
<field name="renter_id"/>
<field name="property_id"/>
<field name="unit_ids" widget="many2many_tags"/>
<field name="due_date"/>
<field name="paid_date"/>
<field name="amount"/>
@ -95,7 +96,7 @@
<field name="due_date"/>
<field name="state"/>
<filter string="Due" name="due_payment" domain="[('state','=','due')]"/>
<filter string="Not due" name="not_due_payment" domain="[('state','=','not')]"/>
<filter string="Not due" name="not_due_payment" domain="[('state','=','draft')]"/>
<filter string="Paid" name="paid_payment" domain="[('state','=','paid')]"/>
<filter string="Cancelled" name="cancel_payment" domain="[('state','=','cancel')]"/>
<separator/>

View File

@ -7,6 +7,8 @@
##############################################################################
import base64
import json
from lxml import etree
import re
from odoo import models, fields, api, exceptions, _
from odoo.modules.module import get_module_resource
@ -20,7 +22,25 @@ class Property(models.Model):
# Smart button to count related maintenance records
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
is_new = fields.Boolean(string="Is New Property?", default=False)
suitability_for_residence = fields.Selection([
('residential', 'Residential'),
('non_residential', 'Non-Residential'),
], string="Property Suitability for Residence")
@api.model
def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):
res = super(PurchaseOrderCustom, self).fields_view_get(view_id=view_id, view_type=view_type, toolbar=toolbar,
submenu=submenu)
doc = etree.XML(res['arch'])
if (view_type == 'form'):
for node in doc.xpath("//field"):
modifiers['readonly'] = [('state', 'in', ['approve'])]
node.set("modifiers", json.dumps(modifiers))
res['arch'] = etree.tostring(doc, encoding='unicode')
return res
def _compute_maintenance_count(self):
for record in self:
record.maintenance_count = self.env['property.management.maintenance'].search_count([
@ -70,7 +90,7 @@ class Property(models.Model):
('external_investment', 'External Investment'),
('include', 'Include')], string="Management Type", default="internal_investment")
market_type = fields.Selection([('residential', 'Residential'),
('commercial', 'Commercial'),
('commercial', 'Commercial'),('residential_commercial', 'Residential and Commercial'),
('industrial', 'Industrial'),
('other', 'Other')], string="Market Type", default="commercial")
other_type = fields.Char(string="Other Type")

View File

@ -9,14 +9,26 @@
import base64
import re
from odoo import models, fields, api, exceptions, _
class PropertyRole(models.Model):
_name = 'property.role'
_description = 'Property Role'
name = fields.Char('Name')
class Unit(models.Model):
_name = 're.unit'
_description = 'Property Unit'
_inherit = ['mail.thread', 'mail.activity.mixin']
_order = "id desc"
unit_category = fields.Selection([
('residential', 'Residential'),
('commercial', 'Commercial'),
('lands', 'Lands') ], string="Unit Category")
attach_nbr = fields.Integer(compute='get_attachments')
active = fields.Boolean(default=True)
role_id = fields.Many2one('property.role', string='Role')
unlock = fields.Boolean(default=True, string="Unlock")
name = fields.Char(string="Unit Name")
color = fields.Integer(string='Color Index', compute="set_color")
@ -74,6 +86,16 @@ class Unit(models.Model):
]
# Smart button to count related maintenance records
maintenance_count = fields.Integer(string="Maintenance Count", compute='_compute_maintenance_count')
def get_attachments(self):
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['context'] = "{'default_res_model': '%s','default_res_id': %d}" % (self._name, self.id)
return action
def get_attachments(self):
res = super(Unit, self).get_attachments()
domain = [('res_model', '=', 're.unit'), ('res_id', '=', self.id)]
self.attach_nbr = self.env['ir.attachment'].search_count(domain)
return res
def _compute_maintenance_count(self):
for record in self:

View File

@ -6,4 +6,5 @@ access_realestate_configuration_property_state,re.property.state,model_re_proper
access_realestate_internal_property,internal.property,model_internal_property,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_role_property,role.property,model_property_role,,1,1,1,1

1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
6 access_realestate_internal_property internal.property model_internal_property real_estate.group_real_estate_user 1 1 1 1
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

View File

@ -34,7 +34,7 @@
</button>
<button class="oe_stat_button" string="Documents" name="get_attachments" type="object" icon="fa-file-text-o"/>
<button name="action_view_maintenance" type="object" class="oe_stat_button">
<button name="action_view_maintenance" type="object" class="oe_stat_button" icon="fa-wrench">
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
</button>
@ -66,7 +66,7 @@
<group>
<field name="market_type"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="property_type_id" domain="[('market_type', '=', market_type)]" required="1"
<field name="property_type_id" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="company_profit" required="1"/>
<field name="company_profit_amount" required="1"/>
@ -230,6 +230,8 @@
<page name="other" string="Other Info">
<group col="4" colspan="2">
<field name="no_rented_units"/>
<field name="suitability_for_residence"/>
<field name="is_new"/>
<field name="no_available_units"/>
<field name="no_reserved_units"/>
</group>

View File

@ -26,7 +26,12 @@
<span class="o_stat_text" attrs="{'invisible': [('unlock', '=', True)]}">Lock</span>
</button>
<!-- Add your buttons here -->
<button name="action_view_maintenance" type="object" class="oe_stat_button">
<button name="get_attachments" type="object"
class="oe_stat_button"
icon="fa-file-text-o">
<field name="attach_nbr" widget="statinfo" string="Documents"/>
</button>
<button name="action_view_maintenance" type="object" icon="fa-wrench" class="oe_stat_button">
<field name="maintenance_count" widget="statinfo" string="Maintenance"/>
</button>
</div>
@ -39,6 +44,7 @@
</h4>
<group name="general_info" colspan="2" col="4">
<field name="unit_type_id" required="1" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="unit_category"/>
<field name="action_type" required="1" />
<field name="company_id" groups="base.group_multi_company" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="user_id" attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}" required="1"/>
@ -49,6 +55,7 @@
<field name="space" required="1"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>
<field name="external_space"/>
<field name="role_id"/>
<field name="mezzanine"
attrs="{'readonly':[('state','!=','draft'),('unlock','=',True)]}"/>

View File

@ -41,9 +41,9 @@
</div>
<group col="4" colspan="2">
<field name="market_type" required="1"/>
<field name="market_type" invisible="1" required="0"/>
<field name="name" required="1"/>
<field name="is_land"/>
<field name="is_land" invisible="1"/>
<field name="company_id" groups="base.group_multi_company"/>
</group>
</sheet>
@ -188,4 +188,4 @@
</data>
</odoo>
</odoo>