Skip to content

[ADD] estate: initial Real Estate module with models, views, and rela… #757

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
wants to merge 2 commits into
base: 18.0
Choose a base branch
from

Conversation

raaa-odoo
Copy link

…tions

Introduce the base structure of the Real Estate application as per Odoo 18 developer tutorial, covering the foundational data model, views, menus, access rights, and key relationships.

This commit adds:

  • A new module named estate.
  • The main model estate.property with relevant business fields (name, price, expected price, description, living area, garden, garage, etc.).
  • Custom menus, actions, form and list views for estate.property.
  • Field attributes like readonly, copy, required, and default values.
  • Access rights through ir.model.access.csv for developers.
  • Multiple record filtering using domain, search, and view buttons.
  • Related models:
    • estate.property.type`: Many2one for property types.
    • estate.property.tag`: Many2many tags with selection UI.
    • estate.property.offer`: One2many offer list per property with inline editing
    • Links to existing models: res.partner (buyer), res.users (salesperson).
  • Navigation enhancements through related fields and smart buttons.
  • Search enhancements using filters for related fields like tags and type.

The goal of this commit is to build a working foundation of the real estate sales module including a robust data model, basic UI, and relations required for future business logic and workflow implementation.

task-001 (Chapter 1–7 Odoo 18 Developer Tutorial)

…tions

Introduce the base structure of the Real Estate application as per Odoo 18
developer tutorial, covering the foundational data model, views, menus,
access rights, and key relationships.

This commit adds:

- A new module named `estate`.
- The main model `estate.property` with relevant business fields (name, price,
  expected price, description, living area, garden, garage, etc.).
- Custom menus, actions, form and list views for `estate.property`.
- Field attributes like `readonly`, `copy`, `required`, and default values.
- Access rights through `ir.model.access.csv` for developers.
- Multiple record filtering using `domain`, `search`, and view buttons.
- Related models:
  - estate.property.type`: Many2one for property types.
  - estate.property.tag`: Many2many tags with selection UI.
  - estate.property.offer`: One2many offer list per property with inline editing
  - Links to existing models: `res.partner` (buyer), `res.users` (salesperson).
- Navigation enhancements through related fields and smart buttons.
- Search enhancements using filters for related fields like tags and type.

The goal of this commit is to build a working foundation of the real estate
sales module including a robust data model, basic UI, and relations required
for future business logic and workflow implementation.

task-001 (Chapter 1–7 Odoo 18 Developer Tutorial)
@robodoo
Copy link

robodoo commented May 7, 2025

Pull request status dashboard

 Enhance the Real Estate module by implementing computed fields, onchange
behavior,  SQL constraints, and business logic for handling property offers as
 outlined in Chapters 9 and 10 of the Odoo 18 Developer Tutorial.

 This commit adds:

   - Computed fields:
     - `total_area`: combines living and garden areas.
     - `best_price`: dynamically shows the highest offer on a property.
     - Onchange method to auto-fill garden attributes when the garden is checked
     - Python constraints using `@api.constrains` to:
     - Ensure selling price is at least 90% of expected price.
     - Validate date availability is not in the past.
       - SQL-level check constraints to enforce:
         - `expected_price > 0` on estate.property.
         - `price > 0` on estate.property.offer.
       - Action methods for accepting and refusing property offers:
         - Accepting sets offer status and updates property selling price/buyer.
         - Refusing only updates offer status.
        - Constraints ensure only one offer can be accepted per property.
      - Improved inline editing experience in offer list view.
      - Readonly fields, computed badges, and smart button usability refinements.

       These changes enforce critical business rules and improve user feedback,
       ensuring data consistency and meaningful interactions within the Real
       Estate flow.

       task-002 (Chapter 9–10 Odoo 18 Developer Tutorial)
Copy link

@adsh-odoo adsh-odoo left a comment

Choose a reason for hiding this comment

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

Hello @raaa-odoo
Nice work overall looks good.
Few comments mostly related to coding guidelines and nitpicking.
Cheers!!

Choose a reason for hiding this comment

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

Need blank line at EOF.
Please check other occurrences aslo.

string="Offers"
)

tag_ids = fields.Many2many("estate.property.tag", string="Tags", widget="many2many_tags" )

Choose a reason for hiding this comment

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

widgets are provided on the field in XML side. HINT: refer codebase
Runbot build is failing due to this.

Comment on lines +1 to +3
from odoo import fields, api, models
from datetime import timedelta
from odoo.exceptions import UserError

Choose a reason for hiding this comment

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

Suggested change
from odoo import fields, api, models
from datetime import timedelta
from odoo.exceptions import UserError
from datetime import timedelta
from odoo import api, fields, models
from odoo.exceptions import UserError

Generally, we follow a convention where we import the external libraries first, and then we make imports from Odoo in alphabetical order.
https://www.odoo.com/documentation/18.0/contributing/development/coding_guidelines.html#python

Comment on lines +3 to +4
from odoo.exceptions import UserError
from odoo.exceptions import ValidationError

Choose a reason for hiding this comment

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

This two imports can be combined

for record in self:
record.total_area = record.living_area + record.garden_area

best_price = fields.Float("Best Offer", compute="_compute_best_price", store=True)

Choose a reason for hiding this comment

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

All field definitions should be together, so this needs to be moved up.
And why we need to store this field.

Comment on lines +149 to +160
_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.",
),
]

Choose a reason for hiding this comment

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

The definitions of constraints should be after the field definition.
Hint: refer code base.

Comment on lines +28 to +50
<!-- "Both are correct"

<odoo>
<menuitem id="estate_menu_root" name="Real Estate" />

<menuitem id="estate_menu_property" name="Properties"
parent="estate_menu_root" />

<menuitem id="estate_menu_property_action"
parent="estate_menu_property"
action="estate_property_action" />
</odoo>

________________________________________________________________________________________________

<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Properties">
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
</menuitem>
</menuitem>
</odoo>

Choose a reason for hiding this comment

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

Need to remove the commented codes.

<field name="tag_ids" widget="many2many_tags" />
</group>
</page>

Copy link

@adsh-odoo adsh-odoo May 9, 2025

Choose a reason for hiding this comment

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

An unnecessary blank line. Need to be checked for other occurrences also.

<header>
<group>
<field name="name" nolabel="1"
style="font-size: 28px; font-weight: bold;" />

Choose a reason for hiding this comment

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

Suggested change
style="font-size: 28px; font-weight: bold;" />
style="font-size: 28px; font-weight: bold;"/>

Need to change other places also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants