Skip to content

Conversation

@THDES-odoo
Copy link

No description provided.

This module will be the basis of the Estate App
@robodoo
Copy link

robodoo commented Jan 19, 2026

Pull request status dashboard

Copy link

@artn-odoo artn-odoo left a comment

Choose a reason for hiding this comment

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

Nice job so far !
All comments are small styling nitpicks but your code won't pass the styling tests if they are not fixed.
We also try to always add an empty line at the end of every file. If using vscode, the Insert Final Newline option can be activated to do it automatically every time you save your file.

Copy link

@artn-odoo artn-odoo left a comment

Choose a reason for hiding this comment

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

Nice one, as usual just a few nitpicks

Comment on lines 12 to 13
date_availability = fields.Date('Availability Date', copy=False,
default=fields.Date.add(fields.Date.today(), months=3))

Choose a reason for hiding this comment

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

If the line is split because it's too long, every parameter should be on it's own line

Suggested change
date_availability = fields.Date('Availability Date', copy=False,
default=fields.Date.add(fields.Date.today(), months=3))
date_availability = fields.Date(
'Availability Date',
copy=False,
default=fields.Date.add(fields.Date.today(), months=3)
)

And the closing bracket's indentation should match the opening one

Comment on lines 24 to 29
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('north', 'North'), ('south', 'South'),
('east', 'East'), ('west', 'West')
])

Choose a reason for hiding this comment

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

Try to match the opening bracket's indentation

Suggested change
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('north', 'North'), ('south', 'South'),
('east', 'East'), ('west', 'West')
])
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('north', 'North'),
('south', 'South'),
('east', 'East'),
('west', 'West')
]
)

Also, it would be better to have each selection proposition on it's own line

Comment on lines 33 to 39
selection=[
('new', 'New'), ('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'), ('cancelled', 'Cancelled') ],
default='new',
required=True
)

Choose a reason for hiding this comment

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

Same as above

Suggested change
selection=[
('new', 'New'), ('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'), ('cancelled', 'Cancelled') ],
default='new',
required=True
)
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled')
],
default='new',
required=True
)

Updating the selling price before the state of the property lead to a
property with state 'offer_accepted' and selling_price = 0. trigger the
constraint to raise an error.

Now, the state is updated first, to prevent the error.
Copy link

@artn-odoo artn-odoo left a comment

Choose a reason for hiding this comment

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

Looks almost good to me !

Comment on lines 15 to 23

date_availability = fields.Date(
'Availability Date',
copy=False,
default=fields.Date.add(fields.Date.today(), months=3)
)
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price', readonly=True, copy=False)

Choose a reason for hiding this comment

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

The newlines seem kind of random, you could just remove them IMO

Suggested change
date_availability = fields.Date(
'Availability Date',
copy=False,
default=fields.Date.add(fields.Date.today(), months=3)
)
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price', readonly=True, copy=False)
date_availability = fields.Date(
'Availability Date',
copy=False,
default=fields.Date.add(fields.Date.today(), months=3)
)
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price', readonly=True, copy=False)

Comment on lines 72 to 85
@api.constrains('state', 'expected_price', 'selling_price')
def _check_prices(self):
for record in self:
if record.state == 'offer_accepted' and self._offer_too_low():
raise ValidationError('The selling price must be at least 90% of the selling price')

def _offer_too_low(self):
self.ensure_one()
return float_compare(
self.selling_price,
self.expected_price * 0.9,
precision_digits=2
) == -1

Choose a reason for hiding this comment

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

In this case, I feel like this is a bit overkill, it could be done in one line in the constrains, or you could break the line before the and if it gets too long

Suggested change
@api.constrains('state', 'expected_price', 'selling_price')
def _check_prices(self):
for record in self:
if record.state == 'offer_accepted' and self._offer_too_low():
raise ValidationError('The selling price must be at least 90% of the selling price')
def _offer_too_low(self):
self.ensure_one()
return float_compare(
self.selling_price,
self.expected_price * 0.9,
precision_digits=2
) == -1
@api.constrains('state', 'expected_price', 'selling_price')
def _check_prices(self):
for record in self:
if record.state == 'offer_accepted' and float_compare(self.selling_price, self.expected_price * 0.9, precision_digits=2) == -1:
raise ValidationError('The selling price must be at least 90% of the selling price')

That was a nice try though, and it could have been the right solution had the use case been a bit different !

Comment on lines 15 to 25

validity = fields.Integer(string='Validity (days)', default=7)
date_deadline = fields.Date(
string='Deadline',
compute='_compute_deadline',
inverse="_compute_validity"
)

property_id = fields.Many2one('estate.property', string='Property', required=True)
partner_id = fields.Many2one('res.partner', string='Partner', required=True)

Choose a reason for hiding this comment

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

Same here the newlines seem kind of random

Suggested change
validity = fields.Integer(string='Validity (days)', default=7)
date_deadline = fields.Date(
string='Deadline',
compute='_compute_deadline',
inverse="_compute_validity"
)
property_id = fields.Many2one('estate.property', string='Property', required=True)
partner_id = fields.Many2one('res.partner', string='Partner', required=True)
validity = fields.Integer(string='Validity (days)', default=7)
date_deadline = fields.Date(
string='Deadline',
compute='_compute_deadline',
inverse="_compute_validity"
)
property_id = fields.Many2one('estate.property', string='Property', required=True)
partner_id = fields.Many2one('res.partner', string='Partner', required=True)

Copy link

@artn-odoo artn-odoo left a comment

Choose a reason for hiding this comment

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

Looking good !

Comment on lines +104 to +106

record.state = 'sold'

Choose a reason for hiding this comment

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

Looks kinda weird IMO, removing the lines should be fine

Suggested change
record.state = 'sold'
record.state = 'sold'

Comment on lines +113 to +115

record.state = 'canceled'

Choose a reason for hiding this comment

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

Same here

Suggested change
record.state = 'canceled'
record.state = 'canceled'

Comment on lines +54 to +56

self.state = 'accepted'

Choose a reason for hiding this comment

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

Suggested change
self.state = 'accepted'
self.state = 'accepted'

Lots of unneeded newlines, won't point them all out but I feel like this is a bit much

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