Skip to content

Commit 4d5e056

Browse files
committed
[ADD] estate: Chapter 5 - add fields, menus, and views
1 parent 0866025 commit 4d5e056

File tree

4 files changed

+46
-2
lines changed

4 files changed

+46
-2
lines changed

estate/__manifest__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
22
"name": "Estate",
33
"version": "1.0",
4+
"author": "Joyep",
5+
"license": "LGPL-3",
46
"depends": ["base"],
57
"data": [
68
"data/ir.model.access.csv",
9+
"views/estate_property_views.xml",
10+
"views/estate_menus.xml",
711
],
812
"installable": True,
913
"application": True,

estate/models/estate_property.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from odoo import fields, models
2+
from dateutil.relativedelta import relativedelta
23

34

45
class EstateProperty(models.Model):
@@ -13,9 +14,11 @@ class EstateProperty(models.Model):
1314
# Basic fields
1415
description = fields.Text("Description")
1516
postcode = fields.Char("Postcode")
16-
date_availability = fields.Date("Available From")
17+
date_availability = fields.Date(
18+
"Available From", default=lambda self: fields.Date.today() + relativedelta(months=3), copy=False
19+
)
1720
expected_price = fields.Float("Expected Price", required=True)
18-
selling_price = fields.Float("Selling Price")
21+
selling_price = fields.Float("Selling Price", copy=False, readonly=True)
1922
bedrooms = fields.Integer("Bedrooms", default=2)
2023
living_area = fields.Integer("Living Area (sqm)")
2124
facades = fields.Integer("Number of Facades")
@@ -31,3 +34,17 @@ class EstateProperty(models.Model):
3134
],
3235
string="Garden Orientation",
3336
)
37+
active = fields.Boolean("Active", default=True)
38+
status = fields.Selection(
39+
selection=[
40+
("new", "New"),
41+
("offer_received", "Offer Received"),
42+
("offer_accepted", "Offer Accepted"),
43+
("sold", "Sold"),
44+
("canceled", "Canceled"),
45+
],
46+
string="Status",
47+
default="new",
48+
required=True,
49+
copy=False,
50+
)

estate/views/estate_menus.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<menuitem id="estate_menu_root" name="Real Estate"/>
4+
5+
<menuitem id="estate_property_menu_categ"
6+
name="Properties"
7+
parent="estate_menu_root"
8+
sequence="10"/>
9+
10+
<menuitem id="estate_property_menu_action"
11+
name="Properties"
12+
parent="estate_property_menu_categ"
13+
action="estate_property_action"
14+
sequence="20"/>
15+
</odoo>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<odoo>
3+
<record id="estate_property_action" model="ir.actions.act_window">
4+
<field name="name">Properties</field>
5+
<field name="res_model">estate.property</field>
6+
<field name="view_mode">list,form</field>
7+
</record>
8+
</odoo>

0 commit comments

Comments
 (0)