Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
748a2b7
[ADD] estate:taskv
tskv Nov 18, 2025
07ee005
[ADD] estate: init
tskv Nov 18, 2025
0db978f
[IMP] new model: estate_property
tskv Nov 18, 2025
b78f9c1
[IMP] estate_property:new fields
tskv Nov 18, 2025
c66d2ad
[IMP] estate: access rights
tskv Nov 18, 2025
821328f
[IMP] estate: menu + view form
tskv Nov 18, 2025
afec0e3
[IMP] estate: chapter 6 (views)
tskv Nov 19, 2025
b87b0a4
[IMP] estate: chapter 7 (relational fields)
tskv Nov 19, 2025
ae44645
[IMP] estate: chapter 8 (compute and onchange)
tskv Nov 19, 2025
898c085
[IMP] estate: chapter 9 (actions)
tskv Nov 19, 2025
347453f
[IMP] estate: chapter 10 (constraints)
tskv Nov 19, 2025
d490741
[IMP] estate: chapter11 (sprinkles)
tskv Nov 20, 2025
220923d
[IMP] estate: chapter 12 (inheritance)
tskv Nov 20, 2025
b722b3e
[ADD] estate: invoicing (chapter 13)
tskv Nov 20, 2025
64e100c
[ADD] estate: kanban view (chapter 14)
tskv Nov 21, 2025
03cee0d
[IMP] estate: chapter 15
tskv Nov 21, 2025
61dd212
[ADD] awsome_owl: task 1 + 2
tskv Nov 24, 2025
527af1f
[ADD] awsome_owl: task 3 (card)
tskv Nov 24, 2025
fceec12
[IMP] awsome_owl: task 4 (markup)
tskv Nov 24, 2025
0135233
[IMP] estate: corretions after code review
tskv Nov 24, 2025
09aff26
[IMP] awesome_owl: task 7 (todo list v1)
tskv Nov 24, 2025
16065f8
[IMP] awesome_owl: tasks 8-12 (todo list)
tskv Nov 25, 2025
5f3af82
[IMP] awesome_owl: task 13-14 (slots and toggle in cards)
tskv Nov 25, 2025
647c006
[ADD] awesome_dashboard: tasks 1-3
tskv Nov 25, 2025
67e8dc2
[ADD] estate: master_data and demo_data
tskv Nov 25, 2025
ddd9e28
[ADD] awesome_dashboard: task 4 (statistics)
tskv Nov 26, 2025
f233d5c
[IMP] awesome_dashboard: task 5
tskv Nov 26, 2025
66c4d7b
[IMP] awesome_dashboard: task 6 (pie chart)
tskv Nov 27, 2025
cd24f13
[IMP] awesome_dashboard: task 7
tskv Nov 27, 2025
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
3 changes: 3 additions & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

Choose a reason for hiding this comment

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

The odoo license in every file is not needed anymore. You can remove it!

from . import models
24 changes: 24 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
'name': "Real Estate",
'version': '1.0',
'depends': ['base'],
'author': "taskv",
'category': 'Tutorials',
'description': """
Tutorial Project
""",
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_menus.xml',
'views/res_users_views.xml',
],
'demo': [
],
Comment on lines 20 to 22

Choose a reason for hiding this comment

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

you don't need to specify demo if it's empty

'installable': True,
'application': True,
'license': 'LGPL-3',
}
7 changes: 7 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

Choose a reason for hiding this comment

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

Also you can remove that license, it's not needed anymore for any new odoo files

from . import estate_property
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import res_users
Comment on lines 1 to 5

Choose a reason for hiding this comment

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

You just need to sort all imports by alphabetical order like here
https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#imports
Screenshot 2025-11-21 at 10 39 33

107 changes: 107 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models, api, exceptions
from odoo.tools.float_utils import float_is_zero, float_compare


class EstateProperty(models.Model):
_name = 'estate.property'
_description = 'Estate Property'
_order = "id desc"

name = fields.Char('Title', required=True, default='Unknown', translate='True')
active = fields.Boolean('Active', default=True)
description = fields.Text('Description')
postcode = fields.Char('Postcode')
date_availability = fields.Date('Available From', copy=False, default=fields.Date.add(fields.Date.today(), months=3))
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price', readonly=True, copy=False)
bedrooms = fields.Integer('Bedrooms', default=2)
living_area = fields.Integer('Living Area (sqm)')
facades = fields.Integer('Facades')
garage = fields.Boolean('Garage')
garden = fields.Boolean('Garden')
garden_area = fields.Integer('Garden Area (sqm)')
garden_orientation = fields.Selection(string='Garden orientation',
selection=[('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')]
)

Choose a reason for hiding this comment

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

This indentation is a little bit strange, I would do something like this

Suggested change
garden_orientation = fields.Selection(string='Garden orientation',
selection=[('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')]
)
garden_orientation = fields.Selection(
string='Garden orientation',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West'),
],
)

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

Choose a reason for hiding this comment

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

Same, the indent is a little bit weird, it looks better to just have one argument per line here

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

property_type_id = fields.Many2one('estate.property.type', string='Property Type')
property_tag_ids = fields.Many2many('estate.property.tag', string='Property Tag')
buyer_id = fields.Many2one('res.partner', string='Buyer', copy=False,
domain=[('is_company', '=', False)])
salesperson_id = fields.Many2one('res.users', string='Salesperson',
default=lambda self: self.env.user)
offer_ids = fields.One2many('estate.property.offer', 'property_id', string='Offers')
total_area = fields.Integer('Total Area (sqm)', compute='_compute_total_area')
best_offer = fields.Float('Best Offer', compute='_compute_best_offer')

_check_expected_price = models.Constraint(
'CHECK(expected_price > 0)',
'The expected price must be strictly positive',
)

_check_selling_price = models.Constraint(
'CHECK(selling_price >= 0)',
'The selling price must be positive',
)

@api.depends('garden_area', 'living_area')
def _compute_total_area(self):
for record in self:
record.total_area = record.garden_area + record.living_area

@api.depends('offer_ids.price')
def _compute_best_offer(self):
for record in self:
if record.offer_ids:
record.best_offer = max(record.offer_ids.mapped('price'))
else:
record.best_offer = 0

Choose a reason for hiding this comment

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

you can just do this

Suggested change
if record.offer_ids:
record.best_offer = max(record.offer_ids.mapped('price'))
else:
record.best_offer = 0
record.best_offer = max(record.offer_ids.mapped('price'), default=0.0)


@api.constrains('selling_price', 'expected_price')
def _check_selling_price(self):
for record in self:
if not float_is_zero(record.selling_price, 4) and float_compare(record.selling_price,
record.expected_price * 0.9, 4) < 0:
raise exceptions.ValidationError("The selling price must be at least 90% of the expected price.")

@api.onchange('garden')
def _onchange_garden(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = 'north'
else:
self.garden_area = 0
self.garden_orientation = ''

@api.ondelete(at_uninstall=False)
def _unlink_check_state(self):
for record in self:
if record.state not in ('new', 'cancelled'):
raise exceptions.UserError("Only new and cancelled properties can be deleted.")

def action_property_sold(self):
self.ensure_one()
if self.state != 'cancelled':
self.state = 'sold'
else:
raise exceptions.UserError("Cancelled properties cannot be sold.")
return True

def action_property_cancelled(self):
self.ensure_one()
if self.state != 'sold':
self.state = 'cancelled'
else:
raise exceptions.UserError("Sold properties cannot be cancelled.")
return True
59 changes: 59 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

Choose a reason for hiding this comment

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

Same, you don't need to put the odoo license in every file anymore


from odoo import fields, models, api, exceptions
from datetime import date, timedelta


class EstatePropertyOffer(models.Model):
_name = 'estate.property.offer'
_description = 'Estate Property Offer'
_order = "price desc"

price = fields.Float(string='Price')
status = fields.Selection(string='Status', copy=False,
selection=[('accepted', 'Accepted'), ('refused', 'Refused')])

Choose a reason for hiding this comment

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

Same, this indentation looks a little bit strange. When you have multiline arguments IMO it's better to do one argument per line

Suggested change
status = fields.Selection(string='Status', copy=False,
selection=[('accepted', 'Accepted'), ('refused', 'Refused')])
status = fields.Selection(
string='Status',
copy=False,
selection=[('accepted', 'Accepted'), ('refused', 'Refused')]
)

partner_id = fields.Many2one('res.partner', string='Customer', required=True)
property_id = fields.Many2one('estate.property', string='Property', required=True)
validity = fields.Integer(string='Validity (days)', default=7)
date_deadline = fields.Date(string='Deadline', compute='_compute_deadline', inverse='_inverse_deadline')
property_type_id = fields.Many2one('estate.property.type', string='Property Type', related="property_id.property_type_id", store=True)

_check_price = models.Constraint(
'CHECK(price > 0)',
'The offer price must be strictly positive',
)

@api.depends('validity')
def _compute_deadline(self):
for record in self:
record.date_deadline = (record.create_date if record.create_date else date.today()) + timedelta(days=record.validity)

def _inverse_deadline(self):
for record in self:
record.validity = (record.date_deadline - (record.create_date.date() if record.create_date else date.today())).days

@api.model

Choose a reason for hiding this comment

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

You already support a list of dicts, you can add @api.model_create_multi decorator

def create(self, vals_list):
for vals in vals_list:
if 'property_id' in vals and vals.get('property_id'):

Choose a reason for hiding this comment

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

You are checking almost the same condition twice

Suggested change
if 'property_id' in vals and vals.get('property_id'):
if vals.get('property_id'):

current_property = self.env['estate.property'].browse(vals['property_id'])
if 'price' in vals and current_property.best_offer > vals.get('price', 0):
raise exceptions.ValidationError(f'The offer must be higher than {current_property.best_offer}')

Choose a reason for hiding this comment

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

Not a problem for the tutorial, but with an actual module, we usually don't use fstrings for errors, as you cannot translate these

Here is an example of how we usually format translated strings with parameters
https://github.com/odoo/odoo/blob/fc658b2e3d9c5afbfa5d00b579bf8928a90dab87/addons/barcodes/models/barcode_rule.py#L41

if current_property.state == 'new':
current_property.state = 'offer_received'
return super().create(vals_list)

def action_accept(self):
self.ensure_one()
if self.property_id.state in ('new', 'offer_received'):
self.property_id.state = 'offer_accepted'
self.status = 'accepted'
self.property_id.selling_price = self.price
self.property_id.buyer_id = self.partner_id
return True

def action_refuse(self):
self.ensure_one()
if not self.status:
self.status = 'refused'
return True
17 changes: 17 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

Choose a reason for hiding this comment

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

No need license


from odoo import fields, models


class EstatePropertyTag(models.Model):
_name = 'estate.property.tag'
_description = 'Estate Property Tag'
_order = "name"

Choose a reason for hiding this comment

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

little nitpick, although not everybody respects that at odoo, we have somewhat of a convention for using single vs double quotes. Everything that is user-facing (e.i. everything an end-user will see) is usually double-quoted. Everything else is single quoted (so mostly technical strings).

Suggested change
_description = 'Estate Property Tag'
_order = "name"
_description = "Estate Property Tag"
_order = 'name'


name = fields.Char(string='Property Tag', required=True)
color = fields.Integer()

_tag_name_uniq = models.Constraint(
'unique(name)',
"The property tag name must be unique",
)
25 changes: 25 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models, api


class EstatePropertyType(models.Model):
_name = 'estate.property.type'
_description = 'Estate Property Type'
_order = "sequence, name"

name = fields.Char('Property Type', required=True)
property_ids = fields.One2many('estate.property', 'property_type_id', 'Properties')
offer_ids = fields.One2many('estate.property.offer', 'property_type_id', 'Offers')
offer_count = fields.Integer(compute='_compute_offer_count')
sequence = fields.Integer()

_type_name_uniq = models.Constraint(
'unique(name)',
"The property type name must be unique",
)

@api.depends('offer_ids')
def _compute_offer_count(self):
for record in self:
record.offer_count = len(record.offer_ids)
10 changes: 10 additions & 0 deletions estate/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import fields, models


class Users(models.Model):
_inherit = 'res.users'

property_ids = fields.One2many('estate.property', 'salesperson_id', string='Estate Property',
domain=[('date_availability', '<=', fields.Date.today())])
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
access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1
29 changes: 29 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<odoo>
<menuitem
id="estate_menu_root"
name="Real Estate"/>
<menuitem
id="properties_menu"
name="Properties"
parent="estate_menu_root"
action="estate_property_action"
sequence="1"/>
<menuitem
id="settings_menu"
name="Settings"
parent="estate_menu_root"
sequence="2"/>
<menuitem
id="properties_type_menu"
name="Property Types"
parent="settings_menu"
action="estate_property_type_action"
sequence="1"/>
<menuitem
id="properties_tag_menu"
name="Property Tags"
parent="settings_menu"
action="estate_property_tag_action"
sequence="2"/>
</odoo>
49 changes: 49 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_offer_view_form" model="ir.ui.view">
<field name="name">estate.property.offer.view.form</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form string="Estate Property Offer">
<sheet>
<group>
<group>
<field name="price"/>
<field name="partner_id"/>
</group>
<group>
<field name="validity"/>
<field name="date_deadline"/>
<field name="status"/>
</group>
</group>
</sheet>
</form>
</field>
</record>

<record id="estate_property_offer_view_list" model="ir.ui.view">
<field name="name">estate.property.offer.view.list</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list string="Estate Property Offer" editable="bottom"
decoration-success="status == 'accepted'"
decoration-danger="status == 'refused'">
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<button name="action_accept" title="Accept" type="object" icon="fa-check" invisible="status"/>
<button name="action_refuse" title="Refuse" type="object" icon="fa-close" invisible="status"/>
Comment on lines +36 to +37

Choose a reason for hiding this comment

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

these invisibles don't seem correct. I think it should be status in ('accepted', 'refused')

Copy link
Author

Choose a reason for hiding this comment

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

Let me explain why I've done like this.
The "status" is a selection-field with two possible values ('accepted' or 'refused'). According to the tutorial task, if it is defined, we don't need to show these two buttons. We want to see them only if "status" is empty yet.
So i thought in this case invisible="status" should also work fine

</list>
</field>
</record>

<record id="estate_property_offer_action" model="ir.actions.act_window">
<field name="name">Offers</field>
<field name="res_model">estate.property.offer</field>
<field name="view_mode">list,form</field>
<field name="domain">[('property_type_id','=',active_id)]</field>

Choose a reason for hiding this comment

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

Suggested change
<field name="domain">[('property_type_id','=',active_id)]</field>
<field name="domain">[('property_type_id', '=', active_id)]</field>

</record>

</odoo>
35 changes: 35 additions & 0 deletions estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<odoo>
<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 string="Estate Property Tag">
<sheet>
<group>
<field name="name"/>
<field name="color" widget="color_picker"/>
</group>
</sheet>
</form>
</field>
</record>

<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 string="Estate Property Tag" editable="bottom">
<field name="name"/>
<field name="color" widget="color_picker"/>
</list>
</field>
</record>

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

</odoo>
Loading