Skip to content
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

16 changes: 16 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
'name': 'estate',
'summary': 'Estate Module for the Tutorial',
'author': 'manab',
'license': 'LGPL-3',
'data': [
'views/estate_property_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_menu_views.xml',
'security/ir.model.access.csv',
]
}


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


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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do not forget the make your runbot green, for instance here it should complain because it does not have two lines before the class definition.

class Property(models.Model):
_name = "estate_property"
_description = "estate property model"

name = fields.Char('Nom', required=True)
description = fields.Text('Description')
postcode = fields.Char('Post Code')
date_availability = fields.Date('Date Availability', copy=False, default=fields.Date.add(fields.Date.today(), months=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.

here default should use a lambda function otherwise the default would be static depending on when the server started not at record creation.

expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Prince', readonly=True, copy=False)
bedrooms = fields.Integer('# Bedrooms', default=2)
living_area = fields.Integer('# Living Areas')
facades = fields.Integer('# Facades')
garage = fields.Boolean('Has Garage')
garden = fields.Boolean('Has Garden')
garden_area = fields.Integer('# Garden Areas')
garden_orientation = fields.Selection(
string = 'Garden Orientation',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')
]
)
active = fields.Boolean('Active', default=True)
state = fields.Selection(
string='State',
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled')
],
required=True,
copy=False,
default='new'
)
Comment on lines +29 to +41

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
state = fields.Selection(
string='State',
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled')
],
required=True,
copy=False,
default='new'
)
state = fields.Selection(
string='State',
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled')
],
required=True,
copy=False,
default='new',
)

Be careful at your indentation as well as the final comma, it is better to always add it so that later if someone wants to add a new line in here, it won't trigger a diff on the final line you added.


salesperson = fields.Many2one('res.users', string='Salesperson', index=True, tracking=True, default=lambda self: self.env.user)
buyer = fields.Many2one('res.partner', string="Buyer", copy=False)

tag_ids = fields.Many2many('estate_property.tag', string='Tags')

offer_ids = fields.One2many('estate_property.offer', 'property_id', string='Offer')



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

class EstatePropertyOffer(models.Model):
_name = "estate_property.offer"
_description = "Offer to the Estate"

name = fields.Char('Nom', required=True)
price = fields.Float('Price')
status = fields.Selection(
string="Status",
selection=[
('accepted', "Accepted"),
('refused', "Refused")
]
)
partner_id = fields.Many2one('res.partner', string="Partner", required=True)
property_id = fields.Many2one('estate_property', string="Property", required=True)




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

class EstatePropertyTag(models.Model):
_name = "estate_property.tag"
_description = "Tag of Estate Property"

name = fields.Char('Nom', 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 models, fields

class EstatePropertyType(models.Model):
_name = "estate_property.type"
_description = "Types of Estate Property"

name = fields.Char('Nom', required=True)


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

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

<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_menu_first_level" name="Advertisements" sequence="1">
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="settings" name="Settings" sequence="2">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>

</menuitem>


</odoo>

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

<odoo>

<record id="estate_property_offer_list" model="ir.ui.view">
<field name="name">estate_properties.offer_list</field>
<field name="model">estate_property.offer</field>
<field name="arch" type="xml">
<list string="Channel">
<field name='name' string="Name"/>
<field name='price' string="Price"/>
<field name='status' string="Status"/>
<field name='partner_id' string="Partner"/>
<field name='property_id' string="Property"/>
</list>
</field>
</record>

</odoo>

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

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

</odoo>

10 changes: 10 additions & 0 deletions estate/views/estate_property_type_views.xml

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should avoid pushing empty files but I guess it is because you are working on it. But just in case 😄

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_type_action" model="ir.actions.act_window">
<field name="name">Property Type</field>
<field name="res_model">estate_property.type</field>
<field name="view_mode">list,form</field>
</record>

</odoo>
111 changes: 111 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?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">list,form</field>
</record>

<record id="estate_property_list" model="ir.ui.view">
<field name="name">estate_properties.list</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<list string="Channel">
<field name="name" string="Title"/>
<field name="postcode" string="Postcode"/>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="Selling Price"/>
<field name="date_availability" string="Available From"/>
</list>
</field>
</record>

<record id="etstate_property_form" model="ir.ui.view">
<field name="name">estate_properties.form</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<form string="Properties">
<sheet>
<h1>
<field name="name"/>
</h1>

<div class="row align-items-start">
<div class="col">
<group>
<field name="postcode" string="Postcode"/>
<field name="date_availability" string="Available From"/>
</group>
</div>
<div class="col">
<group>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="Selling Price"/>
</group>
</div>
<notebook>
<page string="Description">
<group>
<field name="description" string="Description"/>
</group>
<group>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades" string="Facades"/>
<field name="garage" string="Garage"/>
</group>
<group>
<field name="garden" string="Garden"/>
<field name="garden_area" string="Garden Area (sqm)"/>
<field name="garden_orientation" string="Garden Orientation"/>
</group>
<group>
<field name="state" string="State"/>
</group>
Comment on lines +51 to +67

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why doing so many groups ?

</page>
<page string="Offers">
<list>
<field name='offer_ids'/>
</list>

</page>
<page string="Other Info">
<group>
<field name="salesperson" string="Salesperson"/>
<field name="buyer" string="Buyer"/>
</group>
</page>
</notebook>
</div>
</sheet>
</form>
</field>
</record>


<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate_property.view.search</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<search string="Properties">
<field name="name" string="Title"/>
<field name="postcode" string="Postcode"/>
<field name="bedrooms" string="Bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price" string="Expected Price"/>
<field name="selling_price" string="Selling Price"/>
<separator/>
<filter name="active" string="Available" domain="[('state', 'in', ('new', 'offer_received'))]"/>
<separator/>
<group>
<filter string="Postcode" name="postcode" context="{'group_by':'postcode'}"/>
</group>
</search>
</field>
</record>
</odoo>