8000 XAFR - Technical Training by xafr-odoo · Pull Request #740 · odoo/tutorials · GitHub
[go: up one dir, main page]

Skip to content

XAFR - Technical Training #740

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

Open
wants to merge 21 commits into
base: 18.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[IMP] Chapter 2: New Application
  • Loading branch information
xafr-odoo committed Apr 25, 2025
commit 6c3923211e54822e70d3b9535cf9ea4481d69eab
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
1 change: 1 addition & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_property
34 changes: 34 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from odoo import fields, models, api

class TestModel(models.Model):
_name = "estate.property"
_description = "Estate properties"

name = fields.Char('Title', required=True, translate=True)
description = fields.Text('Description')
postcode = fields.Integer('Postcode', help="Your post code in 4 or 5 digits.")
date_availability = fields.Date('Date Availability')
expected_price = fields.Float('Expected Price', required=True)
selling_price = fields.Float('Selling Price')
bedrooms = fields.Integer(string='Bedrooms')
living_area = fields.Integer('Living Area (sqm)')
facades = fields.Integer('Facades')
garage = fields.Boolean('Garage')
garden = fields.Boolean('Garden')
garden_area = fields.Integer('Garden Area (sqm)')
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[('north', 'North'), ('west', 'West'), ('south', 'South'), ('east', 'East')],
help="The selection of the garden orientation.")
Copy link
@sedi-odoo sedi-odoo Apr 24, 2025

Choose a reason for hiding this comment

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

All good but most of the field display names are not required.

If not set, Odoo will basically deduct the display name of the field based on the field name. It'll separate it on the underscore and capitalize every word. (In case of a Many2One, Many2Many or One2Many behaviour will be slightly different but we'll see that when you'll have some). For example:

description -> Description
expected_price -> Expected Price

Basically, except name, living_area and garden_area none of them are required to be explicitly mentioned. Not a big issue but helps code look cleaner.

Copy link
Author

Choose a reason for hiding this comment

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

Ok thank you that's good to know :)


# company_currency_id = fields.Many2one('res.currency', compute='_compute_company_currency_id')
# expected_price = fields.Monetary('Expected Price', currency_field='company_currency_id')


_sql_constraints = [
('check_selling_price', 'CHECK(selling_price >= 0)', 'The price can\'t be negative.'),
]

@api.depends_context('company')
def _compute_company_currency_id(self):
self.company_currency_id = self.env.company.currency_id
0