Update internal_property.py

This commit is contained in:
zainab2097 2024-09-29 13:13:32 +03:00 committed by GitHub
parent 7f2e3bd432
commit 87bfae6a14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -30,6 +30,29 @@ class Property(models.Model):
('residential', 'Residential'),
('non_residential', 'Non-Residential'),
], string="Property Suitability for Residence")
contract_counts = fields.Integer(string='Contracts', compute='count_contracts_number')
def count_contracts_number(self):
contract_count = self.env['rental.contract'].search([('property_id', '=', self.id)])
self.contract_counts = len(contract_count)
def get_contract(self):
contract_id = self.env['rental.contract'].search(
[('property_id', '=', self.id)])
form_id = self.env.ref('property_management.rental_contract_form_view').id
list_id = self.env.ref('property_management.rental_contract_list_view').id
domain = [('id', 'in', contract_id.ids)]
return {
'name': _('Rental Contract'),
'view_type': 'form',
'view_mode': 'form',
'res_model': 'rental.contract',
'views': [(list_id, 'tree'), (form_id, 'form')],
'type': 'ir.actions.act_window',
'target': 'current',
'domain': domain,
}
# @api.model
# def fields_view_get(self, view_id=None, view_type='form', toolbar=False, submenu=False):