Skip to content

Commit

Permalink
[ADD] estate: new module created
Browse files Browse the repository at this point in the history
- New model 'property' created
- Security: give read, write, create and unlink permissions to the group base.group_user.
- Basic list, form views added
  • Loading branch information
stva-odoo committed Nov 19, 2024
1 parent b16e643 commit 68a0e8d
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 0 deletions.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
'name': 'Estate',
'version': '0.1',
'depends': ['base'],
'summary': 'Estate module',
'category': 'Tutorials/Estate',
'application': True,
'installable': True,
'license': 'AGPL-3',
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
]
}
2 changes: 2 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import property

32 changes: 32 additions & 0 deletions estate/models/property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from dateutil.relativedelta import relativedelta
from odoo import fields, models


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


class EstateProperty(models.Model):
_name = 'estate.property'
_description = "Estate Property"
name = fields.Char(required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False,
default=_default_date_availability,
string='Available from')
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer(string='Living area (sqm)')
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer(string='Garden area (sqm)')
garden_orientation = fields.Selection(
selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')])
active: bool = fields.Boolean(default=True)
state = fields.Selection(copy=False, default='New', required=True,
selection=[('New', 'New'), ('Offer Received', 'Offer Received'),
('Offer Accepted', 'Offer Accepted'), ('Sold', 'Sold'),
('Cancelled', 'Cancelled')])
2 changes: 2 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink"
"access_estate_property","access_estate_property","model_estate_property","base.group_user",1,1,1,1
75 changes: 75 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="estate_property_model_action" model="ir.actions.act_window">
<field name="name">Properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>

<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Advertisements">
<menuitem id="estate_model_menu_action" action="estate_property_model_action"/>
</menuitem>
</menuitem>

<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list>
<field name="name" string="Title"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability"/>
</list>
</field>
</record>

<record id="estate_property_view_form" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>

<field name="arch" type="xml">
<form string="Property">
<sheet>
<div class="oe_title">
<h1>
<field name="name"/>
</h1>
</div>

<group>
<group>
<field name="postcode"/>
<field name="date_availability"/>
</group>
<group>
<field name="expected_price"/>
<field name="selling_price"/>
</group>
</group>

<notebook>
<page string="Description">
<group>
<field name="description"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
</group>
</page>
</notebook>

</sheet>
</form>
</field>
</record>

</odoo>

0 comments on commit 68a0e8d

Please sign in to comment.