[ADD] estate: Added the new real estate module#1228
[ADD] estate: Added the new real estate module#1228ripil-odoo wants to merge 13 commits intoodoo:19.0from
Conversation
Created a new folder called 'estate' with '__init__.py' (empty) and '__manifest__.py'. Ensured the app is listed in the Apps module, the only dependency added was 'base'. Chapter 2
Removed the unnecessary encoding declaration and removed trailing whitespaces from multiple lines in the '__manifest__.py' file. Also, added the missing extra line in the end of the code file Chapter 2
Created the estate_properties model with simple fields for name, description, date_availability, etc. Understood imports, models, and fields. Chapter 3
Created the security folder inside the estate module with the csv file giving read, write, create and unlink access to the group 'base.group_user' and ensured the no access rights warning doesn't show up in the server startup logs. Chapter 4
Removed the trailing whitespaces and extra lines from multiple files. Chapter 4
Created an action for the model estate.properties as well as the estate_properties_view.xml in the views folder. Created three levels of menus for the action in the file estate_menus.xml. Defined both in proper sequential order in the estate manifest as well. Chapter 5
Calculated the date with 3 month addition for the date_availability field dynamically. Chapter 5
Created the custom view for estate module list view and code space formatting in estate_properties.py file. Chapter 6
Added all the required fields in the list view as specified in the task along with changed labels and width. Created user access to not have create permissions. Chapter 6
Created custom fields for form view in groups and notebook. Chapter 6
mash-odoo
left a comment
There was a problem hiding this comment.
Hello!
Thank you for your work.
Here are some few questions and suggestions.
estate/models/estate_properties.py
Outdated
| from odoo import models, fields | ||
| import logging | ||
| # from datetime import date, timedelta | ||
| from dateutil import relativedelta as rd |
There was a problem hiding this comment.
Please refer to this for sorting imports properly
estate/models/estate_properties.py
Outdated
| _name = "estate.properties" | ||
| _description = "Real Estate Properties" |
There was a problem hiding this comment.
The technical strings should be written with single quotes and the user defined strings which would be visible on UI should be with double quotes
| _name = "estate.properties" | |
| _description = "Real Estate Properties" | |
| _name = 'estate.properties' | |
| _description = "Real Estate Properties" |
estate/models/estate_properties.py
Outdated
| description = fields.Text('Description', help="Description of the property shown") | ||
| postcode = fields.Char('Postcode', help="Postal Code of the property shown") |
There was a problem hiding this comment.
| description = fields.Text('Description', help="Description of the property shown") | |
| postcode = fields.Char('Postcode', help="Postal Code of the property shown") | |
| description = fields.Text(help="Description of the property shown") | |
| postcode = fields.Char(help="Postal Code of the property shown") |
You don't need to write the string if you want it to be displayed same as the field name.
Also its good to write help, but try writing it only when the field is a bit complex to understand
estate/models/estate_properties.py
Outdated
| garage = fields.Boolean('Has Garage?', help="Does the proeprty have a garage?") | ||
| garden = fields.Boolean('Has Garden?', help="Does the property have a garden?") | ||
| garden_area = fields.Integer('Garden Area', help="Area of the garden of the property shown") | ||
| garden_orientation = fields.Selection([('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')], help="Directional orientation of the garden of the property shown") |
There was a problem hiding this comment.
Try breaking the line and make it <100 chars per line so that it can be easier to read.
| garden_orientation = fields.Selection([('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')], help="Directional orientation of the garden of the property shown") | |
| garden_orientation = fields.Selection( | |
| [ | |
| ('north', "North"), | |
| ('south', "South"), | |
| ('east', "East"), | |
| ('west', "West") | |
| ], | |
| help="Directional orientation of the garden of the property shown" | |
| ) |
Also try writing the values in double quotes as it will be displayed to the user
estate/models/estate_properties.py
Outdated
| date_availability = fields.Date('Availability Date', help="Date of availability of the property shown", copy=False, default=lambda self: _logger.info("!!! date time calculated at creation") or fields.Date.add(fields.Date.context_today(self), months=3)) | ||
| _logger.info("Date set? %s", date_availability) | ||
| expected_price = fields.Float('Expected Price', required=True, help="Expected price of the property shown") | ||
| selling_price = fields.Float('Selling Price', help="Selling Price of the property shown", readonly=True, copy=False) |
There was a problem hiding this comment.
What's the purpose of using copy=False?
There was a problem hiding this comment.
copy=False allows the field to not be copied when it is duplicated, it is true by default
| </form> | ||
| </field> | ||
| </record> | ||
| <record id="estate_action" model="ir.actions.act_window"> |
There was a problem hiding this comment.
| <record id="estate_action" model="ir.actions.act_window"> | |
| <record id="estate_properties_action" model="ir.actions.act_window"> |
| 'installable': True, | ||
| 'application': True, |
There was a problem hiding this comment.
What's the purpose of using 'application': True and 'installable': True?
There was a problem hiding this comment.
'application': Truemakes the estate module list as an app and visible with the Apps filter, otherwise it is not listed as an app just a module'installable': Trueallows the module to be installed ('Activate' button)
estate/models/estate_properties.py
Outdated
| description = fields.Text('Description', help="Description of the property shown") | ||
| postcode = fields.Char('Postcode', help="Postal Code of the property shown") | ||
| date_availability = fields.Date('Availability Date', help="Date of availability of the property shown", copy=False, default=lambda self: _logger.info("!!! date time calculated at creation") or fields.Date.add(fields.Date.context_today(self), months=3)) | ||
| _logger.info("Date set? %s", date_availability) |
There was a problem hiding this comment.
It helps to debug and understand the flow, here I used it to see when the function was called and to see what the field was
| access_estate_user,access_estate_user,model_estate_properties,base.group_user,1,0,0,0 | ||
| access_estate_admin,access_estate_user,model_estate_properties,base.group_system,1,1,1,1 |
There was a problem hiding this comment.
Can you explain me what happens when you write these lines?
There was a problem hiding this comment.
These lines give access rights to two groups: group_user (internal) and group_system (admin). Without access rights there is no rights to anyone. The permissions are to read, write, create, unlink.
estate/models/estate_properties.py
Outdated
| name = fields.Char('Property Name', required=True, help="Name of the property shown") | ||
| description = fields.Text('Description', help="Description of the property shown") | ||
| postcode = fields.Char('Postcode', help="Postal Code of the property shown") | ||
| date_availability = fields.Date('Availability Date', help="Date of availability of the property shown", copy=False, default=lambda self: _logger.info("!!! date time calculated at creation") or fields.Date.add(fields.Date.context_today(self), months=3)) |
There was a problem hiding this comment.
This is not a correct way to use a logger inside of a default. Use _logger for debugging flows (create, write or any other functions) pr to track important changes. Avoid using it in fields or lambdas.
Finished adding custom fields for the form view. Created a custom search view without filters using only fields. Addressed all the comments from the PR and fixed the code formatting issues. Chapter 5, 6
Fixed whitespace issue in the file 'estate_properties.py' and removed unnecessary testing code from the custom views. Chapter 6
…odule Creating custom filters in the search view using search domain and context, used logical filters for fields from the estate properties model. Chapter 6

Created a new folder called 'estate' with 'init.py' (empty) and 'manifest.py'. Ensured the app is listed in the Apps module, the only dependency added was 'base'.
Chapter 2