Skip to content

[ADD] estate:Create first Estate module #731

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

Draft
wants to merge 8 commits into
base: 18.0
Choose a base branch
from

Conversation

adak-ahmed
Copy link

Adding manifest and fields.

@robodoo
Copy link

robodoo commented Apr 22, 2025

Pull request status dashboard

Copy link

@SergeBayet SergeBayet left a comment

Choose a reason for hiding this comment

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

Some remarks. :)

'application':True,


}

Choose a reason for hiding this comment

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

Missing a blank line at the end of the file.

@@ -0,0 +1 @@
from . import estate

Choose a reason for hiding this comment

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

Same here.


from odoo import fields, models
class Estate(models.Model):
_name="estate"

Choose a reason for hiding this comment

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

blank spaces around equal signs.

Copy link

@SergeBayet SergeBayet left a comment

Choose a reason for hiding this comment

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

Some remarks 👍

Comment on lines 16 to 17


Choose a reason for hiding this comment

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

There are plenty of unnecessary blank lines in your files.

Comment on lines 25 to 31







Choose a reason for hiding this comment

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

Like here :)
Remove these lines here and elsewhere in your code.

</menuitem>


</odoo>

Choose a reason for hiding this comment

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

And here a blank line is missing at the end of file

Copy link

@SergeBayet SergeBayet left a comment

Choose a reason for hiding this comment

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

Some remarks! Keep going! :)

self.garden_orientation = "north"
else:
self.garden_area = 0
self.garden_orientation = ""

Choose a reason for hiding this comment

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

Suggested change
self.garden_orientation = ""
self.garden_orientation = False

record.total_area = record.living_area + record.garden_area

@api.depends("offer_ids")
def _max_offer_price(self):

Choose a reason for hiding this comment

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

the method should start with _compute_...

for record in self:
record.total_area = record.living_area + record.garden_area

@api.depends("offer_ids")

Choose a reason for hiding this comment

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

Depends only on offer_ids, not offer_ids.price, which means the method won’t be triggered when an offer’s price changes, unless a new offer is added/removed.


@api.depends("offer_ids")
def _max_offer_price(self):
self.best_price = max(self.offer_ids.mapped("price"), default=0)

Choose a reason for hiding this comment

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

This sets self.best_price assuming self is a single record, but compute methods must support recordsets.
You should loop through self.

@@ -8,3 +9,18 @@ class Offer(models.Model):
status = fields.Selection([("accepted", "Accepted"), ("refused", "Refused")])
buyer_id = fields.Many2one("buyer")
property_id = fields.Many2one("realestate")
validity = fields.Integer()
deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline")

Choose a reason for hiding this comment

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

It's a good habit to add the suffix _date on a Date field.

@SergeBayet
Copy link

@naja628 And a last one for you.


def set_offer_accepted(self):
self.ensure_one()
record = self

Choose a reason for hiding this comment

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

why??

if record.property_id.state == "sold":
raise UserError("This property is already sold")
record.status = "accepted"
record.property_id.selling_price = record.price

Choose a reason for hiding this comment

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

You can use 'mappedto avoid repeatingrecord.property_id`

Copy link

@naja628 naja628 left a comment

Choose a reason for hiding this comment

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

Hello :)

[Sorry I see Serge also did a 2nd pass on your code too -- I guess you will have 2 2nd reviews]

I left some comments on your code

I see you haven't reacted to Serge's previous suggestions yet -- could you do that too please?

Comment on lines +1 to +7
from . import realestate
from . import owner
from . import types
from . import tags
from . import seller
from . import buyer
from . import offer
Copy link

Choose a reason for hiding this comment

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

nitpick: by convention, we prefix model names with the name of the module

Suggested change
from . import realestate
from . import owner
from . import types
from . import tags
from . import seller
from . import buyer
from . import offer
from . import realestate_property
from . import realesate_owner
....

Comment on lines 5 to 12
"security/ir.model.access.csv",
"views/estate_view.xml",
"views/owner_view.xml",
"views/type_view.xml",
"views/tag_view.xml",
"views/seller_view.xml",
"views/buyer_view.xml",
"views/offer_view.xml",
Copy link

Choose a reason for hiding this comment

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

similarly the files could be named realestate_owner_view.xml ...



class Buyer(models.Model):
_name = "buyer"
Copy link

Choose a reason for hiding this comment

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

Suggested change
_name = "buyer"
_name = "realestate_buyer"

(etc...)

Comment on lines +45 to +48
status = fields.Selection(related="offer_ids.status")
price = fields.Float(related="offer_ids.price")
validity = fields.Integer(related="offer_ids.validity")
deadline = fields.Date(related="offer_ids.deadline")
Copy link

Choose a reason for hiding this comment

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

You cannot created related fields that pass through an x2many (you can look at the warning in the Doc)

What are you trying to accomplish here? What do you think the value should be?

</menuitem>


</odoo>
Copy link

Choose a reason for hiding this comment

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

Some of your files are missing the eol character at the end of the last line (hence the red signs in the github ui) -- could you configure your editor so it doesn't do that please?

_sql_constraints = [
(
"check_expected_price",
"CHECK(expected_price> 0)",
Copy link

Choose a reason for hiding this comment

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

nitpick:

Suggested change
"CHECK(expected_price> 0)",
"CHECK(expected_price > 0)",

(more places)

for record in self:
if record.selling_price < 0.9 * record.expected_price:
raise ValidationError(
"Selling price must be at least 90'%' of the expected price"
Copy link

Choose a reason for hiding this comment

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

  • why the quotes around the %
  • try wrap user facing text in a call to _ so it can be translated

Comment on lines +58 to +59


Copy link

Choose a reason for hiding this comment

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

nitpick:

Suggested change

I like the idea of separating things but 2 blank lines is a bit overkill ^^

<search>
<field name="postcode" />
<field name='name' />
<filter name='is_garden' string='With Garden' domain="[('garden','=', 'True')]" />
Copy link

Choose a reason for hiding this comment

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

nitpick: do you think is_garden is a good name for what this represents?

@SergeBayet
Copy link

@adak-ahmed You can click on the button "Ready for review" and try to make runbot happy. :) The commit titles don't follow the guidelines.

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