-
Notifications
You must be signed in to change notification settings - Fork 2.7k
19.0 tutorials joyep #1036
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?
19.0 tutorials joyep #1036
Conversation
e9da80b to
c526e50
Compare
antonrom1
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.
Look really good overall, good job :P
estate/views/estate_menus.xml
Outdated
| <menuitem id="estate_menu_root" name="Real Estate"/> | ||
|
|
||
| <menuitem id="estate_property_menu_categ" | ||
| name="Properties" | ||
| parent="estate_menu_root" | ||
| sequence="10"/> | ||
|
|
||
| <menuitem id="estate_property_menu_action" | ||
| name="Properties" | ||
| parent="estate_property_menu_categ" | ||
| action="estate_property_action" | ||
| sequence="20"/> |
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.
Good! 👍
Just as a note, you can also define them like this instead of specifying the parent
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.
thx! fixed.
| @api.depends("living_area", "garden_area") | ||
| def _compute_total_area(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| total_area = fields.Integer("Total Area (sqm)", compute="_compute_total_area", store=True) | ||
|
|
||
| @api.depends("offer_ids.price") | ||
| def _compute_best_offer(self): | ||
| for record in self: | ||
| prices = record.offer_ids.mapped("price") | ||
| record.best_offer = max(prices) if prices else 0.0 | ||
|
|
||
| best_offer = fields.Float("Best Offer", compute="_compute_best_offer", store=True) | ||
|
|
||
| @api.onchange("garden") | ||
| def _onchange_garden(self): | ||
| if not self.garden: | ||
| self.garden_area = 0 | ||
| self.garden_orientation = False | ||
| else: | ||
| if not self.garden_area: | ||
| self.garden_area = 10 | ||
| if not self.garden_orientation: | ||
| self.garden_orientation = "north" |
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.
In a Model attribute order should be
- Private attributes (_name, _description, _inherit, …)
- Default method and default_get
- Field declarations
- SQL constraints and indexes
- Compute, inverse and search methods in the same order as field declaration
- Selection method (methods used to return computed values for selection fields)
- Constrains methods (@api.constrains) and onchange methods (@api.onchange)
- CRUD methods (ORM overrides)
- Action methods
- And finally, other business methods.
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.
thx! fixed.
| other_offers = self.search( | ||
| [ | ||
| ("property_id", "=", offer.property_id.id), | ||
| ("id", "!=", offer.id), | ||
| ] | ||
| ) |
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, but you can make it a bit simpler. Recordsets have bitwise operations (__sub__, __or__, __and__ etc)
| other_offers = self.search( | |
| [ | |
| ("property_id", "=", offer.property_id.id), | |
| ("id", "!=", offer.id), | |
| ] | |
| ) | |
| other_offers = self.property_id.offer_ids - offer |
Also check that none other offers were already accepted. e.g.:
if any(other_offers.filtered(lambda o: o.status == 'accepted')): ...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.
thx! fixed.
estate/models/estate_property.py
Outdated
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError | ||
| from dateutil.relativedelta import relativedelta |
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.
nitpick: import order https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#imports
| from odoo import api, fields, models | |
| from odoo.exceptions import UserError | |
| from dateutil.relativedelta import relativedelta | |
| from dateutil.relativedelta import relativedelta | |
| from odoo import api, fields, models | |
| from odoo.exceptions import UserError |
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.
thx! fixed.
| date_availability = fields.Date( | ||
| "Available From", default=lambda self: fields.Date.today() + relativedelta(months=3), copy=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.
Don't forget the trailing comma. Also making this multiline would look better imo
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.
thx!
estate/models/__init__.py
Outdated
| from . import estate_property_type | ||
| from . import estate_property_tag | ||
| from . import estate_property_offer |
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.
nit: alphabetical import order
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.
thx! fixed.
d851b07 to
b65f969
Compare
b65f969 to
b565d8b
Compare
Add property types, tags, and offers with corresponding views and access rights
Enhance property and offer models with computed fields and views
Implement action methods for property status and offer status
Add SQL constraints for price and uniqueness in property models and add Python constraints for the accepted price.
b565d8b to
859d32c
Compare
Enhance property management - update launch configuration, modify ordering, and improve views
Implement inherited user model and views, add CRUD validation for property offers
1305fc1 to
d8b4942
Compare
Initial implementation of estate module with property management features
update module structure and enhance Playground component
39c6702 to
935914a
Compare

No description provided.