[ADD] estate: initialize estate module#1333
Conversation
Add the basic module structure and manifest file for the estate application.
Define the 'estate.property' model. - Add basic fields: name, description, postcode, date_availability, expected_price, selling_price, bedrooms, living_area, facades, garage, garden, garden_area, and garden_orientation. - Set 'name' and 'expected_price' as required fields. - Initialize the models package and set up imports.
- Create ir.model.access.csv in security folder - Grant read, write, create, and unlink permissions to base.group_user - Register security file in __manifest__.py - Fix manifest warnings by adding author and license keys
- Add tree (list), form, and search views for 'estate.property' in views/estate_property_views.xml. - Configure action 'action_estate_property' to load 'list,form,kanban' views and default filter 'available'. - Define advertisements menu structure in views/estate_menus.xml. - Clean up hardcoded field column widths from the list view in views/estate_property_views.xml to use standard auto-sizing layout.
| @@ -0,0 +1,29 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <odoo> | |||
| <data> | |||
There was a problem hiding this comment.
The <data> tag was not needed because we were not using attributes like noupdate="1". So, I removed the unnecessary tags from the security and view files and kept only the root tag.
|
|
||
| <record id="module_category_real_estate" model="ir.module.category"> | ||
| <field name="name">Real Estate</field> | ||
| <field name="sequence">10</field> |
There was a problem hiding this comment.
What's the purpose of this sequence field?
There was a problem hiding this comment.
The sequence field decides the order of the categories. A smaller number shows the category first.
| <field name="name">Properties</field> | ||
| <field name="res_model">estate.property</field> | ||
| <field name="view_mode">list,form,kanban</field> | ||
| <field name="context">{'search_default_available': 1}</field> |
There was a problem hiding this comment.
What's the difference between domain and context?
There was a problem hiding this comment.
-Domain is used to filter records at the database level (like a SQL WHERE clause). It decides "which" records to display.
-Context is used to pass information to the view, such as grouping records (like {'group_by': 'postcode'} ) or setting default values for new records.
| <field name="living_area" /> | ||
| <field name="facades" /> | ||
| <separator /> | ||
| <filter name="available" string="Available" domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]" /> |
There was a problem hiding this comment.
Yes, I have optimized it to:
domain= [('state', 'in', ('new', 'offer_received'))]
It is better because it is much easier to read and makes it simple to add more states in the future.
| <field name="bedrooms" /> | ||
| <field name="living_area" /> | ||
| <field name="facades" /> | ||
| <separator /> |
There was a problem hiding this comment.
The tag shows a vertical line between filters in the UI.
Logically, it joins filters with an AND operator instead of OR,
I have practiced this in our search view (estate_property_view_search) by using to split the State filters and Feature filters (Garage/Garden).
| </field> | ||
| </record> | ||
|
|
||
| <record id="view_estate_property_form" model="ir.ui.view"> |
There was a problem hiding this comment.
Follow this for naming your views
| <record id="view_estate_property_form" model="ir.ui.view"> | |
| <record id="estate_property_view_form" model="ir.ui.view"> |
<model_name>_view_<view_type>, where view_type is kanban, form, list, search,...
There was a problem hiding this comment.
Done. I have renamed all view IDs to follow the <model_name>view<view_type> format (e.g., estate_property_view_form).
| "name": "Real Estate", | ||
| "author": "Odoo S.A.", | ||
| "license": "LGPL-3", | ||
| "depends": ["base"], |
There was a problem hiding this comment.
If we don't write base, Odoo will still load it automatically. However, writing it explicitly is a best practice to make the module dependency clear.
mash-odoo
left a comment
There was a problem hiding this comment.
Hello!
Good start on the task..
Here are a few comments...Have a look!
Introduce the property tag (estate.property.tag) and property offer (estate.property.offer) models, establishing relationship fields. - Add estate.property.tag model with basic views. - Add Many2many field tag_ids to estate.property. - Add estate.property.offer model with form and list views. - Add One2many field offer_ids to estate.property. - Add security access rules (ACLs) for both new models task-7
Address the code styling, domain filters, and manifest configurations requested in the code review. Additionally, set up demo data for the property, type, and tag models.
Prior to this commit: -Users had to manually calculate total area and find the best offer. -Offers had no validity or deadline tracking. -Garden details had to be typed manually when enabling a garden. -Views and tags lacked distinct colors and code descriptions. Post this commit: -Total area, square area, and best offer price are computed automatically. -Offers now calculate validity and deadline dates bidirectionally. -Enabling a garden automatically sets default area and orientation. -Property tags show color and property types show their code in dropdowns. -Views, actions, and search filters are updated to support the new fields. Why This Approach: -Using @api.depends decorators ensures computed fields update automatically in real-time. -Inverse methods on offer deadline ensure bidirectional synchronization with validity days. -Onchange handler for garden dynamically guides the user in the frontend before saving. task-8
Steps to Reproduce: 1. Install or update the `estate` module with demo data enabled. 2. The database initialization/registry preload fails when loading ` estate_demo.xml`. Issue: - A `psycopg2.errors.NotNullViolation: null value in column description of relation estate_property_tag violates not-null constraint` error is thrown, preventing the module from being installed. Cause: - The `description` field on the `estate.property.tag` model is defined as `required=True`. However, the demo tag records (`Cozy`, `Cool`, `Nice`) defined in `estate_demo.xml` did not include the `description` field, violating the not-null constraint. Fix: - Add the `description` field with text values to all the property tag records in `estate_demo.xml`.

Add the basic module structure and manifest file for the estate application.