Skip to content

[ADD] estate: create real estate module #783

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 15 commits into
base: 18.0
Choose a base branch
from

Conversation

clom-odoo
Copy link

Creation of a module for real estate.
There should be more description however it's work in progress

@robodoo
Copy link

robodoo commented May 19, 2025

Pull request status dashboard

@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 4b7b110 to 821971f Compare May 19, 2025 14:59
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 821971f to 3e0c64e Compare May 19, 2025 15:27
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 3e0c64e to 6181942 Compare May 20, 2025 08:41
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch 2 times, most recently from b357377 to 88c49fd Compare May 21, 2025 08:06
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch 3 times, most recently from f3aee3d to be3fe3d Compare May 21, 2025 13:24
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from be3fe3d to 5d8670f Compare May 21, 2025 14:55
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 5d8670f to 3d66c40 Compare May 21, 2025 15:18
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from ea014ea to 4bddac7 Compare May 23, 2025 07:15
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 77e21d7 to 4bc26bc Compare May 23, 2025 12:39
clom-odoo added 2 commits May 23, 2025 14:41
…ideline and clear some typos

This commit will refactor estate_property in estate.property as recommended. Some file name especially those who deals with inhertiance are changed accoridng to the guideline.
Copy link

@ushyme ushyme 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 overall. One general remark: There are inconsistencies with the use of single/double quotes. We generally use different quote signs to distinguishes between technical strings (single quotes) and user-facing strings (double quotes).

date_availability = fields.Date(
"Date availability",
copy=False,
default=fields.Date.today() + relativedelta(months=3))
Copy link

Choose a reason for hiding this comment

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

Suggested change
default=fields.Date.today() + relativedelta(months=3))
default=lambda: fields.Date.today() + relativedelta(months=3))

As it is now, fields.Date.today() + relativedelta(months=3) is evaluated once when the class is loaded, not each time a record is created. Use a function returning the value so it's evaluated on each record creation.

estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
Copy link

Choose a reason for hiding this comment

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

Suggested change
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1

Remember to leave an empty line at the end of files. While it seems trivial, it ensures compatibility with many tools and version control systems.

<menuitem id="estate_tag_menu_action" action="estate_property_tag_action"/>
</menuitem>
</menuitem>
</odoo>
Copy link

Choose a reason for hiding this comment

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

Suggested change
</odoo>
</odoo>

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

Suggested change
</odoo>
</odoo>

Comment on lines 17 to 20
date_availability = fields.Date(
"Date availability",
copy=False,
default=fields.Date.today() + relativedelta(months=3))
Copy link

Choose a reason for hiding this comment

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

Suggested change
date_availability = fields.Date(
"Date availability",
copy=False,
default=fields.Date.today() + relativedelta(months=3))
date_availability = fields.Date(
"Date availability",
copy=False,
default=lambda: fields.Date.today() + relativedelta(months=3))

As it is now, fields.Date.today() + relativedelta(months=3) is evaluated once when the class is loaded, not each time a record is created. Use a function returning the value so it’s evaluated on each record creation.

<field name="name">estate.property.tag.form</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<form string="Property">
Copy link

Choose a reason for hiding this comment

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

Suggested change
<form string="Property">
<form string="Property Tag">

<field name="name">estate.property.offer.form</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<form string="Property">
Copy link

Choose a reason for hiding this comment

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

Suggested change
<form string="Property">
<form string="Property Offer">

res = super().action_sold()
self.env['account.move'].create({
"move_type": 'out_invoice',
"partner_id": self.buyer.id,
Copy link

Choose a reason for hiding this comment

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

What if the self.buyer doesn't exist ?

Copy link
Author

Choose a reason for hiding this comment

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

As buyer is a many2one field it gets a blank template by default. Therefore there is a field buyer.id with the value False which is interpreted as no buyer.

So when there is no buyer, this will create an invoice with no Customer

Comment on lines 44 to 51
<!--
<div class="o_field_widget o_stat_info">
<span class="o_stat_value d-flex gap-1">
<field name="offer_count" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="name" class="oe_inline"/>
</span>
</div>
-->
Copy link

Choose a reason for hiding this comment

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

Suggested change
<!--
<div class="o_field_widget o_stat_info">
<span class="o_stat_value d-flex gap-1">
<field name="offer_count" widget="statinfo" nolabel="1" class="oe_inline"/>
<field name="name" class="oe_inline"/>
</span>
</div>
-->

In general, we try to use comments to add context to the code. This doesn't seem to add much.

Copy link
Author

Choose a reason for hiding this comment

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

I forgot to uncomment it after debugging

<field string="Bedrooms" name="bedrooms"/>
<field string="Living Area (sqm)" name="living_area" filter_domain="[('living_area', '&gt;', self)]"/>
<field string="Facades" name="facades"/>
<filter string="Available" name="state_availability_filter" 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.

Domains have a in operator

…the review

Add a lambda fonction to the default field computing a date based on fields.Date.today method.

Add a line at the end of file for files where it was missing.

Adapted the create method of the EstatePropertyOffer to match the api.model_create_multi decorator.

Add a call to the self.env._ method at each UserError callto export them for translation.

Updated class name according to the guideline to match their model name in CamelCase format.

Updated 'offer received' and 'offer accepted' to snake_case formatting.

Updated misleading _sql_constraints name and error from estate_property_type.

Switch to default return value instead of a workaround for max method in estate/models/estate_property.py .

Updated action_confirm to:
1) right algorithm
2) better readability using write and filtered method

Corrected some string field in xml.

Uncommented the core of a stat_button that was only displaying 'test'.
@clom-odoo clom-odoo force-pushed the 18.0-tutorial-clom branch from 6a68bec to 7d4bb56 Compare May 27, 2025 13:20
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