-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ADD] estate: created the model and Initalized it with the postgre db #1107
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
base: 19.0
Are you sure you want to change the base?
Conversation
- The Estate Module, which is needed as of tutorials - Required fields were added, including the selection - CHAPTER 1,2,3
-Added the list and form view for proper readability with the group feature -Added the search functionality, i.e, available and Postcode -Added the security read, write, and create rules to solve the warning message
-improved the structure of the estate property -CHAPTER 4,5,6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
Good work!
No need to define a chapter in the PR message.
And can you please adapt your commit message according to guidelines?
Thanks
estate/models/estate_property.py
Outdated
| from odoo import models, fields | ||
| from datetime import timedelta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please follow these guidelines?
https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#imports
estate/views/estate_menus.xml
Outdated
| name="Properties" | ||
| parent="estate_first_level_menu" | ||
| action="estate_property_action" /> | ||
| </odoo> No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be one empty line at the EOF.
| <field name="res_model">estate.property</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| </odoo> No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be one empty line at the EOF.
- Created the 'estate.property.offer' model with fields - Add a One2many relationship 'offer_ids' to the 'estate.property' model. - Implement list and form views for the offer model. - Update the property form view to display offers in a dedicated tab.
- Implemented computed fields for 'total_area' and 'best_price' to automatically aggregate property data and identify the highest offer. - Added 'validity' and 'date_deadline' to property offers with inverse logic, allowing users to define deadlines either by a date or a duration in days.
- Add an onchange method for the garden field - Fix ParseError by ensuring actions are defined before menuitems - chapter 8
bit-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello
Nice work!
Can you please update your PR description.
Thanks
estate/models/estate_property.py
Outdated
| from odoo import api, fields, models | ||
| from datetime import timedelta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply these changes.-#1107 (comment)
|
|
||
| name = fields.Char(required=True) | ||
| description = fields.Text() | ||
| postcode = fields.Char() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this field char() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because, Sir, here in Chapter 3, we are told to have this field as a Character
https://www.odoo.com/documentation/19.0/developer/tutorials/server_framework_101/03_basicmodel.html#types
I have done the other changes
Thank You.
| from odoo import api, fields, models | ||
| from datetime import timedelta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply these changes here also.-#1107 (comment)
estate/security/ir.model.access.csv
Outdated
| estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1 | ||
| estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1 No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be one empty line at EOF.
| <h1> | ||
| <field name="name" /> | ||
| </h1> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneccary space.
| help="here you will get the tags" /> | ||
| </group> | ||
| <group> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneccary space.
| <field name="total_area" /> | ||
| </group> | ||
| </page> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneccary space.
| <page string="Offers"> | ||
| <field name="offer_ids"></field> | ||
| </page> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unneccary space.
- Added 'Sold' and 'Cancel' buttons to estate.property. - Added 'Accept' and 'Refuse' buttons to estate.property.offer. - Implement logic to prevent selling canceled properties and vice-versa. - Update property state, selling price, and buyer when an offer is accepted.
Add SQL constraints to ensure data integrity: - Expected price and offer price must be strictly positive. - Selling price must be positive. - Property type and tag names must be unique. - Added the Python constrains but without using float_compare and float_is_zero
…ttributes
- Model Ordering:
- Added default ordering for properties (newest first), offers
(highest price), tags, and types (alphabetical).
- Implemented manual ordering for property types using a
'sequence' field and the 'handle' widget in list views.
- View Enhancements:
- Integrated 'statusbar' widget for property states.
- Added color pickers to tags and 'no_create'/'no_edit' options
to property types to prevent accidental data entry.
- Enabled inline editing (editable=bottom) for offers and tags
to reduce form switching.
- Applied conditional decorations (colors/bold) to list views
based on property status and offer values.
- Business Logic & Visibility:
- Used 'invisible' attributes to hide garden details when no
garden is present and to hide offer buttons once processed.
- Set 'readonly' on offers once a property reaches a terminal
state (Offer Accepted, Sold, or Cancelled) to ensure data integrity.
- Chapter 10 done, 11 (85%)
bit-odoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
Can you please improve your PR title.
Thanks
| _check_expected_price = models.Constraint( | ||
| "CHECK(expected_price >= 0)", | ||
| "The expected price should be strictly positive", | ||
| ) | ||
| _check_selling_price = models.Constraint( | ||
| "CHECK(selling_price >= 0)", | ||
| "The selling price should be strictly positive", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the coding guidelines SQL constraints are declared after the field declaration.
| copy=False, | ||
| required=True, | ||
| ) | ||
| status = fields.Selection( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have you created this field? We already have a state field.
| for record in self: | ||
| if record.status == "cancelled": | ||
| raise UserError("Cancelled Property cannot be sold.") | ||
| else: | ||
| record.state = "sold" | ||
| record.status = "sold" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to make the error message translatable.
raise UserError(_("Cancelled Property cannot be sold."))
We can use filtered() here.
if self.filtered(lamda x: x.state=="cancelled")
| for record in self: | ||
| if record.status == "sold": | ||
| raise UserError("Sold Property cannot be Cancelled.") | ||
| record.state = "cancelled" | ||
| record.status = "cancelled" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to make the error message translatable.
raise UserError(_("Sold Property cannot be Cancelled."))
We can use filtered() here.
if self.filtered(lamda x: x.state=="sold")
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "Estate Property Offer" | ||
| _check_offer_price = models.Constraint( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the coding guidelines SQL constraints are declared after the field declaration.
| date_diff = record.date_deadline - creation_date | ||
| record.validity = date_diff.days | ||
|
|
||
| def refuse_offer_action_icon(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the coding guidelines prefix with action_ .

Add SQL constraints to ensure data integrity: