|
| 1 | +from typing import DefaultDict |
| 2 | +from typing_extensions import ReadOnly |
1 | 3 | from odoo import fields, models, api |
2 | 4 | from odoo.exceptions import ValidationError |
3 | 5 |
|
4 | 6 |
|
5 | | -class estate_property(models.Model): |
| 7 | +class EstateProperty(models.Model): |
6 | 8 |
|
7 | | - _name = "estate.property" |
| 9 | + _name = 'estate.property' |
8 | 10 | _description = "A real estate model with many fields" |
9 | | - name = fields.Char(required=True) |
10 | | - description = fields.Text() |
11 | | - postcode = fields.Integer() |
12 | | - date_availability = fields.Datetime() |
13 | | - expected_price = fields.Float(required=True) |
14 | | - selling_price = fields.Float() |
15 | | - bedrooms = fields.Integer() |
16 | | - living_area = fields.Integer() |
17 | | - facades = fields.Integer() |
18 | | - garage = fields.Boolean() |
19 | | - garden = fields.Boolean() |
20 | | - garden_area = fields.Integer() |
| 11 | + active = fields.Boolean(string="Active", default="Active") |
| 12 | + bedrooms = fields.Integer(string="Bedrooms", default="2") |
| 13 | + date_availability = fields.Datetime( |
| 14 | + string="Available From", copy=False, default=lambda self: fields.Date.add(fields.Date.context_today(self), months=3)) |
| 15 | + description = fields.Text(string="Description") |
| 16 | + expected_price = fields.Float(string="Expected Price", required=True) |
| 17 | + facades = fields.Integer(string="Facades") |
| 18 | + garden = fields.Boolean(string="Garden") |
| 19 | + garden_area = fields.Integer(string="Garden Area (sqm)") |
21 | 20 | garden_orientation = fields.Selection( |
22 | | - string='Type', |
23 | | - selection=[('north', 'North'), ('south', 'South'), |
24 | | - ('east', 'East'), ('west', 'West')], |
25 | | - help="Type is used to specify the garden orientation") |
| 21 | + string="Direction", |
| 22 | + selection=[ |
| 23 | + ('north', "North"), |
| 24 | + ('south', "South"), |
| 25 | + ('east', "East"), |
| 26 | + ('west', "West") |
| 27 | + ], |
| 28 | + help="Type is used to specify the garden orientation" |
| 29 | + ) |
| 30 | + garage = fields.Boolean(string="Garage") |
| 31 | + living_area = fields.Integer(string="Living Area (sqm)") |
| 32 | + name = fields.Char(string="Title", required=True, default="Unknown") |
| 33 | + postcode = fields.Integer(string="Postcode") |
| 34 | + selling_price = fields.Float( |
| 35 | + string="Selling Price", readonly=True, copy=False) |
| 36 | + state = fields.Selection([('new', "New"), |
| 37 | + ('offer_received', "Offer Received"), |
| 38 | + ('offer_accepted', "Offer Accepted"), |
| 39 | + ('sold', "Sold"), |
| 40 | + ('cancelled', "Cancelled") |
| 41 | + ], |
| 42 | + default='new') |
26 | 43 |
|
27 | 44 | @api.constrains('expected_price') |
28 | 45 | def _check_price(self): |
|
0 commit comments