Skip to content

Commit 923489a

Browse files
committed
[ADD] estate: adding menus and changing fields - Chapter 5
[LINT] estate: linting all python files with ruff
1 parent b4bd38a commit 923489a

File tree

4 files changed

+59
-18
lines changed

4 files changed

+59
-18
lines changed

estate/__manifest__.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
2-
'name': "estate",
3-
4-
'website': "",
5-
'category': 'Tutorials',
6-
'version': '0.1',
7-
'application': True,
8-
'installable': True,
9-
'depends': ['base'],
10-
'data': [
11-
'security/ir.model.access.csv'
2+
"name": "estate",
3+
"website": "",
4+
"category": "Tutorials",
5+
"version": "0.1",
6+
"application": True,
7+
"installable": True,
8+
"depends": ["base"],
9+
"data": [
10+
"security/ir.model.access.csv",
11+
"views/estate_property_views.xml",
12+
"views/estate_menus.xml",
1213
],
13-
'assets': {},
14-
'author': 'Odoo S.A.',
15-
'license': 'LGPL-3',
14+
"assets": {},
15+
"author": "Odoo S.A.",
16+
"license": "LGPL-3",
1617
}

estate/models/estate_property.py

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

35

46
class EstateProperty(models.Model):
@@ -7,14 +9,36 @@ class EstateProperty(models.Model):
79
name = fields.Char(required=True)
810
description = fields.Text()
911
postcode = fields.Char()
10-
date_availability = fields.Date()
12+
date_availability = fields.Date(
13+
copy=False, default=datetime.now() + relativedelta(months=3)
14+
)
1115
expected_price = fields.Float(required=True)
12-
selling_price = fields.Float()
13-
bedrooms = fields.Integer()
16+
selling_price = fields.Float(readonly=True, copy=False)
17+
bedrooms = fields.Integer(default=2)
1418
living_area = fields.Integer()
1519
facades = fields.Integer()
1620
garage = fields.Boolean()
1721
garden = fields.Boolean()
1822
garden_area = fields.Integer()
19-
garden_orientation = fields.Selection(string="Orientation", selection=[("North", "North"), ("South", "South"), ("East", "East"), ("West", "West")])
20-
23+
garden_orientation = fields.Selection(
24+
string="Orientation",
25+
selection=[
26+
("North", "North"),
27+
("South", "South"),
28+
("East", "East"),
29+
("West", "West"),
30+
],
31+
)
32+
active = fields.Boolean(default=True)
33+
state = fields.Selection(
34+
selection=[
35+
("New", "New"),
36+
("Offer Received", "Offer Received"),
37+
("Offer Accepted", "Offer Accepted"),
38+
("Sold", "Sold"),
39+
("Cancelled", "Cancelled"),
40+
],
41+
default="New",
42+
required=True,
43+
copy=False,
44+
)

estate/views/estate_menus.xml

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+
<menuitem id="estate_menu_root" name="Estate Property">
4+
<menuitem id="estate_first_level_menu" name="Advertisements">
5+
<menuitem id="estate_second_level_menu" action="estate_property_action" />
6+
</menuitem>
7+
</menuitem>
8+
</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)