from random import randint from odoo import fields, models, api, _ class City(models.Model): _name = 'res.country.city' _description = "Benefits - City" @api.depends('code', 'name') def _load_country_id(self): for r in self: r.country_id = self.env.ref('base.sa') code = fields.Char(string='Code') name = fields.Char(string='Name') state_id = fields.Many2one('res.country.state', string='State') country_id = fields.Many2one('res.country', string='Country', compute='_load_country_id', store=True, readonly=False) active = fields.Boolean(default=True) class housing(models.Model): _name = 'benefit.housing' _inherit = ['mail.thread', 'mail.activity.mixin'] _description = "Benefits - housing" name = fields.Char(compute='_compute_get_name') city_id = fields.Many2one('res.country.city', string='City') block = fields.Char(string='block') street = fields.Char(string='street') url = fields.Char(compute="open_map") url_html = fields.Html( sanitize=False, compute="get_html") lat = fields.Char() lon = fields.Char() house_number = fields.Char(string='house number') floor = fields.Char(string='floor') housing_number = fields.Char(string='housing number') image = fields.Binary(string="", ) image_1 = fields.Binary(string="", ) image_2 = fields.Binary(string="", ) image_3 = fields.Binary(string="", ) image_4 = fields.Binary(string="", ) nearby_mosque = fields.Char(string='Nearby mosque') housing_note = fields.Char(string='housing note') note_neighborhood = fields.Char() rent_amount = fields.Integer() housing_type = fields.Selection([ ('apartment', 'apartment'), ('villa', 'villa'), ('popular_house', 'popular house'), ('tent', 'tent'), ('Appendix', 'Appendix'), ], default='apartment') housing_cat = fields.Selection([ ('excellent', 'Excellent'), ('good', 'Good'), ('bad', 'Bad'), ('collapsible', 'Collapsible'), ('collapsed', 'Collapsed')]) property_type = fields.Selection([ ('ownership', 'ownership'), ('rent', 'rent'), ('charitable', 'charitable'), ('ownership_shared', 'Ownership Shared'), ('rent_shared', 'Rent Shared')]) rooms_number = fields.Integer('Rooms Number', compute="get_rooms_total", required=True) room_ids = fields.One2many('benefit.housing.rooms', inverse_name='housing_id') water_bill_account_number = fields.Char(string='water Bill Account Number') electricity_bill_account_number = fields.Char(string='Electricity Bill Account Number') water_bill_account_attach = fields.Many2many('ir.attachment', relation="ir_water_bill_account_number_rel", column1="water_bill_account_number", column2="name", string="water Bill") electricity_bill_account_attach = fields.Many2many('ir.attachment', relation="ir_electricity_bill_account_attach_rel", column1="electricity_bill_account_number", column2="name", string="Electricity Bill ") benefits_total = fields.Integer(string="Benefit Total", compute="get_benefits_total") benefit_ids = fields.One2many('grant.benefit', 'housing_id', string="Benefits") family_ids = fields.One2many('benefit.family', 'housing_id', string="Benefits") total_income = fields.Float(compute='get_total') total_expenses = fields.Float(compute='get_total') total_net = fields.Float(compute='get_total') financial_aid = fields.Float(compute='get_total') domestic_labor_ids = fields.Many2many('domestic.labor') def get_html(self): for rec in self: print(f'') rec.url_html = f'