Skip to content

19.0 tutorials amtha - #1376

Draft
amtha-odoo wants to merge 21 commits into
odoo:19.0from
odoo-dev:19.0-tutorials-amtha
Draft

19.0 tutorials amtha#1376
amtha-odoo wants to merge 21 commits into
odoo:19.0from
odoo-dev:19.0-tutorials-amtha

Conversation

@amtha-odoo

Copy link
Copy Markdown
  • Created Estate module and models
  • Added list, form, and search views
  • Configured menus, actions, and security
  • Implemented model relationships (Many2one, One2many, Many2many)
  • Added computed fields, inverse methods, and onchange logic
  • Implemented property and offer business actions (Sold, Cancel, Accept, Refuse)
  • Added validations and state management
  • Updated property buyer and selling price on offer acceptance

amtha-odoo added 17 commits July 2, 2026 18:11
Add the basic structure for the estate module as part of the Odoo Server Framework 101 training.
Introduce the initial user interface for the estate module by defining the
window action and menu hierarchy required to access property records from the
Odoo web client.

This change makes the estate.property model accessible through the application,
providing the foundation for interacting with records using the default list
and form views before introducing custom views in later chapters.

The property model is also improved by configuring field attributes and
defaults. Read-only and copy behaviors are defined for system-managed fields,
default values are added to reduce manual data entry, and the reserved active
and state fields are introduced to support record archiving and future
workflow-related features.
Introduce the initial user interface for the estate module by defining the
window action and menu hierarchy required to access property records from the
Odoo web client.

This change makes the estate.property model accessible through the application,
providing the foundation for interacting with records using the default list
and form views before introducing custom views in later chapters.

The property model is also improved by configuring field attributes and
defaults. Read-only and copy behaviors are defined for system-managed fields,
default values are added to reduce manual data entry, and the reserved active
and state fields are introduced to support record archiving and future
workflow-related features.
Replace the automatically generated views with custom list and form views
to provide a clearer and more user-friendly interface for managing estate
properties.

The custom views organize the property information into logical groups,
making property creation and editing easier while exposing the most
important fields directly from the list view.

This change prepares the module for future UI enhancements such as custom
search views, buttons and advanced form layouts introduced in later
chapters.
-compute the total-area of the property
-compute the best-price of the property using private methods
-compute the deadline from create_date and validity
-implement an inverse method to update validity from the deadline
-handle record creation by providing a fallback when create_date is not yet available
-display the new fields in the offer tree and form views
@amtha-odoo
amtha-odoo requested a review from mash-odoo July 29, 2026 07:16
@robodoo

robodoo commented Jul 29, 2026

Copy link
Copy Markdown

Pull request status dashboard

@amtha-odoo
amtha-odoo force-pushed the 19.0-tutorials-amtha branch from 6c89568 to 26ccc80 Compare August 11, 2026 12:48

@mash-odoo mash-odoo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello,
Good start on the task.
I have added some comments and suggestions.
Some points to be looked at:

  1. Do not leave unnecessary lines between fields.
  2. Reformat the files according to the coding guidelines.
  3. Add description and chapter name while pushing the commits in order to understand the changes done for that particular commit.
  4. Update the PR title.

Comment thread estate/models/__init__.py Outdated
Comment on lines +1 to +3
# estate/models/__init__.py

from . import 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.

Suggested change
# estate/models/__init__.py
from . import estate_property
from . import estate_property

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment thread estate/models/estate_property.py Outdated
Comment on lines +11 to +19
_order = "name asc"

name = fields.Char(required=True)
total_area = fields.Integer(compute="_compute_total_area")

@api.depends("living_area", "garden_area")
def _compute_total_area(self):
for record in self:
record.total_area = record.living_area + record.garden_area

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please refer to this for proper ordering of attributes in a model

Image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

Comment on lines +62 to +75
property_type_id = fields.Many2one(
"estate.property.type",
string="Property Type",
)

buyer_id = fields.Many2one(
"res.partner",
string="Buyer",
copy=False,
)
salesperson_id = fields.Many2one(
"res.users",
string="Salesperson",
default=lambda self: self.env.user,

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 to add string explicitly if you want it to be similar to the field name itself.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Remove string attributes from fields where the default field label is already appropriate.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

string /home/odoo/odoo19/community/odoo/orm/fields.py line no. = 508 =>Odoo automatically generates the UI label from the field's technical name.

Comment on lines +115 to +122
garden_orientation = fields.Selection(
[
("north", "North"),
("south", "South"),
("east", "East"),
("west", "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.

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

Try to keep the key i.e the technical strings in single quotes and the values which are to be displayed to the user in double quotes

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

)
< 0
):
raise ValidationError(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When would you raise UserError and ValidationError?
What is the difference between both of them?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

UserError : use when the user perform invalid action.usually use in button and action methods and stop the current operation
ValidationError : use when data violates a validation.prevents invalid data from being saved.

Both will show an error popup to the user, but UserError is used when a user performs an action that is not allowed, and ValidationError is used when entered or modified data fails a validation

</field>
</record>

</odoo> 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.

Always leave an extra line at the end of the file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok

<field name="partner_id"/>
<field name="validity"/>
<field name="deadline"/>
<button name="action_confirm" string="Confirm" type="object" icon="fa-check"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When to use type object and type action?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

type = "object" : used when execute python method defined on the model.
type = "action" : used when execute an odoo action identified by its external ID.

Comment thread estate/__manifest__.py Outdated
"depends": ["base"],
"application": True,
"category": "Tutorials",
"author": "Thakor Anish",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When you are working for a company, you should keep the author name as Odoo S.A. or just skip writing it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok

Comment thread estate/__manifest__.py
"application": True,
"category": "Tutorials",
"author": "Thakor Anish",
"license": "LGPL-3",

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 other options are there for licensing?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

/home/odoo/odoo19/community/odoo/addons/base/models/ir_module.py == line no. : 296

GPL-2,GPL-3,AGPL-3,LGPL-3,OEEL-1,OPL-1

Comment thread estate/models/estate_property.py Outdated
best_price = fields.Float(
string="Best Offer",
compute="_compute_best_price",
store=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.

Why do we need to store this value?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For a calculated field, use store=True to store the value in the database. but here we don't need to store this value here, so I removed store=True.

- Fix line spacing
- Reorder model attributes and methods
- Remove unnecessary field string attributes
- Update selection technical values to single quotes
- Add trailing newline at end of files
- Update author name
- Remove unnecessary store=True from best_price
@amtha-odoo
amtha-odoo force-pushed the 19.0-tutorials-amtha branch from 2333d73 to b00f3b5 Compare August 13, 2026 11:36
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