-
Notifications
You must be signed in to change notification settings - Fork 2.3k
18.0 training rvar #848
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: 18.0
Are you sure you want to change the base?
18.0 training rvar #848
Conversation
Created new 'estate' module. Added base model 'estate.property' with fields mentioned in exercise. Set up module structure. Set 'name' and 'expected_price' as required fields.
This commit introduces the initial version of the module as part of the Odoo 18 developer tutorial. The module includes basic models, access rights, security rules, and simple form and tree views for managing real estate properties. The purpose of this change is to set up a foundational structure for the module. It follows the official tutorial steps to demonstrate Odoo’s ORM, security mechanisms, and view definitions. Adding proper access control ensures that only authorized users can interact with the module. The initial UI provides the groundwork for extending functionality later. This is part of a learning exercise to understand Odoo’s server framework and how to implement a feature-rich module following best practices.
This commit enhances the module by introducing relational fields (many2one, one2many, and many2many), computed fields with dependencies, onchange methods for dynamic form updates, and server actions to extend business logic. The motivation for these changes is to provide a richer data model and dynamic behavior in the estate management workflow. Relations connect properties to users and offers, improving data integrity. Computed and stored fields enable automatic updates (e.g., total area or best offer). Onchange handlers improve UX by pre-filling or validating data at the form level. Server actions and automated behaviors lay the groundwork for more complex business processes. These improvements align with Odoo’s design philosophy of reactive and modular business logic while maintaining clear separation between models and views.
This commit enhances the estate module by introducing relational fields (many2one, one2many, and many2many), computed fields with dependencies, onchange methods for dynamic form updates, and server actions to extend business logic. The motivation for these changes is to provide a richer data model and dynamic behavior in the estate management workflow. Relations connect properties to users and offers, improving data integrity. Computed and stored fields enable automatic updates (e.g., total area or best offer). Onchange handlers improve UX by pre-filling or validating data at the form level. Server actions and automated behaviors lay the groundwork for more complex business processes. These improvements align with Odoo’s design philosophy of reactive and modular business logic while maintaining clear separation between models and views.
Added SQL constraints to ensure: Property expected price is strictly positive Property selling price is positive Offer price is strictly positive Property tag name and property type name are unique Added Python constraint to prevent selling price from being set below 90% of expected price Changes in UI: Added inline list view for properties on property type form Used statusbar widget for property state display Defined default ordering for models and enabled manual ordering for property types via sequence field Applied widget options to restrict creation/editing of property types from property form
- Added model and view inheritance for extending existing functionality. - Implemented interaction with external modules using dependencies. - Updated estate module to demonstrate cross-module field access and method calls.
- Implemented cross-module field access and method calls to demonstrate interaction with other modules. - Cleaned codebase to fix linter errors and improve readability.
5b0238d
to
93657db
Compare
- Implemented cross-module field access and method calls to demonstrate interaction with other modules. - Cleaned codebase to fix linter errors and improve readability.
93657db
to
b6e2c1e
Compare
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.
Quick first review.
Remove the unnecessary diff added in the code base.
Also the PR title is not correct, please adapt that as well
@@ -0,0 +1 @@ | |||
from . import models |
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.
Missing licensing
"installable": True, | ||
"depends": ["base"], | ||
"application": True, | ||
"auto_install": False, |
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.
If the value is false, then no need to define it anyways
"summary": "Demo app for estate", | ||
"description": "This is the demo app ", |
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.
Add a proper summary and description
class RecurringPlan(models.Model): | ||
_name = "estate.property" | ||
_description = "estate property revenue plans" |
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.
Mismatch class name and model name
class RecurringPlan(models.Model): | ||
_name = "estate.property" | ||
_description = "estate property revenue plans" | ||
_order = "id desc" # For ordering in ascending opr descending order one more way to do so is from view like: <list default_order="date desc"> |
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.
Comment is not required here
# Allow only if property has no accepted offer | ||
if offer.property_id.buyer_id: | ||
raise UserError( | ||
_("An offer has already been accepted for this property.") | ||
) | ||
# Set buyer and selling price | ||
offer.property_id.buyer_id = offer.partner_id | ||
offer.property_id.selling_price = offer.price | ||
offer.status = "accepted" | ||
offer.property_id.state = "offer_accepted" | ||
# Setting remaining Offer as refused | ||
other_offers = offer.property_id.offer_id - offer | ||
# for other in other_offers: # -----> Normal for loop logic | ||
# other.status = 'refused' | ||
other_offers.write({"status": "refused"}) # -----> Odoo ORM Method |
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.
Comment are unnecesary
|
||
return super().create(new_records) | ||
|
||
# vals_list---------> [{'partner_id': 23, 'price': 100, 'validity': 7, 'date_deadline': '2025-07-16', 'property_id': 19}] |
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.
Unnecessary
access_estate_model,estate.property,model_estate_property,base.group_user,1,1,1,1 | ||
access_estate_model_property,estate.property.type,model_estate_property_type,base.group_user,1,1,1,1 | ||
access_estate_model_tag,estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
access_estate_model_offer,estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1 |
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.
End of file line is missing
</field> | ||
|
||
</record> | ||
</odoo> |
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.
End of file line is missing
journal = self.env["account.journal"].search( | ||
[("type", "=", "sale")], limit=1 | ||
) |
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.
Do you think searching inside for loop is efficient way to do it ?
This PR adds demo data to the estate module as per the Odoo Estate tutorial.
Features:
-Estate module initialization and configuration
-Property model definition with key fields
-Basic list and form views
-Menu and action setup for navigation
-Implemented Inheritance