Skip to content

dalio - Technical Training#1233

Open
dalio-odoo wants to merge 29 commits intoodoo:19.0from
odoo-dev:19.0-technical-training-dalio
Open

dalio - Technical Training#1233
dalio-odoo wants to merge 29 commits intoodoo:19.0from
odoo-dev:19.0-technical-training-dalio

Conversation

@dalio-odoo
Copy link
Copy Markdown

No description provided.

@robodoo
Copy link
Copy Markdown

robodoo commented Apr 21, 2026

Pull request status dashboard

@Mathilde411 Mathilde411 self-requested a review April 21, 2026 13:30
@dalio-odoo dalio-odoo force-pushed the 19.0-technical-training-dalio branch from 6d29bbd to d9454fb Compare April 22, 2026 09:00
Copy link
Copy Markdown

@Mathilde411 Mathilde411 left a comment

Choose a reason for hiding this comment

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

Very solid PR.
Also be careful of usage of ' vs ". You should use a convention and stick to it.
Most R&D teams use ' :)

Comment thread .vscode/settings.json Outdated
Comment on lines +1 to +8
{
"python.analysis.extraPaths": [
"/home/odoo/src/venv",
"/home/odoo/src/odoo",
"/home/odoo/src/enterprise"
],
"python.defaultInterpreterPath": "/home/odoo/src/venv/bin/python3.12"
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This file is your local vscode confing, you shouldn't commit and push it to the repo

Comment thread estate/security/ir.model.access.csv Outdated
@@ -0,0 +1,2 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Using slashes work, but most commonly used is:

Suggested change
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink

Comment thread estate/security/ir.model.access.csv Outdated
@@ -0,0 +1,2 @@
id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The access right should say what group it applies on.
Name is meant to be displayed, usually names use dots in Odoo

Suggested change
access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
estate_property_access_user,estate.property.user,model_estate_property,base.group_user,1,1,1,1

Comment thread estate/views/estate_menus.xml Outdated
Comment on lines +3 to +5
<menuitem id="estate_menu_root" name="Real Estate"/>
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
<menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Menu items can be nested, avoids having to set the parent

Suggested change
<menuitem id="estate_menu_root" name="Real Estate"/>
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
<menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_first_level_menu" name="Advertisements">
<menuitem id="estate_property_menu_action" action="estate_property_action"/>
</menuitem>
</menuitem>

Comment thread estate/views/estate_menus.xml Outdated
Comment on lines +3 to +5
<menuitem id="estate_menu_root" name="Real Estate"/>
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
<menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#xml-ids-and-naming

Suggested change
<menuitem id="estate_menu_root" name="Real Estate"/>
<menuitem id="estate_first_level_menu" name="Advertisements" parent="estate_menu_root"/>
<menuitem id="estate_property_menu_action" parent="estate_first_level_menu" action="estate_property_action"/>
<menuitem id="estate_menu_root" name="Real Estate"/>
<menuitem id="estate_menu_advertisement" name="Advertisements" parent="estate_menu_root"/>
<menuitem id="estate_property_menu" parent="estate_menu_advertisement" action="estate_property_action"/>

Comment thread estate/__manifest__.py Outdated
@@ -0,0 +1,15 @@
{
'name': 'Real Estate',
'version': '1.0',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When using modules outside odoo standard, best practice is to specify th Odoo version.

Suggested change
'version': '1.0',
'version': '19.0.1.0.0',

Comment thread estate/__manifest__.py Outdated
'name': 'Real Estate',
'version': '1.0',
'depends': [
'base_setup'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the diff if you add a new dependency

Suggested change
'base_setup'
'base',

Also you should depend on base not base_setup

Comment thread estate/__manifest__.py Outdated
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menus.xml'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same, add a comma for the diff

Copy link
Copy Markdown

@Mathilde411 Mathilde411 left a comment

Choose a reason for hiding this comment

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

Very good, I don't have a lot to say :D

Comment thread estate/models/__init__.py Outdated
@@ -0,0 +1 @@
from . import estate_property, estate_property_type, estate_property_tag, estate_property_offer
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Make it one line per import, this way you can see what commit adds whant, and resolving conflicts is easier :)

Comment thread estate/models/estate_property.py Outdated
Comment on lines +95 to +118
_check_expected_price = models.Constraint(
"CHECK(expected_price > 0)",
"the expected price must be strictly positive.",
)

_check_selling_price = models.Constraint(
"CHECK(selling_price >= 0)",
"the selling price must be positive.",
)

@api.constrains("selling_price", "expected_price")
def _check_selling_price(self):
for record in self:

if float_is_zero(record.selling_price, precision_digits=2):
continue

lower_bound = 0.9 * record.expected_price

if float_compare(record.selling_price, lower_bound, precision_digits=2) == -1:
raise ValidationError(
"The selling price must be at least 90% of the expected price! "
"You must reduce the expected price if you want to accept this offer."
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Be careful about attribute ordering

Comment thread estate/models/estate_property.py Outdated
)
property_type_id = fields.Many2one("estate.property.type", string="Property Type")
salesman_id = fields.Many2one("res.users", string="Salesman", default=lambda self: self.env.user)
buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When using a many2one the string is inferred by removing _id at the end. So buyer_id default string is "Buyer", so no need to add the string there :D
(same for many2many and one2many but w/ _ids instead)

Comment thread estate/models/estate_property.py Outdated
Comment on lines +65 to +70
prices = record.offer_ids.mapped("price")

if prices:
record.best_price = max(prices)
else:
record.best_price = 0.0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
prices = record.offer_ids.mapped("price")
if prices:
record.best_price = max(prices)
else:
record.best_price = 0.0
prices = max(record.offer_ids.mapped("price"), default=0.0)

There is a default argument on max (and min) that avoids the condition

Comment thread estate/models/estate_property_offer.py Outdated
def _compute_date_deadline(self):
for record in self:
base_date = record.create_date or fields.Date.today()
days_to_add = record.validity or 0
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You don't need the days_to_add here, for numeric fields, the default value is always 0, so you can use record.validity directly :)

Comment thread estate/models/estate_property_offer.py Outdated

def _inverse_date_deadline(self):
for record in self:
base_date = fields.Date.to_date(record.create_date) or fields.Date.today()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

use 'record.create_date.date()'

Comment thread estate/models/estate_property_offer.py Outdated
Comment on lines +48 to +49
for record in self:
record.status = "refused"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested change
for record in self:
record.status = "refused"
self.status = "refused"

You can assign values of recordsets attributes, no need to iterate :D

Comment thread estate/views/estate_property_views.xml Outdated
Comment on lines +31 to +36
<button name="action_sold"
string="Sold"
type="object"
class="oe_highlight"/> <button name="action_cancel"
string="Cancel"
type="object"/> <field name="state" widget="statusbar" statusbar_visible="new,offer_received,offer_accepted,sold"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Formatting is weird here

Comment thread estate/views/estate_property_views.xml Outdated
</div>
<group>
<group>
<field name="state"/>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

State here is not necessary since you have the statusbar :)

@dalio-odoo dalio-odoo force-pushed the 19.0-technical-training-dalio branch from 2409a9d to 1338c5c Compare April 27, 2026 14:05
vandroogenbd and others added 5 commits April 28, 2026 15:39
This commit is here to introduce the testing framework of Odoo. Try running the
tests using `--test-tags :TestEstateProperty`.

Doc:
https://www.odoo.com/documentation/18.0/developer/reference/backend/testing.html?highlight=tests#invocation

The tests were made such that the first one should work but the second one
should fail. Your job is to ensure both tests pass in the end. You should update
the behaviour of the appropriate models.

If you want, you can also add a small test of your own to get a feel for it.
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.

4 participants