Skip to content

rohar - Technical Training#1242

Open
rohar-odoo wants to merge 1 commit intoodoo:19.0from
odoo-dev:19.0-onboarding-rohar
Open

rohar - Technical Training#1242
rohar-odoo wants to merge 1 commit intoodoo:19.0from
odoo-dev:19.0-onboarding-rohar

Conversation

@rohar-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 22, 2026 06:56
@rohar-odoo rohar-odoo force-pushed the 19.0-onboarding-rohar branch from bcfd4ea to a6d47e1 Compare April 22, 2026 08:06
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 good so far !
Runbot is green so good job !
Also would you be able to squash your commits so that you only have one per chapter ?

Comment thread estate/models/estate_property.py Outdated
Comment thread estate/models/estate_property.py Outdated
Comment thread estate/models/estate_property.py
Comment thread estate/models/estate_property.py Outdated
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
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1 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.

Suggested change
estate.access_estate_property,access_estate_property,estate.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

Comments for each column:
1st column is the XMLid of the access right, it should be <model_name>_access_<concerned_group> (similarly to record rules in https://www.odoo.com/documentation/19.0/contributing/development/coding_guidelines.html#xml-ids-and-naming)
second column is the name
2nd column is the name of the rule, the one that will be displayed in the ui, should say the model name and the targeted group (there is not really a fixed way, but a common one is with dots, like suggested)
3rd one is the xmlid of the model targeted, you don't need to add the module name in front if the xmlid is from the same module as you, same for 4th column that represents the targetted group

Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
Comment thread estate/__manifest__.py Outdated
@rohar-odoo rohar-odoo force-pushed the 19.0-onboarding-rohar branch 2 times, most recently from 9687c2b to 31493f7 Compare April 23, 2026 09:24
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 here !
Here are a few things that I'd have done another way :)

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.py Outdated
Comment thread estate/models/estate_property.py Outdated
Comment thread estate/views/estate_menus.xml Outdated
Comment thread estate/views/estate_property_offer_views.xml Outdated
Comment thread estate/views/estate_property_tag_views.xml Outdated
Comment thread estate/views/estate_property_views.xml Outdated
Comment thread estate/views/estate_property_views.xml Outdated
@rohar-odoo rohar-odoo force-pushed the 19.0-onboarding-rohar branch 4 times, most recently from 0af77d9 to 9013cee Compare April 29, 2026 13:22
@rohar-odoo rohar-odoo force-pushed the 19.0-onboarding-rohar branch from 9013cee to 7745737 Compare April 29, 2026 13:56
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.

Oops forgot to submit it !
Pretty good overall !
Fix the last few points and you'll be good to go !

Comment on lines +92 to +113
_check_expected_price = models.Constraint(
"CHECK(expected_price > 0)",
"A property expected price must be stricly positive",
)

_check_selling_price = models.Constraint(
"CHECK(selling_price >= 0)",
"A property 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):
return
if float_compare(record.selling_price, 0.9 * record.expected_price, precision_digits=2) == -1:
raise ValidationError("The selling price cannot be lower than 90% of the expected price.")

@api.ondelete(at_uninstall=False)
def _unlink_if_new_or_cancelled(self):
if any(not record.state in ("new", "cancelled") for record in self):
raise UserError("Can only delete an new or cancelled property.")
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

)

@api.constrains("selling_price", "expected_price")
def check_selling_price(self):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be named '_check_selling_price'

Comment on lines +105 to +106
if float_is_zero(record.selling_price, precision_digits=2):
return
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 an exception for 0 ?

Comment on lines +35 to +43
@api.model
def create(self, vals_list):
property = self.env["estate.property"].browse(vals_list[0]["property_id"])
if max(property.offer_ids.mapped("price"), default=0.0) > vals_list[0]["price"]:
raise UserError("New offer must be higher than existing ones.")

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

What if I create multiple records ? (multiple values in vals_list) then only the first one would be checked

Comment on lines +45 to +65
def _inverse_date_deadline(self):
for record in self:
days = record.date_deadline - record.create_date.date()
record.validity = days.days

def action_accept(self):
for record in self:
property_id = record.property_id
if property_id.state in ("sold", "accepted"):
raise UserError("A sold or cancelled property can't be sold.")

if (property_id.has_garden and property_id.garden_orientation == "south" and float_compare(record.price, property_id.expected_price, precision_digits=2) == -1):
raise ValidationError("The selling price cannot be lower than 90% of the expected price.")

record.status = "accepted"
property_id.state = "sold"
property_id.buyer_id = record.partner_id
property_id.selling_price = record.price

def action_refuse(self):
self.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.

Attribute ordering :)

estate_property_access_user,estate.property.user,model_estate_property,base.group_user,1,1,1,1
estate_property_type_access_user,estate.property.type.user,model_estate_property_type,base.group_user,1,1,1,1
estate_property_tag_access_user,estate.property.tag.user,model_estate_property_tag,base.group_user,1,1,1,1
estate_property_offer_acces_user,estate.property.offer.user,model_estate_property_offer,base.group_user,1,1,1,1 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.

typo

Comment on lines +12 to +14
<field name="validity" optional="true"/>
<field name="date_deadline" optional="true"/>
<field name="property_type_id" optional="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.

Optional values are hide or show

Comment on lines +1 to +6
from odoo import models


class EstateAccount(models.Model):
_name = "estate.account"
_description = "Real estate accounting"
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 a model here ? Why did you add it ?

Comment on lines +5 to +6
_name = "estate.property"
_inherit = ["estate.property"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can just be:

Suggested change
_name = "estate.property"
_inherit = ["estate.property"]
_inherit = "estate.property"

"security/ir.model.access.csv",
],
"license": "LGPL-3",
"auto_install": 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.

This makes sense here ! Do you know why ?

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