Skip to content

[ADD] estate,estate_account: technical onboarding commit #1285

Open
jupir-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-tuto-server-jupir
Open

[ADD] estate,estate_account: technical onboarding commit #1285
jupir-odoo wants to merge 1 commit into
odoo:19.0from
odoo-dev:19.0-tuto-server-jupir

Conversation

@jupir-odoo
Copy link
Copy Markdown

@jupir-odoo jupir-odoo commented May 19, 2026

jupir's technical onboarding

task-6229399

@robodoo
Copy link
Copy Markdown

robodoo commented May 19, 2026

Pull request status dashboard

@aboo-odoo aboo-odoo self-requested a review May 21, 2026 07:48
@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 07fb131 to 2b8c4ec Compare May 21, 2026 13:47
@jupir-odoo jupir-odoo changed the title 19.0 tuto server jupir [ADD] estate,estate_accountant: technical onboarding commit May 21, 2026
@jupir-odoo
Copy link
Copy Markdown
Author

@aboo-odoo kind reminder :D

@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 2b8c4ec to 5c36dbc Compare May 21, 2026 14:19
@jupir-odoo jupir-odoo changed the title [ADD] estate,estate_accountant: technical onboarding commit [ADD] estate,estate_account: technical onboarding commit May 21, 2026
Copy link
Copy Markdown

@aboo-odoo aboo-odoo left a comment

Choose a reason for hiding this comment

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

Fenomenal work 🥳 I'm being extra-picky so that I can transmit as much information as possible. If there is anything you disagree with, please share it without fear.

Some comments apply at several places but I've only written it once to save some time and to not cumbersome the PR, when you check and update according to one of my comment, check that this comment does not apply elsewhere before moving to the next one 😄

A generic comment:

  • your PR/commit body could be a little more exhaustive a good template is to follow is
STEPS to reproduce the bug (only for bugfixes)
PROBLEM - what is the problem 
GOAL - what do we want to achieve
SOLUTION - how did we achieve it 

task-XXXXXX

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In a Model attribute order should be:

  1. Private attributes (_name, _description, _inherit, …)
  2. Default method and default_get
  3. Field declarations
  4. SQL constraints and indexes
  5. Compute, inverse and search methods in the same order as field declaration
  6. Selection method (methods used to return computed values for selection fields)
  7. Constrains methods (@api.constrains) and onchange methods (@api.onchange)
  8. CRUD methods (ORM overrides)
  9. Action methods
  10. And finally, other business methods.

Comment thread estate/models/estate_property.py Outdated
copy=False, default=datetime.today() + relativedelta(months=3)
)
expected_price = fields.Float(required=True)
_expected_price_constraint = models.Constraint(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The two constraints should be just after the _order attribute 😄



class EstatePropery(models.Model):
_name = "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.

There is a tacit convention that strings viewed by the users are surrounded by ", otherwise it is '

Suggested change
_name = "estate.property"
_name = 'estate.property'

garden_area = fields.Integer()
garden_orientation = fields.Selection(
string="Orientation",
selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Consider selection and a kind of dictionary, for dictionaries, you would write the keys in lower letters

Suggested change
selection=[("N", "North"), ("E", "East"), ("S", "South"), ("W", "West")],
selection=[('north', "North"), ('east', "East"), ('south', "South"), ('west', "West")],

Also, don't hesitate to be exhaustive in your name; estate.garden_orientation = 'north' is a bit clearer than estate.garden_orientation = 'n'

Comment thread estate/models/estate_property.py Outdated
default="new",
)

def action_cancel_property(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.

self is a recordset, i.e. a collection of records. Your method would failed if called on several records when trying to perform self.state.

Currently, through the UI, you cannot trigger the error, but from the command line or a server action, users could get the traceback.

side note: you can run odoo in terminal mode by adding shell after odoo-bin: python odoo-bin shell --addons-path .... From there, you could perform

estates = self.env['estate.property'].create([{'name': 'TEST1', ADD the other relevant key-value pairs}, {'name': 'TEST2', ADD the other relevant key-value pairs}])
estates.action_cancel_property()  # This should trigger the traceback

There are two ways to solve the issue:

  • begin your method with self.ensure_one(), quite self explanatory
  • or use a for loop like in _compute methods

Comment thread estate/models/estate_property_offer.py Outdated
)

def action_accept(self):
if self.property_id.state == "sold":
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 happens if the property is cancelled ?

Comment thread estate/models/estate_property_offer.py Outdated
Comment on lines +41 to +42
@api.model
def create(self, vals):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be preferable that you create the records in a batch rather than one by one, better performances 😄

Suggested change
@api.model
def create(self, vals):
@api.model_create_multi
def create(self, vals_list):

Comment thread estate/models/estate_property_offer.py Outdated
if float_compare(property.best_price, record["price"], 2) == 1:
raise UserError("You already have a higher offer")

if hasattr(property, "state"):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The property model always has the state attribute (you defined it as field), in what scenario could you not have one ?

Comment thread estate/__manifest__.py
],
"installable": True,
"application": True,
"author": "Julien (jupir)",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Everything you create for Odoo belongs to "Odoo S.A." hehe

Suggested change
"author": "Julien (jupir)",
"author": "Odoo S.A.",

Comment on lines +57 to +62
delta = timedelta(days=offer.validity)
offer.date_deadline = (
offer.create_date.date() + delta
if offer.create_date
else today() + delta
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Alternatively (one-liner)

Suggested change
delta = timedelta(days=offer.validity)
offer.date_deadline = (
offer.create_date.date() + delta
if offer.create_date
else today() + delta
)
offer.date_deadline = (offer.create_date or today()).date() + timedelta(days=offer.validity)

jupir's technical onboarding

task-6229399
@jupir-odoo jupir-odoo force-pushed the 19.0-tuto-server-jupir branch from 5c36dbc to 4fd2d3b Compare May 22, 2026 11:30
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