Skip to content

[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

Open
wants to merge 9 commits into
base: 18.0
Choose a base branch
from

Conversation

A-Yehia19
Copy link

No description provided.

@robodoo
Copy link

robodoo commented May 20, 2025

Pull request status dashboard

Copy link

@barracudapps barracudapps left a 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.
🚀

'license': 'LGPL-3',
'application': True,
'installable': True,
'depends': ['base', 'web'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'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" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</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
@barracudapps
Copy link

@A-Yehia19
Can you please review the name of your PR and your commits titles/messages ?
Everything you need to know is here

_description = 'Estate Model Offer'

price = fields.Float()
status = fields.Selection(copy=False, selection=[('Accepted', 'Accepted'), ('Refused', 'Refused')])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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
@A-Yehia19 A-Yehia19 changed the title [ADD] add estate app with empty view [ADD] computed modules May 21, 2025
…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
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.')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines 4 to 5
from odoo.tools.float_utils import float_compare

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@A-Yehia19 A-Yehia19 changed the title [ADD] computed modules [ADD] estate: defines a new app for estate properties May 22, 2025
A-Yehia19 added 4 commits May 22, 2025 17:07
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
@barracudapps
Copy link

Hi mate!
Can you please explain why you made this PR in the description ?

@A-Yehia19 Can you please review the name of your PR and your commits titles/messages ? Everything you need to know is here

@barracudapps
Copy link

As you can see on the runbot, you have some changes requested:
https://runbot.odoo.com/runbot/build/81254345 (issue in your XML)
https://runbot.odoo.com/runbot/build/81254346 (commit titles not following our conventions)

Copy link

@barracudapps barracudapps left a 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

Comment on lines +70 to +73
best = 0
for offer in record.offer_ids:
best = max(best, offer.price)
record.best_price = best

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')

Comment on lines +34 to +37
if record.validity:
record.date_deadline = fields.Date.today() + timedelta(days=record.validity)
else:
record.date_deadline = fields.Date.today()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines +59 to +66
@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)

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" />

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'depends': ['base', 'estate', 'account'],
'depends': ['estate', 'account'],

This is redundant as your estate module already relies on base module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants