Skip to content

yoelf - technical training#1244

Open
yoelfatihi wants to merge 15 commits intoodoo:19.0from
odoo-dev:19.0-technical-training-yoelf
Open

yoelf - technical training#1244
yoelfatihi wants to merge 15 commits intoodoo:19.0from
odoo-dev:19.0-technical-training-yoelf

Conversation

@yoelfatihi
Copy link
Copy Markdown

PR with the first chapter exercises

@robodoo
Copy link
Copy Markdown

robodoo commented Apr 21, 2026

Pull request status dashboard

@Mathilde411 Mathilde411 self-requested a review April 22, 2026 06:55
@yoelfatihi yoelfatihi force-pushed the 19.0-technical-training-yoelf branch from d31232a to 77632cf Compare April 22, 2026 08:11
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.

Mostly okay so far :)
There are some things to fix still :)

Comment thread estate/models/estate_property.py
Comment thread estate/models/estate_property.py
Comment thread estate/models/estate_property.py
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_property_views.xml Outdated
Comment thread estate/views/estate_property_views.xml Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py
@yoelfatihi yoelfatihi force-pushed the 19.0-technical-training-yoelf branch from 0f172ad to 2538c7d Compare April 23, 2026 08:36
yoelfatihi and others added 8 commits April 23, 2026 13:48
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.
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.

Pretty nice, only changes in the python files mainly.
Good job :)

Comment on lines +48 to +50
estate_property_type_id = fields.Many2one(
"estate.property.type", string="Property Type"
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you name the field 'property_type_id' you won't need to add the string attribute :)

estate_property_type_id = fields.Many2one(
"estate.property.type", string="Property Type"
)
buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False, readonly=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.

Won't say it anymore ater that but there are more instances:

For many2one field the default string will be Xyz for xyz_id
And for one2many and many2many Xyz for xyz_ids

Comment on lines +86 to +90
@api.onchange("garden")
def _onchange_has_garden(self):
if self.garden:
self.garden_area = 10
self.garden_orientation = "north"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here you forgot to reset to the default value if garden is false

Comment on lines +80 to +84
property.best_price = (
max(property.estate_property_offer_ids.mapped("price"))
if property.estate_property_offer_ids
else None
)
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
property.best_price = (
max(property.estate_property_offer_ids.mapped("price"))
if property.estate_property_offer_ids
else None
)
property.best_price = max(property.estate_property_offer_ids.mapped("price"), default=0)

raise UserError("You can't sell a a cancelled property :)")

property.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.

return True is indented too much here, will return at the first iteration of the loop

raise UserError("you can't cancel a sold property :)")

property.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

precision_digits=2,
) == -1:
raise ValidationError(
r"the selling price cannot be lower than 90% of the expected price"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Why a raw string here ?

Comment on lines +35 to +43
if offer.create_date:
offer.date_deadline = fields.Date.add(
offer.create_date,
days=offer.validity,
)
else:
offer.date_deadline = fields.Date.add(
fields.Date.today(), days=offer.validity
)
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
if offer.create_date:
offer.date_deadline = fields.Date.add(
offer.create_date,
days=offer.validity,
)
else:
offer.date_deadline = fields.Date.add(
fields.Date.today(), days=offer.validity
)
offer.date_deadline = fields.Date.add(
offer.create_date or fields.Date.today(),
days=offer.validity,
)

Comment on lines +46 to +50
for offer in self:
if offer.create_date:
offer.validity = (offer.date_deadline - offer.create_date.date()).days
else:
offer.validity = (offer.date_deadline - fields.Date.today()).days
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 offer in self:
if offer.create_date:
offer.validity = (offer.date_deadline - offer.create_date.date()).days
else:
offer.validity = (offer.date_deadline - fields.Date.today()).days
date = offer.create_date.date() if offer.create_date else fields.Date.today()
offer.validity = (offer.date_deadline - date).days

Comment on lines +7 to +10
<menuitem id="estate_settings_menu" name="Settings">
<menuitem id="estate_property_type_menu_action" action="estate_property_type_action"/>
<menuitem id="estate_property_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

XMLid naming is not correct here

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