Skip to content

[ADD] estate: create real estate module #783

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
wants to merge 15 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[REF] estate, estate_account: change names according to the coding gu…
…ideline and clear some typos

This commit will refactor estate_property in estate.property as recommended. Some file name especially those who deals with inhertiance are changed accoridng to the guideline.
  • Loading branch information
clom-odoo committed May 26, 2025
commit fb559d64987028f0b4b0bff5dc67575913d83908
4 changes: 2 additions & 2 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
'base'
],
'data': [
'views/estate_property_offer.xml',
'views/estate_property_offer_views.xml',
'views/estate_property_type_views.xml',
'views/estate_property_tag_views.xml',
'views/estate_property_views.xml',
'views/estate_menus.xml',
'views/inherited_user.xml',
'views/res_user.xml',
'security/ir.model.access.csv',
],
'application': True
Expand Down
4 changes: 2 additions & 2 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import estate_property_type
from . import estate_property_tag
from . import estate_property_offer
from . import estate_properties
from . import inherited_user
from . import estate_property
from . import res_user
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


class Properties(models.Model):
Copy link

Choose a reason for hiding this comment

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

Suggested change
class Properties(models.Model):
class EstateProperty(models.Model):

By convention, model class names should correspond to the model name in the CamelCase format.

_name = "estate_property"
_name = "estate.property"
_description = "Properties of the estate model"
_order = "id desc"

Expand Down Expand Up @@ -91,7 +91,7 @@ def action_cancel(self):
def _check_minimum_sell_price(self):
for a_property in self:
if float_compare(a_property.selling_price, a_property.expected_price * 0.9, 2) == -1:
raise ValidationError("The seling prce can not be lower than 90% of the expected price")
raise ValidationError("The selling price can not be lower than 90% of the expected price")

@api.ondelete(at_uninstall=False)
def _unlink_if_new_or_cancelled(self):
Expand Down
8 changes: 4 additions & 4 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PropertyOffer(models.Model):
price = fields.Float("price")
status = fields.Selection(copy=False, selection=[('accepted', 'Accepted'), ('refused', 'Refused')])
partner_id = fields.Many2one("res.partner", required=True)
property_id = fields.Many2one("estate_property", required=True)
property_id = fields.Many2one("estate.property", required=True)
date_deadline = fields.Date(default=fields.Date.today() + relativedelta(days=7), compute="_compute_deadline", inverse="_update_validity")
validity = fields.Integer(default=7)
property_type_id = fields.Many2one(related="property_id.property_type_id", store=True)
Expand Down Expand Up @@ -58,10 +58,10 @@ def action_cancel(self):
return True

@api.model
def create(self, vals):
property_id = self.env["estate_property"].browse(vals["property_id"])
def create_multi(self, vals):
property_id = self.env["estate.property"].browse(vals["property_id"])
if property_id.state == "new":
property_id.state = "offer received"
if property_id.best_price > vals["price"]:
raise UserError("The price of a new offer can't be below the price of an already existing offer.")
return super().create(vals)
return super().create_multi(vals)
2 changes: 1 addition & 1 deletion estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class PropertyType(models.Model):
_order = "sequence,name desc"

name = fields.Char("Type", required=True)
property_ids = fields.One2many("estate_property", "property_type_id")
property_ids = fields.One2many("estate.property", "property_type_id")
sequence = fields.Integer()
offer_ids = fields.One2many("estate.property.offer", "property_type_id")
offer_count = fields.Integer(compute="_count_offer")
Expand Down
7 changes: 0 additions & 7 deletions estate/models/inherited_user.py

This file was deleted.

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


class User(models.Model):
_inherit = "res.users"

property_ids = fields.One2many("estate.property", inverse_name="salesperson")
2 changes: 1 addition & 1 deletion estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<odoo>
<menuitem id="estate_menu_root" name="Estate">
<menuitem id="estate_first_level_menu" name="First Level">
<menuitem id="estate_first_level_menu" name="Property">
<menuitem id="estate_menu_action" action="estate_property_action"/>
</menuitem>
<menuitem id="estate_type_first_level_menu" name="Estate Types">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<odoo>

<record id="estate_property_offer_filter_action" model="ir.actions.act_window">
<record id="estate_property_offer_action_filter" model="ir.actions.act_window">
<field name="name">Offer</field>
<field name="res_model">estate.property.offer</field>
<!-- <field name="domain">[('property_type_id', '=', active_id)]</field> -->
Expand Down
2 changes: 1 addition & 1 deletion estate/views/estate_property_type_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<sheet>
<div name="button_box">
<button class="oe_stat_button"
name="estate.estate_property_offer_filter_action"
name="estate.estate_property_offer_action_filter"
type="action" string="test">
<!--
<div class="o_field_widget o_stat_info">
Expand Down
11 changes: 5 additions & 6 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<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="model">estate.property</field>
<field name="arch" type="xml">
<search>
<field string="Title" name="name"/>
Expand All @@ -20,15 +20,15 @@

<record id="estate_property_action" model="ir.actions.act_window">
<field name="name">Estate property</field>
<field name="res_model">estate_property</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,kanban,form</field>
<field name="context">{'search_default_state_availability_filter': True}</field>
</record>

<!-- list view -->
<record id="estate_property_view_tree" model="ir.ui.view">
<field name="name">estate.property.list</field>
<field name="model">estate_property</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Channel" decoration-success="state in ['offer received','offer accepted']" decoration-bf="state == 'offer accepted'" decoration-muted="state == 'sold'">
<field name="name"/>
Expand All @@ -52,7 +52,7 @@
<!-- Form view -->
<record id="estate_property_view_form" model="ir.ui.view">
<field name="name">estate.property.form</field>
<field name="model">estate_property</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<form string="Property">
<header>
Expand Down Expand Up @@ -86,7 +86,6 @@
<field name="garden"/>
<field name="garden_area" invisible="not garden"/>
<field name="garden_orientation" invisible="not garden"/>
<field name="state"/>
<field name="total_area"/>
</group>
</page>
Expand Down Expand Up @@ -117,7 +116,7 @@
<!-- Kanban View -->
<record id="estate_property_view_kanban" model="ir.ui.view">
<field name="name">estate.property.kanban</field>
<field name="model">estate_property</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<kanban default_group_by="state" records_draggable="False">
<templates>
Expand Down
4 changes: 2 additions & 2 deletions estate/views/inherited_user.xml → estate/views/res_user.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<odoo>
<record id="inherited_user_estate_view_form" model="ir.ui.view">
<field name="name">inherited.base.view_users_form</field>
<record id="view_users_form" model="ir.ui.view">
<field name="name">res.user.view.form.inherit.estate.property</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
Expand Down
4 changes: 2 additions & 2 deletions estate_account/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from odoo import models, Command


class InheritedProperty(models.Model):
_inherit = "estate_property"
class Property(models.Model):
Copy link

Choose a reason for hiding this comment

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

Suggested change
class Property(models.Model):
class EstateProperty(models.Model):

By convention, the class name should be the same as the one being inherited.

_inherit = "estate.property"

def action_sold(self):
res = super().action_sold()
Expand Down