Skip to content

Commit

Permalink
[ADD] estate: Chapter 6, add my first views and menus
Browse files Browse the repository at this point in the history
Playing with views and menus, adding my first views and menus to the estate module.
Use of the Active reserved field to enable archive & unarchive records.
Use of the State reserved field to enable lifecycle stages.
  • Loading branch information
Clement-Cardot committed Mar 19, 2024
1 parent 8006195 commit 9e5e90e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
5 changes: 4 additions & 1 deletion estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

{
'name': "Estate",
'name': "estate",
'version': '1.0',
'depends': ['base'],
'author': "Clément Cardot (cacl)",
Expand All @@ -13,6 +13,9 @@

'data': [
'security/ir.model.access.csv',

'views/estate_property_views.xml',
'views/estate_menus.xml',
],

'application': True,
Expand Down
20 changes: 17 additions & 3 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models
from odoo.tools import relativedelta

def _compute_three_months_from_now():
return fields.Date.today() + relativedelta(months=3)

class EstateProperty(models.Model):

_name = "estate.property"
_description = "Real Estate Property"

name = fields.Char(required=True)
description = fields.Text()
active = fields.Boolean(default=True)
state = fields.Selection([
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('canceled', 'Canceled')
], default='new', required=True, copy=False)

postcode = fields.Char()
date_availability = fields.Date()
date_availability = fields.Date(default=_compute_three_months_from_now(), copy=False)
expected_price = fields.Float(required=True)
selling_price = fields.Float()
selling_price = fields.Float(readonly=True, copy=False)

bedrooms = fields.Integer()
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
Expand Down
11 changes: 11 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<odoo>

<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_advertisement_menu" name="Advertisements">
<menuitem id="estate_property_menu_action" name="Properties" action="estate_property_action">
</menuitem>
</menuitem>
</menuitem>

</odoo>
10 changes: 10 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">tree,form</field>
</record>

</odoo>

0 comments on commit 9e5e90e

Please sign in to comment.