19.0 tutorials mrgor - #1362
Conversation
Initialize the estate module by adding the required module configuration files. This establishes the basic structure needed for future development and allows Odoo to recognize the module.
Initialize the estate module by adding the required module configuration files. This establishes the basic structure needed for future development and allows Odoo to recognize the module.
2c55e50 to
ce43cf1
Compare
Create the basic property model for the Real Estate module. This model allows storing essential property information and provides the base structure for adding more features. task = chapter 3 completed
8a0d18c to
4f1eeb0
Compare
Newly created models are inaccessible by default in Odoo. Define access rights so Internal Users can interact with the estate.property model and remove the missing access rules warning. Task Completed chapter 4
4f1eeb0 to
a9cc58d
Compare
- Allow users to access and manage property records from the UI. - Improve data consistency by protecting important field values. - Prevent unwanted data from being copied to duplicate records. - Reduce manual work by providing default field values. - Prepare the property model for future business workflows by introducing state fields. Task Completed chapter 5
3113f4d to
707c862
Compare
The default generated views are not suitable for a business application. A custom UI is required to improve data organization and allow users to efficiently manage and search property records as the application grows. Task Completed chapter 6
6e79df5 to
904ee8f
Compare
Introduce a dedicated property type model to improve how properties are organized and managed within the application. - Centralize the management of property types - Allow properties to be assigned reusable categories - Improve the user experience when organizing listings - Simplify property organization and maintenance
9638607 to
56faa55
Compare
Improve property management by introducing buyer and salesperson relationships together with reusable property tags. Associate properties with buyers and salespersons, automatically assign the current user as the default salesperson, prevent buyer information from being copied during duplication, and introduce the Property Tag model with its views, menu, action, access rights, and a many2many relationship for assigning multiple tags to properties.
b36d639 to
32d3417
Compare
Allow properties to track offers from potential buyers without requiring a dedicated menu, keeping offer management within the property workflow. Introduce the Property Offer model with its views and access rights, link offers to properties through a many2one relationship, and expose them on the property form using a one2many field. Task Completed chapter 7
32d3417 to
dfdf6ed
Compare
| _description = "Real Estate Property" | ||
| name = fields.Char(required=True) |
There was a problem hiding this comment.
| _description = "Real Estate Property" | |
| name = fields.Char(required=True) | |
| _description = "Real Estate Property" | |
| name = fields.Char(required=True) |
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" |
There was a problem hiding this comment.
| _name = "estate.property" | |
| _name = 'estate.property' |
wrap the technical strings in single quotes and the strings which appear on UI and visible to customer in double quotes
| active = fields.Boolean(default=True) | ||
| state = fields.Selection( |
There was a problem hiding this comment.
Arrange all the fields alphabetically so that it's easier to locate it later
| selection=[ | ||
| ("north", "North"), | ||
| ("south", "South"), | ||
| ("east", "East"), | ||
| ("west", "West"), | ||
| ] |
There was a problem hiding this comment.
| selection=[ | |
| ("north", "North"), | |
| ("south", "South"), | |
| ("east", "East"), | |
| ("west", "West"), | |
| ] | |
| selection=[ | |
| ('north', "North"), | |
| ('south', "South"), | |
| ('east', "East"), | |
| ('west', "West"), | |
| ] |
| property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) | ||
| salesperson_id = fields.Many2one( | ||
| "res.users", string="Salesperson", default=lambda self: self.env.user |
There was a problem hiding this comment.
Why do we need to use here lambda function?
Do we have any other approach here?
There was a problem hiding this comment.
I used a lambda because the logic is only one line, so it keeps the code short and readable. Another approach would be to define a method like _default_salesperson() that returns self.env.user and use that method as the default. Both work, but I felt lambda was simpler here.
| { | ||
| "name": "Real Estate", | ||
| "version": "1.0", | ||
| "author": "Mrunmayee", |
There was a problem hiding this comment.
When you are working for a company, you should keep the author name as Odoo S.A. or just skip writing it.
| "name": "Real Estate", | ||
| "version": "1.0", | ||
| "author": "Mrunmayee", | ||
| "depends": ["base"], |
There was a problem hiding this comment.
depends specifies which modules my module relies on. Odoo uses it to ensure those modules are installed and loaded before installing or upgrading my module. In this case, I added base because my module uses the core Odoo framework, such as models.Model, field types, and models like res.users and res.partner.
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_availability = fields.Date( | ||
| copy=False, default=lambda self: fields.Date.add(fields.Date.today(), months=3) |
There was a problem hiding this comment.
Yes, another approach is to create a separate method, for example _default_date_availability(), which returns the default date, and then pass that method to default.
| "res.users", string="Salesperson", default=lambda self: self.env.user | ||
| ) | ||
| tag_ids = fields.Many2many("estate.property.tag", string=" Property Tags") | ||
| offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") |
There was a problem hiding this comment.
Where can I find the records of offers connected to a property?
There was a problem hiding this comment.
The offers are stored in the estate.property.offer table. They are connected to a property using the property_id field. When I access offer_ids, Odoo automatically fetches all offer records whose property_id matches the current property.
| <filter | ||
| string="Postcode" | ||
| name="group_postcode" | ||
| context="{'group_by':'postcode'}"/> |
There was a problem hiding this comment.
context passes extra information to Odoo. In this case, it tells Odoo to group the records by postcode.
- Follow Odoo coding conventions for string quoting - Reorder model fields alphabetically - Improve code consistency and readability - Apply requested review changes
56cd7e0 to
a96ee70
Compare
The property total area should be derived automatically to ensure data consistency and avoid manual calculation. Added a computed field that calculates the total area from the living area and garden area, and displayed it in the property form view.
The property best offer should be computed automatically from the related offers to ensure it always reflects the highest available offer. Added the computed `best_price` field using the related `offer_ids.price` dependency and displayed it in the property form view.

No description provided.