-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[ADD] estate_gasa,*: Implemented Real Estate with Accounting using Account Module #843
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
Draft
gasa-odoo
wants to merge
9
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-training-gasa
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.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7aaf839
[ADD] real_estate: Create Our First App
gasa-odoo 8b76f10
[ADD] real_estate: give some basic UI to New Applicataion
gasa-odoo 26fc1ca
[ADD] real_estate: add four model in our application
gasa-odoo d48f4ad
[IMP] real_estate: add SQL constraints and UI improvements for proper…
gasa-odoo 1a7732c
[ADD] estate_account: link one module with other module
gasa-odoo 567b121
[FIX] real_estate: fixing error in odoo formate
gasa-odoo d337c6c
[FIX] real_estate: fixing space error in odoo formate
gasa-odoo baf7908
[IMP] real_estate: apply Odoo coding guidelines to naming conventions
gasa-odoo e93d96c
[IMP] real_estate: restrict access date and define module data
gasa-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 |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# Ignore VS Code settings | ||
.vscode/ |
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 @@ | ||
{ | ||
"recommendations": [ | ||
"esbenp.prettier-vscode" | ||
] | ||
} | ||
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,2 @@ | ||
# License LGPL-3 | ||
from . import models | ||
gasa-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
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,10 @@ | ||
{ | ||
'name': "Account", | ||
'version': '1.0', | ||
'depends': ['base', 'estate_gasa', 'account'], | ||
'author': "gasa", | ||
'category': 'Category', | ||
"license": "LGPL-3", | ||
"application": True, | ||
"sequence": 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 @@ | ||
from . import estate |
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,43 @@ | ||
from odoo import models, Command | ||
from odoo.exceptions import UserError | ||
|
||
|
||
class Estate(models.Model): | ||
_inherit = 'estate.property' | ||
|
||
def action_mark_sold(self): | ||
self.check_access_rights('write') | ||
self.check_access_rule('write') | ||
res = super().action_mark_sold() | ||
|
||
journal = self.env['account.journal'].sudo().search([('type', '=', 'sale')], limit=1) | ||
if not journal: | ||
raise UserError("No sale journal found. Please configure at least one sale journal.") | ||
|
||
for record in self: | ||
if not record.buyer: | ||
raise UserError("Please set a Buyer before generating an invoice.") | ||
if not record.selling_price: | ||
raise UserError("Please set a Selling Price before generating an invoice.") | ||
|
||
invoice_vals = { | ||
"partner_id": record.buyer.id, | ||
"move_type": "out_invoice", | ||
"journal_id": journal.id, | ||
"invoice_line_ids": [ | ||
Command.create({ | ||
"name": "6% Commission", | ||
"quantity": 1, | ||
"price_unit": 0.06 * record.selling_price, | ||
}), | ||
Command.create({ | ||
"name": "Administrative Fees", | ||
"quantity": 1, | ||
"price_unit": 100.0, | ||
}), | ||
] | ||
} | ||
|
||
self.env["account.move"].sudo().create(invoice_vals) | ||
|
||
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,2 @@ | ||
# License LGPL-3 | ||
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,25 @@ | ||
{ | ||
'name': "estate", | ||
'version': '1.0', | ||
'depends': ['base'], | ||
'author': "gasa", | ||
'category': 'Real Estate/Brokerage', | ||
"license": "LGPL-3", | ||
"application": True, | ||
"sequence": 1, | ||
'data': [ | ||
'security/security.xml', | ||
'security/ir.model.access.csv', | ||
'security/estate_property_rules.xml', | ||
'data/estate.property.type.csv', | ||
'views/estate_property_views.xml', | ||
'views/estate_property_offer_views.xml', | ||
'views/estate_property_type_views.xml', | ||
'views/estate_tag_views.xml', | ||
'views/inherited_model.xml', | ||
'views/estate_menus.xml' | ||
], | ||
"demo": [ | ||
'demo/estate_property_demo_data.xml', | ||
], | ||
} |
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 | ||
estate_property_type_residential,Residential | ||
estate_property_type_commercial,Commercial | ||
estate_property_type_industrial,Industrial | ||
estate_property_type_land,Land |
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,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<odoo> | ||
<record id="demo_property_big_villa" model="estate.property"> | ||
<field name="name">Big Villa</field> | ||
<field name="state">new</field> | ||
<field name="description">A nice and big villa</field> | ||
<field name="postcode">12345</field> | ||
<field name="date_availability">2025-07-10</field> | ||
<field name="expected_price">97000</field> | ||
<field name="selling_price">97000</field> | ||
<field name="bedrooms">6</field> | ||
<field name="living_area">100</field> | ||
<field name="facades">4</field> | ||
<field name="garage">True</field> | ||
<field name="garden">True</field> | ||
<field name="garden_area">100</field> | ||
<field name="garden_orientation">south</field> | ||
<field name="property_type" ref="estate_property_type_residential" /> | ||
</record> | ||
|
||
<record id="demo_property_trailer_home" model="estate.property"> | ||
<field name="name">Trailer home</field> | ||
<field name="state">cancelled</field> | ||
<field name="description">Home in a trailer park</field> | ||
<field name="postcode">54321</field> | ||
<field name="date_availability">2025-07-10</field> | ||
<field name="expected_price">1000</field> | ||
<field name="selling_price">1000</field> | ||
<field name="bedrooms">2</field> | ||
<field name="living_area">100</field> | ||
<field name="facades">4</field> | ||
<field name="garage">True</field> | ||
<field name="garden">True</field> | ||
<field name="garden_orientation">south</field> | ||
<field name="property_type" ref="estate_property_type_residential" /> | ||
</record> | ||
|
||
<record id="property_offer_1" model="estate.property.offer"> | ||
<field name="partner_id" ref="base.res_partner_2" /> | ||
<field name="property_id" ref="demo_property_big_villa" /> | ||
<field name="price">90000</field> | ||
<field name="validity">14</field> | ||
<field name="date_deadline" eval="(datetime.now() + timedelta(days=14)).date().isoformat()" /> | ||
</record> | ||
|
||
<record id="property_offer_2" model="estate.property.offer"> | ||
<field name="partner_id" ref="base.res_partner_2" /> | ||
<field name="property_id" ref="demo_property_big_villa" /> | ||
<field name="price">1500000</field> | ||
<field name="validity">14</field> | ||
<field name="date_deadline" eval="(datetime.now() + timedelta(days=14)).date().isoformat()" /> | ||
</record> | ||
|
||
<record id="property_offer_3" model="estate.property.offer"> | ||
<field name="partner_id" ref="base.res_partner_3" /> | ||
<field name="property_id" ref="demo_property_big_villa" /> | ||
<field name="price">1500001</field> | ||
<field name="validity">14</field> | ||
<field name="date_deadline" eval="(datetime.now() + timedelta(days=14)).date().isoformat()" /> | ||
</record> | ||
<function model="estate.property.offer" name="action_accept"> | ||
<value eval="[ref('property_offer_1')]" /> | ||
</function> | ||
|
||
<function model="estate.property.offer" name="action_refuse"> | ||
<value eval="[ref('property_offer_2')]" /> | ||
</function> | ||
|
||
<function model="estate.property.offer" name="action_refuse"> | ||
<value eval="[ref('property_offer_3')]" /> | ||
</function> | ||
|
||
<record id="demo_property_with_inline_offers" model="estate.property"> | ||
<field name="name">Estate with Inline Offers</field> | ||
<field name="state">new</field> | ||
<field name="postcode">44444</field> | ||
<field name="expected_price">120000</field> | ||
<field name="date_availability">2025-07-15</field> | ||
<field name="garden">True</field> | ||
<field name="garage">True</field> | ||
<field name="bedrooms">3</field> | ||
<field name="living_area">95</field> | ||
<field name="property_type" ref="estate_property_type_residential" /> | ||
<field name="offer_ids" | ||
eval="[ | ||
Command.create({ | ||
'partner_id': ref('base.res_partner_2'), | ||
'price': 100000, | ||
'validity': 10, | ||
}), | ||
Command.create({ | ||
'partner_id': ref('base.res_partner_3'), | ||
'price': 115000, | ||
'validity': 14, | ||
}) | ||
]" /> | ||
</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,6 @@ | ||
# License LGPL-3 | ||
from . import estate | ||
gasa-odoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
from . import estate_property_type | ||
from . import estate_property_tag | ||
from . import estate_property_offer | ||
from . import inherited_model |
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,137 @@ | ||
from odoo import api, fields, models | ||
from datetime import date, timedelta | ||
from odoo.exceptions import UserError | ||
from odoo.exceptions import ValidationError | ||
from odoo.tools.float_utils import float_compare, float_is_zero | ||
|
||
|
||
class Estate(models.Model): | ||
_name = "estate.property" | ||
_description = "Estate Property" | ||
_order = "id desc" | ||
|
||
name = fields.Char(required=True, default="Unknown") | ||
description = fields.Text(string="Description") | ||
postcode = fields.Char(string="Postcode") | ||
expected_price = fields.Float() | ||
bedrooms = fields.Integer(default=2) | ||
last_seen = fields.Datetime("Last Seen", default=fields.Date.today) | ||
date_availability = fields.Date(default=lambda self: date.today() + timedelta(days=90), copy=False) | ||
active = fields.Boolean(default=True) | ||
living_area = fields.Integer(string="Living Area") | ||
facades = fields.Integer(string="Facades") | ||
garage = fields.Boolean(string="Garage") | ||
garden = fields.Boolean(string="Garden") | ||
garden_area = fields.Integer(string="Garden Area") | ||
garden_orientation = fields.Selection( | ||
[ | ||
('north', 'North'), | ||
('south', 'South'), | ||
('east', 'East'), | ||
('west', 'West') | ||
], | ||
string="Garden Orientation" | ||
) | ||
state = fields.Selection( | ||
selection=[ | ||
('new', 'New'), | ||
('offer_received', 'Offer Received'), | ||
('offer_accepted', 'Offer Accepted'), | ||
('sold', 'Sold'), | ||
('cancelled', 'Cancelled') | ||
], | ||
default='new', | ||
required=True, | ||
copy=False | ||
) | ||
property_type = fields.Many2one("estate.property.type", string="Property Type") | ||
buyer = fields.Many2one( | ||
"res.partner", | ||
string="Buyer", | ||
copy=False | ||
) | ||
seller = fields.Many2one( | ||
"res.users", | ||
string="Salesperson", | ||
default=lambda self: self.env.user | ||
) | ||
tag_ids = fields.Many2many("estate.property.tag", string="Tags") | ||
offer_ids = fields.One2many( | ||
"estate.property.offer", "property_id", string="Offers" | ||
) | ||
total_area = fields.Integer( | ||
string="Total Area", | ||
compute="_compute_total_area", | ||
store=True | ||
) | ||
|
||
best_price = fields.Float( | ||
string="Best Offer", | ||
compute="_compute_best_price" | ||
) | ||
|
||
selling_price = fields.Float(copy=False) | ||
company_id = fields.Many2one( | ||
'res.company', | ||
string='Company', | ||
required=True, | ||
default=lambda self: self.env.company | ||
) | ||
|
||
@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: | ||
prices = record.offer_ids.mapped("price") | ||
record.best_price = max(prices) if prices 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_mark_sold(self): | ||
for record in self: | ||
if record.state == 'cancelled': | ||
raise UserError("Canceled properties cannot be sold.") | ||
record.state = 'sold' | ||
|
||
def action_mark_cancelled(self): | ||
for record in self: | ||
if record.state == 'sold': | ||
raise UserError("Sold properties cannot be canceled.") | ||
record.state = 'cancelled' | ||
|
||
@api.constrains('selling_price', 'expected_price') | ||
def _check_selling_price_threshold(self): | ||
for record in self: | ||
if float_is_zero(record.selling_price, precision_digits=2): | ||
continue | ||
|
||
minimum_allowed = record.expected_price * 0.9 | ||
|
||
if float_compare(record.selling_price, minimum_allowed, precision_digits=2) < 0: | ||
raise ValidationError( | ||
("The selling price cannot be lower than 90%% of the expected price.\n" | ||
"Expected Price: %.2f, Selling Price: %.2f (Minimum allowed: %.2f)") % | ||
(record.expected_price, record.selling_price, minimum_allowed) | ||
) | ||
|
||
@api.ondelete(at_uninstall=False) | ||
def _check_property_state_before_delete(self): | ||
for record in self: | ||
if record.state not in ['new', 'cancelled']: | ||
raise UserError("You can only delete properties that are in 'New' or 'Cancelled' state.") | ||
|
||
_sql_constraints = [ | ||
('check_expected_price_positive', 'CHECK(expected_price > 0)', 'The expected price must be strictly positive.'), | ||
('check_selling_price_positive', 'CHECK(selling_price >= 0)', 'The selling price must be positive.'), | ||
] |
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.
Uh oh!
There was an error while loading. Please reload this page.