-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[ADD] estate: defines a new app for estate properties #792
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?
Conversation
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.
Nice!
Some small improvements though you can apply.
🚀
estate/__manifest__.py
Outdated
'license': 'LGPL-3', | ||
'application': True, | ||
'installable': True, | ||
'depends': ['base', 'web'], |
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.
'depends': ['base', 'web'], | |
'depends': ['base'], |
Your module does not require anything coming from the web
module so far
<field name="arch" type="xml"> | ||
<list string="property list"> | ||
<field name="name" /> | ||
<field name="date_availability" width="400" /> |
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.
<field name="date_availability" width="400" /> | |
<field name="date_availability"/> |
Avoid hardcoding styles when it's possible as per screen sizes compatibility.
Use classes instead and check for existing classes in other views and/or stylesheets. As Odoo uses Bootstrap, you can also make responsive UI based on BS styles
<field name="res_model">estate.property</field> | ||
<field name="view_mode">list,form</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.
</odoo> | |
</odoo> | |
As per UNIX compatibility concern, please always add a newline at the end of your files.
Other Python conventions we follow at Odoo can be found on PEP8
…ome new attributes added the tags and property types, buyer, amd seller models and linked them in the property model. also make view of offers list
@A-Yehia19 |
_description = 'Estate Model Offer' | ||
|
||
price = fields.Float() | ||
status = fields.Selection(copy=False, selection=[('Accepted', 'Accepted'), ('Refused', 'Refused')]) |
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.
status = fields.Selection(copy=False, selection=[('Accepted', 'Accepted'), ('Refused', 'Refused')]) | |
status = fields.Selection(copy=False, selection=[('accepted', 'Accepted'), ('refused', 'Refused')]) |
Prefer using snake_case keys.
We basically try to fit PEP8 standards
<form string="property form"> | ||
<sheet> | ||
<group> | ||
<field name="name" style="font-size:50px;" /> |
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.
<field name="name" style="font-size:50px;" /> | |
<field name="name" /> |
Avoid hardcoding styles. Prefer using Bootstrap or check for an existing class in CSS files that does what you want to apply (or add the style you need)
add the `total_area` and the `best_price` as computed attributes in the property modules and finish thier configuration added `validity` and `date_deadline` in the offer model as inverse computed attributes and configure them [FIX] styling issues replaced harcooded font style with bootstrap classes, and make the code follow sake_case naming
…ractions ad constrains in the `selling_price, expected_price` attributes in the property model to be positive and the `name, property_type_id` to be unique together added consrains in the `price` attribute in the offer model to also be positive #[FIX] some styling issues removed unused imports
estate/models/estate_property.py
Outdated
def _check_date_end(self): | ||
for record in self: | ||
if record.state == 'offer_accepted' and float_compare(record.selling_price, 0.9 * record.expected_price, 2): | ||
raise exceptions.UserError(message='the seeling price must be atleast 90% of the expected price.') |
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.
raise exceptions.UserError(message='the seeling price must be atleast 90% of the expected price.') | |
raise UserError(self.env._('the selling price must be at least 90% of the expected price.') |
As Séna would say:
In Odoo, translatable strings in "data"-type content are automatically exported for translation. However, other user-facing strings, Odoo cannot automatically know whether they are translatable. To ensure these strings are exported for translation, you need to explicitly mark them. This is achieved by wrapping the literal string with the self.env._() function. The _() function signals to Odoo's translation system that the string should be included in the translation catalog.
More info here: https://www.odoo.com/documentation/18.0/developer/howtos/translations.html#explicit-exports
You can check this line here:
https://github.com/odoo/odoo/blob/05cff3b7d866f6bc95c4b32f343ae14a4da946f2/addons/account/models/account_move.py#L2075
estate/models/estate_property.py
Outdated
from odoo.tools.float_utils import float_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.
from odoo.tools.float_utils import float_compare | |
from odoo.tools.float_utils import float_compare | |
from odoo.exceptions import UserError | |
Import exceptions as they may be useful for future changes on your file
add colors to records according to its state, and hide some buttons if according to the step the property is in. added default filter to show available properties
Hi mate!
|
As you can see on the runbot, you have some changes requested: |
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.
Nice! A lot of traps you handled correctly!
Some nitpicking comments though
best = 0 | ||
for offer in record.offer_ids: | ||
best = max(best, offer.price) | ||
record.best_price = best |
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.
You can try to optimize this by mapping results with something like record.offer_ids.mapped('price')
if record.validity: | ||
record.date_deadline = fields.Date.today() + timedelta(days=record.validity) | ||
else: | ||
record.date_deadline = fields.Date.today() |
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 record.validity: | |
record.date_deadline = fields.Date.today() + timedelta(days=record.validity) | |
else: | |
record.date_deadline = fields.Date.today() | |
record.date_deadline = fields.Date.today() | |
if record.validity: | |
record.date_deadline += timedelta(days=record.validity) |
Maybe easier to understand
@api.model | ||
def create(self, vals): | ||
if vals['price'] <= self.env['estate.property'].browse(vals['property_id']).best_price: | ||
raise UserError(self.env._('The offer price must be greater than the best offer.')) | ||
|
||
if self.env['estate.property'].browse(vals['property_id']).state == 'new': | ||
self.env['estate.property'].browse(vals['property_id']).state = 'offer_received' | ||
return super(TestModel, self).create(vals) |
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.
Are you sure this works properly ?
model_create_multi
should be used here as per
https://github.com/odoo/odoo/blob/15fd3f62769b137cb9a0625f47b333424b851a27/odoo/api.py#L491-L509
decoration-muted="state == 'sold'"> | ||
<field name="name" /> | ||
<field name="property_type_id" /> | ||
<field name="date_availability" width="200vw" optional="true" /> |
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.
<field name="date_availability" width="200vw" optional="true" /> | |
<field name="date_availability" optional="true" /> |
Avoid hardcoding styles. Usually, hardcoding styles is for reports to be printed and event the reports mainly work using classes.
You can use all existing classes + BootStrap ones
'license': 'LGPL-3', | ||
'application': True, | ||
'installable': True, | ||
'depends': ['base', 'estate', 'account'], |
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.
'depends': ['base', 'estate', 'account'], | |
'depends': ['estate', 'account'], |
This is redundant as your estate
module already relies on base
module
No description provided.