-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import property | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |