Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion awesome_dashboard/controllers/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import random

from odoo import http
from odoo.http import request

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion awesome_owl/controllers/controllers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from odoo import http
from odoo.http import request, route
from odoo.http import request

class OwlPlayground(http.Controller):
@http.route(['/awesome_owl'], type='http', auth='public')
Expand Down
2 changes: 2 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models

20 changes: 20 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "real estate",
"version": "1.0",
"summary": "Estate management",
"description": "Estate management",
"author": "Odoo S.A.",
"category": "tutorials",
"depends": ["base"],
"data": [
"security/ir.model.access.csv",
"views/estate_property_views.xml",
"views/estate_property_type_views.xml",
"views/estate_property_tag_views.xml",
"views/estate_menus.xml"
],
"license": "LGPL-3",
"application": True,
"installable": True
}

4 changes: 4 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import estate_property
from . import estate_property_type
from . import estate_property_tag

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

from odoo import fields, models
Comment on lines +1 to +3
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



class EstateProperty(models.Model):
_name = "estate.property"
_description = "Real Estate Property"

name = fields.Char(required=True)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be one line empty before the field declaration.

description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(
default=lambda self: (
# Without lambda, date would be fixed permanently
fields.Date.today() + relativedelta(months=3)
)
)
expected_price = fields.Float()
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
]
)
active = fields.Boolean(default=True)
state = fields.Selection(
[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('canceled', 'Canceled'),
],
required=True,
copy=False,
default='new'
)
buyer_id = fields.Many2one(
"res.partner",
string="Buyer",
copy=False,
)
salesperson_id = fields.Many2one(
"res.users",
string="salesperson",
default=lambda self: self.env.user,
)
property_type_id = fields.Many2one(
"estate.property.type",
string="Property Type",
)
tag_ids = fields.Many2many(
"estate.property.tag",
string="Tags",
)
# def test_tags(self):
# breakpoint()

# for tag in self.tag_ids:
# print(tag.name)

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

class EstatePropertyTag(models.Model):
_name = "estate.property.tag"
_description = "Property Tags"

name = fields.Char(required=True)


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


class EstatePropertyType(models.Model):
_name = "estate.property.type"
_description = "Property Types"

name = fields.Char(required=True)

5 changes: 5 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1
access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1

43 changes: 43 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<odoo>
<!-- Main App Menu -->
<menuitem
id="estate_menu_root"
name="Real Estate"
/>
<!--First
Level Menu-->
<menuitem
id="estate_property_menu"
name="Advertisement"
parent="estate_menu_root"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_action_menu"
name="Property List"
parent="estate_property_menu"
action="estate_property_action"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_type_menu"
name="Settings"
parent="estate_menu_root"
/>
<!--Action
Menu-->
<menuitem
id="estate_property_type_list_menu"
name="Property Type"
parent="estate_property_type_menu"
action="estate_property_type_action"
/>
<menuitem
id="estate_property_tag_menu"
name="Property Tags"
parent="estate_property_type_menu"
action="estate_property_tag_action"
/>
</odoo>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be one empty line at the end of the file.

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

<record id="estate_property_tag_view_list" model="ir.ui.view">
<field name="name">estate.property.tag.view.list</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<list>
<field name="name" />
</list>
</field>
</record>

<record id="estate_property_tag_view_form" model="ir.ui.view">
<field name="name">estate.property.tag.view.form</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="name" />
</group>
</sheet>
</form>
</field>
</record>

<record id="estate_property_tag_action" model="ir.actions.act_window">
<field name="name">Property Tags</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>

</odoo>
9 changes: 9 additions & 0 deletions estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<!--ACTION-->
<record id="estate_property_type_action" model="ir.actions.act_window">
<field name="name">Property Types</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be one empty line at the end of the file.

104 changes: 104 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<odoo>
<!--List View-->
<record id="estate_property_list_view" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Properties" delete="False">
<field name="name" />
<field name="postcode" />
<field name="bedrooms" />
<field name="living_area" />
<field name="expected_price" />
<field name="selling_price" />
<field name="date_availability" />
<field name="property_type_id" />
<field name="tag_ids" widget="many2many_tags" />
</list>
</field>
</record>
<!--Form
View-->
<record id="estate_property_form_view" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Properties">
<sheet>
<div>
<h1>
<field name="name" />
</h1>
<group>
<field name="tag_ids" widget="many2many_tags" />
</group>
</div>

<group>
<group>
<field name="property_type_id" />
<field name="postcode" />
<field name="expected_price" />
</group>

<group>
<field name="date_availability" />
<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" />
<field name="active" />
<field name="state" />
</group>
</page>

<page string="Other Info">
<group>
<field name="buyer_id" />
<field name="salesperson_id" />
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<!--Search
View-->
<record id="estate_property_search_view" model="ir.ui.view">
<field name="name">estate.property.search</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<search>
<field name="name" string="xyz" />
<field name="postcode" />
<field name="expected_price" />
<field name="bedrooms" />
<field name="living_area" />
<field name="facades" />
<filter string="Available" name="state"
domain="['|',('state','=','new'),('state','=','offer_received')]" />
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}" />
</search>
</field>
</record>

<!--ACTION-->
<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">list,form</field>
</record>
</odoo>