-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[ADD] estate: New module to manage estates #814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
baje-odoo
wants to merge
42
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-fix-invoices-baje
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 21 commits
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
5e4d31e
[ADD] estate: Creating apps and models
baje-odoo 23ad338
[IMP] estate: Add Security rules
baje-odoo 902379a
[IMP] estate: Add fields and parameters to models estate_property
baje-odoo 9420b3a
[IMP] estate: Add list view
baje-odoo ef18c3f
[FIX] estate: pipeline fix
baje-odoo 1be0e7a
[IMP] estate: Add form view
baje-odoo 8ec4cb4
[IMP] estate: Add Searchbar view
baje-odoo 9182210
[IMP] estate: Add many2one relations
baje-odoo c316dd2
[IMP] estate: Add many2many relations
baje-odoo b398197
[IMP] estate: Add one2many relations
baje-odoo 5786a59
[IMP] estate: Add compute and inverse
baje-odoo 0422878
[IMP] estate: Add onchange method
baje-odoo 2949458
[IMP] estate: Add buttons
baje-odoo 9d776f7
[IMP] estate: Add constraints
baje-odoo 1d69faf
[IMP] estate: Add Inline views - widgets - list order - attributes
baje-odoo 716c663
[IMP] estate: Add stat button
baje-odoo 2a00cff
[IMP] estate: Add create and delete conditions - user inheritance
baje-odoo bfdb4ba
[ADD] estate_account: Add link between estate and account
baje-odoo 9a0df1a
[IMP] estate: Add kanban view
baje-odoo 199b3c2
[IMP] estate: Add more informations on cards
baje-odoo d5a3567
[REF] estate: Refactoring to the coding guidelines
baje-odoo 2c139ac
[ADD] awesome_owl: implement counter and card
baje-odoo 290ffe1
[IMP] awesome_owl: Add Markup use to card
baje-odoo 2ad352d
[IMP] awesome_owl: Add validation - callbacks - foreach
baje-odoo 58f4c23
[IMP] awesome_owl: Add dynamic attributes and event handler
baje-odoo 9644d50
[IMP] awesome_owl: Add autofocus on todo list
baje-odoo 3355116
[IMP] awesome_owl: Add deleting button on todo items
baje-odoo 4a021e2
[IMP] awesome_owl: Add slots
baje-odoo 374b700
[IMP] awesome_owl: Add t-if
baje-odoo e7ab77e
[ADD] awesome_dashboard: Add base layout
baje-odoo 82592bd
[IMP] awesome_dashboard: Add navigation and dashboard item
baje-odoo fa0e393
[IMP] awesome_dashboard: Call the server to show statistics
baje-odoo d704def
[IMP] awesome_dashboard: Add statistics service
baje-odoo e0c0418
[IMP] awesome_dashboard: Add pie chart
baje-odoo d2cdb2a
[IMP] awesome_dashboard: reactive use
baje-odoo a0dabb8
[MOV] awesome_dashboard: made bundle folder for dashboard
baje-odoo 1207f8c
[MOV] awesome_dashboard: made a pie chart folder
baje-odoo a5d023c
[IMP] awesome_dashboard: Generic Dashboard
baje-odoo 8f2fe66
[IMP] awesome_dashboard: Extensible Dashboard
baje-odoo 35aa75a
[IMP] awesome_dashboard: Add a dialog to configure the items
baje-odoo cf8ca37
[IMP] estate: Add master and demo data
baje-odoo 1595efc
[IMP] estate: Add demo offers
baje-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -126,4 +126,4 @@ venv.bak/ | |
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
.pyre/ |
This file contains hidden or 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,3 @@ | ||
{ | ||
"python.languageServer": "None" | ||
} |
This file contains hidden or 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 hidden or 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,21 @@ | ||
{ | ||
'name': "estate", | ||
'version': '18.0.1.0.0', | ||
'depends': ['base'], | ||
'data': [ | ||
'security/ir.model.access.csv', | ||
'views/estate_property_views.xml', | ||
'views/estate_property_offer_views.xml', | ||
'views/estate_property_tag_views.xml', | ||
'views/estate_property_type_views.xml', | ||
'views/res_users_views.xml', | ||
'views/estate_menus.xml', | ||
], | ||
'author': "baje", | ||
'category': 'Uncategorized', | ||
'description': """ | ||
An app to manage a Real Estate Agency | ||
""", | ||
'application': True, | ||
'license': 'LGPL-3', | ||
} |
This file contains hidden or 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,5 @@ | ||
from . import estate_property | ||
from . import estate_property_type | ||
from . import estate_property_tag | ||
from . import estate_property_offer | ||
from . import res_users |
This file contains hidden or 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,104 @@ | ||
from odoo import fields, models, api, _ | ||
from dateutil.relativedelta import relativedelta | ||
from odoo.exceptions import UserError, ValidationError | ||
from odoo.tools.float_utils import float_compare, float_is_zero | ||
|
||
|
||
class EstateProperty(models.Model): | ||
"""Model representing a real estate property.""" | ||
|
||
_name = "estate.property" | ||
_description = "Real Estate Properties" | ||
_order = "id desc" | ||
_sql_constraints = [ | ||
('check_expected_price', 'CHECK(expected_price > 0 )', 'Expected price must be strictly positive.'), | ||
('check_selling_price', 'CHECK(selling_price >= 0 )', 'Selling price must be positive.'), | ||
] | ||
|
||
def _default_date_availability(self): | ||
return fields.Date.today() + relativedelta(months=3) | ||
|
||
name = fields.Char("Title", required=True) | ||
description = fields.Text("Description") | ||
postcode = fields.Char("Postcode") | ||
date_availability = fields.Date("Available From", default=_default_date_availability) | ||
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"), | ||
], | ||
) | ||
active = fields.Boolean("Active", default=True) | ||
state = fields.Selection( | ||
string="Status", | ||
selection=[ | ||
('new', "New"), | ||
('offer_received', "Offer Received"), | ||
('offer_accepted', "Offer Accepted"), | ||
('sold', "Sold"), | ||
('canceled', "Canceled"), | ||
], | ||
required=True, | ||
copy=False, | ||
default="new", | ||
) | ||
property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
user_id = fields.Many2one("res.users", string="Salesman", default=lambda self: self.env.user) | ||
buyer_id = 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="Offers") | ||
total_area = fields.Integer("Total Area (sqm)", compute="_compute_total_area") | ||
best_price = fields.Float("Best Offer", compute="_compute_best_price") | ||
|
||
@api.depends("living_area", "garden_area") | ||
def _compute_total_area(self): | ||
for record in self: | ||
record.total_area = record.living_area + record.garden_area | ||
|
||
@api.depends("offer_ids.price") | ||
def _compute_best_price(self): | ||
for record in self: | ||
record.best_price = max(record.offer_ids.mapped("price")) if record.offer_ids else 0.0 | ||
|
||
@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 = False | ||
|
||
def action_sold(self): | ||
for record in self: | ||
if record.state == 'canceled': | ||
raise UserError(_("Canceled properties cannot be sold.")) | ||
record.state = 'sold' | ||
|
||
def action_cancel(self): | ||
for record in self: | ||
if record.state == 'sold': | ||
raise UserError(_("Sold properties cannot be canceled.")) | ||
record.state = 'canceled' | ||
|
||
@api.constrains('expected_price', 'selling_price') | ||
def _check_selling_price(self): | ||
for record in self: | ||
if not float_is_zero(record.selling_price, precision_rounding=0.01) and float_compare(record.selling_price, record.expected_price * 0.9, precision_rounding=0.01) < 0: | ||
raise ValidationError(_("The selling price cannot be lower than 90% of the expected price.")) | ||
|
||
@api.ondelete(at_uninstall=False) | ||
def _unlink_if_state_is_new_or_cancelled(self): | ||
if any(record.state not in ('new', 'canceled') for record in self): | ||
raise UserError(_("Only new and canceled properties can be deleted.")) |
This file contains hidden or 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,65 @@ | ||
from odoo import fields, models, api, _ | ||
from dateutil.relativedelta import relativedelta | ||
from odoo.exceptions import UserError | ||
from odoo.tools.float_utils import float_compare | ||
|
||
|
||
class EstatePropertyOffer(models.Model): | ||
"""Model representing an offer for a real estate property.""" | ||
|
||
_name = "estate.property.offer" | ||
_description = "Real Estate Property Offers" | ||
_order = "price desc" | ||
_sql_constraints = [ | ||
('check_offer_price', 'CHECK(price > 0)', 'An offer price must be strictly positive.'), | ||
] | ||
|
||
price = fields.Float(string="Price") | ||
status = fields.Selection( | ||
string="Status", | ||
selection=[ | ||
('accepted', "Accepted"), | ||
('refused', "Refused"), | ||
], | ||
copy=False, | ||
) | ||
partner_id = fields.Many2one("res.partner", string="Partner", required=True) | ||
property_id = fields.Many2one("estate.property", string="Property", required=True) | ||
validity = fields.Integer("Validity (days)", default=7) | ||
deadline = fields.Date("Deadline", compute="_compute_deadline", inverse="_inverse_deadline") | ||
property_type_id = fields.Many2one( | ||
"estate.property.type", related="property_id.property_type_id", string="Property Type") | ||
|
||
@api.depends("validity") | ||
def _compute_deadline(self): | ||
for record in self: | ||
record.deadline = fields.Date.today() + relativedelta(days=record.validity) | ||
|
||
def _inverse_deadline(self): | ||
for record in self: | ||
record.validity = (record.deadline - fields.Date.today()).days | ||
|
||
def action_accept(self): | ||
if 'accepted' in self.mapped("property_id.offer_ids.status"): | ||
raise UserError(_("An offer is already accepted.")) | ||
for record in self: | ||
record.status = 'accepted' | ||
record.property_id.state = 'offer_accepted' | ||
record.property_id.buyer_id = record.partner_id | ||
record.property_id.selling_price = record.price | ||
|
||
def action_refuse(self): | ||
for record in self: | ||
record.status = 'refused' | ||
|
||
@api.model_create_multi | ||
def create(self, values): | ||
for vals in values: | ||
if vals.get("property_id") and vals.get("price"): | ||
prop = self.env["estate.property"].browse(vals["property_id"]) | ||
if prop.offer_ids: | ||
max_offer = max(prop.mapped("offer_ids.price")) | ||
if float_compare(vals["price"], max_offer, precision_rounding=0.01) <= 0: | ||
raise UserError(_("The offer must be higher than %.2f."), max_offer) | ||
prop.state = "offer_received" | ||
return super().create(values) |
This file contains hidden or 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,15 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class EstatePropertyTag(models.Model): | ||
"""Model representing a property tag.""" | ||
|
||
_name = "estate.property.tag" | ||
_description = "Real Estate Property Tag" | ||
_order = "name" | ||
_sql_constraints = [ | ||
('unique_name', 'UNIQUE(name)', 'The tag name must be unique.'), | ||
] | ||
|
||
name = fields.Char("Name", required=True) | ||
color = fields.Integer("Color") |
This file contains hidden or 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,28 @@ | ||
from odoo import fields, models, api | ||
|
||
|
||
class EstatePropertyType(models.Model): | ||
"""Model representing a property type.""" | ||
|
||
_name = "estate.property.type" | ||
_description = "Real Estate Property Type" | ||
_order = "name" | ||
_sql_constraints = [ | ||
('unique_name', 'UNIQUE(name)', 'The type name must be unique.'), | ||
] | ||
|
||
name = fields.Char("Name", required=True) | ||
sequence = fields.Integer("Sequence", default=10) | ||
property_ids = fields.One2many("estate.property", "property_type_id", string="Properties") | ||
offer_ids = fields.One2many("estate.property.offer", "property_type_id", string="Offers") | ||
offer_count = fields.Integer(string="Offers Count", compute="_compute_offer_count") | ||
|
||
@api.depends('offer_ids') | ||
def _compute_offer_count(self): | ||
for record in self: | ||
record.offer_count = len(record.offer_ids) | ||
|
||
def action_view_offers(self): | ||
res = self.env.ref("estate.estate_property_offer_action").read()[0] | ||
res["domain"] = [("id", "in", self.offer_ids.ids)] | ||
return res |
This file contains hidden or 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,11 @@ | ||
from odoo import fields, models | ||
|
||
|
||
class ResUsers(models.Model): | ||
"""Model extending users""" | ||
|
||
_inherit = "res.users" | ||
|
||
property_ids = fields.One2many( | ||
"estate.property", "user_id", string="Properties", domain=[("state", "in", ["new", "offer_received"])], | ||
) |
This file contains hidden or 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,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 |
This file contains hidden or 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,11 @@ | ||
<odoo> | ||
<menuitem id="estate_menu_root" name="Real Estate"> | ||
<menuitem id="estate_advertisement_menu" name="Advertisements"> | ||
<menuitem id="estate_property_menu_action" action="estate_property_action"/> | ||
</menuitem> | ||
<menuitem id="estate_settings_menu" name="Settings"> | ||
<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> |
This file contains hidden or 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,19 @@ | ||
<odoo> | ||
<record id="estate_property_offer_action" model="ir.actions.act_window"> | ||
<field name="name">Property Offers</field> | ||
<field name="res_model">estate.property.offer</field> | ||
<field name="view_mode">list,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="Property Offers" editable="bottom" decoration-success="status == 'accepted'" decoration-danger="status == 'refused'"> | ||
<field name="price"/> | ||
<field name="partner_id"/> | ||
<button name="action_accept" type="object" title="Accept" icon="fa-check"/> | ||
<button name="action_refuse" type="object" title="Refuse" icon="fa-times"/> | ||
</list> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains hidden or 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,16 @@ | ||
<odoo> | ||
<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> | ||
<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="Property Tags" editable="bottom"> | ||
<field name="name"/> | ||
</list> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains hidden or 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,51 @@ | ||
<odoo> | ||
<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> | ||
<record id="estate_property_type_view_form" model="ir.ui.view"> | ||
<field name="name">estate.property.type.view.form</field> | ||
<field name="model">estate.property.type</field> | ||
<field name="arch" type="xml"> | ||
<form> | ||
<sheet> | ||
<div class="oe_title"> | ||
<h1> | ||
<field name="name"/> | ||
</h1> | ||
</div> | ||
<div class="oe_button_box" name="button_box"> | ||
<button name="action_view_offers" | ||
type="object" | ||
class="oe_stat_button" | ||
icon="fa-tags"> | ||
<field name="offer_count" widget="statinfo" string="Offers"/> | ||
</button> | ||
</div> | ||
<notebook> | ||
<page string="Properties"> | ||
<field name="property_ids"> | ||
<list> | ||
<field name="name"/> | ||
<field name="expected_price"/> | ||
<field name="state"/> | ||
</list> | ||
</field> | ||
</page> | ||
</notebook> | ||
</sheet> | ||
</form> | ||
</field> | ||
</record> | ||
<record id="estate_property_type_view_list" model="ir.ui.view"> | ||
<field name="name">estate.property.type.view.list</field> | ||
<field name="model">estate.property.type</field> | ||
<field name="arch" type="xml"> | ||
<list string="Types"> | ||
<field name="sequence" widget="handle" /> | ||
<field name="name"/> | ||
</list> | ||
</field> | ||
</record> | ||
</odoo> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, on real PRs, such files wouldn't be included.