Skip to content

dalio - Technical Training#1233

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

dalio - Technical Training#1233
dalio-odoo wants to merge 28 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 thread estate/security/ir.model.access.csv Outdated
Comment thread estate/security/ir.model.access.csv Outdated
Comment thread estate/views/estate_menus.xml Outdated
Comment thread estate/views/estate_menus.xml Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
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
Comment thread estate/models/estate_property.py Outdated
Comment thread estate/models/estate_property.py Outdated
Comment thread estate/models/estate_property.py Outdated
Comment thread estate/models/estate_property_offer.py Outdated
Comment thread estate/models/estate_property_offer.py Outdated
Comment thread estate/models/estate_property_offer.py Outdated
Comment thread estate/views/estate_property_views.xml Outdated
Comment thread estate/views/estate_property_views.xml Outdated
@dalio-odoo dalio-odoo force-pushed the 19.0-technical-training-dalio branch from 2409a9d to 1338c5c Compare April 27, 2026 14:05
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.

Good job !
Fix those last few things and you'll be good to go !

Comment thread estate/models/estate_property.py Outdated
Comment on lines +17 to +18
expected_price = fields.Monetary(currency_field="currency_id", required=True)
selling_price = fields.Monetary(currency_field="currency_id", readonly=True, 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.

Default currency_field should already be currency_id here, so no need to add it

Comment thread estate/models/estate_property.py Outdated
@api.ondelete(at_uninstall=False)
def _check_state_before_deletion(self):
for record in self:
if record.state not in ["new", "canceled"]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thre is a typo on "cancelled" here, won't work

Comment on lines +111 to +116
def action_sold(self):
for record in self:
if record.state == "cancelled":
raise UserError("Canceled properties cannot be sold.")
record.state = "sold"
return True
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
def action_sold(self):
for record in self:
if record.state == "cancelled":
raise UserError("Canceled properties cannot be sold.")
record.state = "sold"
return True
def action_sold(self):
for record in self:
if record.state == "cancelled":
raise UserError("Canceled properties cannot be sold.")
self.state = "sold"
return True

Only one assignation for the whole recordset

Comment on lines +118 to +123
def action_cancel(self):
for record in self:
if record.state == "sold":
raise UserError("Sold properties cannot be canceled.")
record.state = "cancelled"
return True
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 as above

Comment thread estate/models/estate_property_offer.py Outdated

price = fields.Monetary(currency_field="currency_id")
status = fields.Selection(
string="Status",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String not necessary

Comment on lines +48 to +60
@api.model
def create(self, vals_list):

for vals in vals_list:
prop = self.env["estate.property"].browse(vals.get("property_id"))
existing_prices = prop.offer_ids.mapped("price")

if existing_prices and vals.get("price") < max(existing_prices):
raise UserError(f"The offer must be higher than {max(existing_prices):.2f}")

prop.state = "offer_received"

return super().create(vals_list)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Browse in a loop is a performance killer it should never happen. Basically if you have a recordset of all the properties and you fetch a field for one of them, the ORM is going to fetch it for all and cache them so that next iteration of the loop, you have them ready. But there since you have a different recordset for every iteration of the loop, the ORM can't do this optimization and you'll end up with one request per iteration which is very not good.

Suggested change
@api.model
def create(self, vals_list):
for vals in vals_list:
prop = self.env["estate.property"].browse(vals.get("property_id"))
existing_prices = prop.offer_ids.mapped("price")
if existing_prices and vals.get("price") < max(existing_prices):
raise UserError(f"The offer must be higher than {max(existing_prices):.2f}")
prop.state = "offer_received"
return super().create(vals_list)
@api.model
def create(self, vals_list):
#do a search/browse here
for vals in vals_list: # <- etract it by **zip**ing the vals_list with the recordset :)
existing_prices = prop.offer_ids.mapped("price")
if existing_prices and vals.get("price") < max(existing_prices):
raise UserError(f"The offer must be higher than {max(existing_prices):.2f}")
prop.state = "offer_received"
return super().create(vals_list)

Comment thread estate/models/estate_property_type.py Outdated

_name = "estate.property.type"
_description = "Property Type"
_order = "name"
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 added a sequence to order the stages but the order here was not updated

_order = "name"

name = fields.Char(required=True)
sequence = fields.Integer('Sequence', default=1, help="Used to order stages. Lower is better.")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String not needed

Comment thread estate/models/estate_property_type.py Outdated
property_ids = fields.One2many("estate.property", "property_type_id", string="Properties")
offer_ids = fields.One2many("estate.property.offer", "property_type_id", string="Offers")

offer_count = fields.Integer(compute="_compute_offer_count", string="Offer Count")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

String not needed

Comment thread estate_account/__manifest__.py Outdated
"account",
],
"data": [],
"application": 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.

Application's default is False, you don't need it.

dalio-odoo and others added 9 commits April 30, 2026 11:05
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.
@dalio-odoo dalio-odoo force-pushed the 19.0-technical-training-dalio branch from 5b2c1b2 to e5ac3b6 Compare April 30, 2026 09:22
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