Skip to content
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

Odoo tutorial - SERU branch #626

Open
wants to merge 4 commits into
base: 18.0
Choose a base branch
from
Open

Odoo tutorial - SERU branch #626

wants to merge 4 commits into from

Conversation

Syozik
Copy link

@Syozik Syozik commented Mar 17, 2025

Created a new Estate module that allows us to add properties, their types and tags. We can monitor the status of the property. When property is sold another added module - estate account creates a new invoice.

@robodoo
Copy link

robodoo commented Mar 17, 2025

Pull request status dashboard

@Syozik Syozik changed the title Seru branch Odoo tutorial - SERU branch Mar 17, 2025
Copy link

@dbeguin dbeguin left a comment

Choose a reason for hiding this comment

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

Good work already! :)
I have some picky comments mainly regarding guidelines :)

'version': '0.1',
'category': 'Real Estate'
'category': 'Real Estate',
'depends': ['base_setup'],
Copy link

Choose a reason for hiding this comment

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

you will probably need base and web. (base setup is way to "low")

Comment on lines 6 to 9
'depends':[
'base_setup'
],
Copy link

Choose a reason for hiding this comment

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

duplicate (it already there in the file)

<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
Copy link

Choose a reason for hiding this comment

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

General remark: not a big deal but we expect 1 empty line at the end of each file

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<odoo>

Copy link

Choose a reason for hiding this comment

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

keep your code minimal by removing useless lines

<form>
<sheet>
<h1 style="margin-bottom: 30px">
<field name="name" string="Title" placeholder="Title" />
Copy link

Choose a reason for hiding this comment

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

unless you want to specify another label than the one of the field, you don't need to specify the string.
By the way, we should always set a label for field in the model definition. (see my other comment for that)

<notebook>
<page string="Description">
<group>
<field name="description" string="Title" />
Copy link

Choose a reason for hiding this comment

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

string seems not really aligned with the field

Comment on lines 70 to 71
<field name="name" string="Title" />
<field name="postcode" string="Postcode" />
Copy link

Choose a reason for hiding this comment

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

same here for the strings

_name = "estate.property"
_description = "Real Estate property"

name = fields.Char(required=True)
Copy link

Choose a reason for hiding this comment

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

Always set the label of the field. even if it's obvious and even if the orm will generate one for you using the field name.
postcode = fields.Char("Postcode") or postcode = fields.Char(string="Postcode")
-> better the first in this case, unless string is not the first param. (typically for relational fields)

garden_area = fields.Integer()
garden_orientation = fields.Selection([("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")])
active = fields.Boolean(default=True)
state = fields.Selection([("new", "New"), ("offer received", "Offer Received"), ("offer accepted", "Offer Accepted"), ("sold", "Sold"), ("canceled", "Canceled")], required=True, copy=False, default="new")
Copy link

Choose a reason for hiding this comment

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

Suggested change
state = fields.Selection([("new", "New"), ("offer received", "Offer Received"), ("offer accepted", "Offer Accepted"), ("sold", "Sold"), ("canceled", "Canceled")], required=True, copy=False, default="new")
state = fields.Selection([
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("canceled", "Canceled")
], string="Status", required=True, copy=False, default="new")

just a matter of coding style. to gain some lines without being unreadable :)
also, don't use white spaces for the technical name of your selection options.

@Syozik Syozik force-pushed the seru-branch branch 3 times, most recently from 75338dd to bee76c5 Compare March 20, 2025 15:51
Syozik and others added 4 commits March 20, 2025 17:17
Copy link

@dbeguin dbeguin left a comment

Choose a reason for hiding this comment

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

Hello ! A review that I would do for a 'normal' task. Try to apply every comments.
it's still possible that reviewer is wrong on some comments so keep critical spirit.
I didn't reviewed the architecture of the module as you followed what the tutorial what told you to do. But this is already some point we pay attention to.
In general, keep your code clean and as simple as possible, put and do things at the right place.

enjoy :)

@@ -53,7 +53,15 @@ class Property(models.Model):

total_area = fields.Float("Total area (sqm)", compute="_compute_area")
best_price = fields.Float("Best price", compute="_compute_best_price")


Copy link

Choose a reason for hiding this comment

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

you can know remove those conflict commits

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# some not so great changes to make a first commit
Copy link

Choose a reason for hiding this comment

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

remove that

@@ -0,0 +1 @@
from . import models
Copy link

Choose a reason for hiding this comment

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

Commit message:
if you use [ADD], which is the right thing to do in this case, you already say that you add a module, so no need to make it your commit title. Explain what the module does in few words, beginning by a verb.
"[ADD] estate: handle real estate properties and salesflow"
Then in description, you can describe what features and capabilities the module have
and even list all the models used to handle the business cases. What do what and how they interact.
Basically, when reading commit message, you don't need to read the code to know how the module works. Or reading commit message will help you understand the code.
Better reading 10 lines of real words than 250 lines of code.
The goal of the commit message is mainly to help future debugging or refactoring or functionality rework, when you try to find why a certain line has been added to the code base, you read the commit message to get the context in which the commit content has been added. Knowledge is power. Better too much info than not enough :)

@@ -0,0 +1,19 @@
{
"name": "Real Estate",
"category": "Real Estate",
Copy link

Choose a reason for hiding this comment

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

missing verison and description

"views/estate_property_tag_views.xml",
"views/res_users_views.xml",
]
}
Copy link

Choose a reason for hiding this comment

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

check for all end of file missing empty lines

<field name="view_mode">list,form</field>
</record>


Copy link

Choose a reason for hiding this comment

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

remove useless line

<button class="oe_stat_button" icon="fa-money" type="action"
name="%(estate.estate_property_offer_action)d">
<div>
<field name="offer_count" string="" />
Copy link

Choose a reason for hiding this comment

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

I think what you want is nolabel="1"

<field name="facades" />
<separator />
<filter name='available' string="Available"
domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]" />
Copy link

Choose a reason for hiding this comment

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

state in

selling_price = fields.Float("Selling price", readonly=True, copy=False)
bedrooms = fields.Integer("Bedrooms", default=2)
living_area = fields.Integer("Living area (sqm)")
facades = fields.Integer("Facades")
Copy link

Choose a reason for hiding this comment

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

usually when a field is basically a counter, you postfix with '_count'
because 'facade' only is not specific enough

<field name="name">estate.property.list</field>
<field name="model">estate.property</field>
<field name='arch' type="xml">
<list string="Properties" decoration-success="state == 'offer_received' or state == 'offer_accepted'" decoration-bf = "state == 'offer_accepted'" decoration-muted="state == 'sold'">
Copy link

Choose a reason for hiding this comment

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

split on multi lines.

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