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

[ADD] estate: add real estate module #221

Draft
wants to merge 19 commits into
base: 18.0
Choose a base branch
from

Conversation

nipl-odoo
Copy link

Create real estate module for training purposes.

Added basic models for property, property type, property tags and property offer
Also made basic views needed for proper representation of data. Right now all
base user have access of data.

Note: Right now all model views and records are there in single xml.
Finished chapter 7,8 and 9 with all features and exercise mentioned.
Business Logic
SQL constrains
Validations
Finished chapter 10 and half 11 (Uptill Attributes and options)
Added python constrains and UI improvements
upto chapter 11 and 12 half

note: I am still not able to reference new field from inherited user model
finished chapter 12

inheritance is working fine we can see real estate properties assigned to
salesperson in users tab.
removed unnecessory model access given on inherited model
Finished all chapters of server framework 101 added some of my
own ideas in kanban view. and guess what it's looking good ;)
Added demo data in estate module, checked all possibilities of demo data.
Only one problem i noticed is that we can not use the same database twice while
working with demo data because it overwrites demo data every time so states of
properties are jumbled.
Added pdf reports feature so that user can download pdf reports based on property
or salesman. Finised build pdf reports module.
Fixed offer action button bug. I was unable to access Many2One fiend in view.
So i made an related field in offer model to make sure accept and reject buttons
are disappeared whenever property goes into offer_Accepted state.
Added ACL so that all users can not access all properties. Also restricted
access of agents to see other agent's property. Also bypassed marking property
sold by agents. (But only if current user has write access on estate property)
Added feature to view property based on company selected. Visibility of
companies is limited to manager only. Agent can only see information in
his/her company only.

Also added wizard for creating bulk offer on selected properties.
Fixed bug while creating bulk offer when one of the property throws validation
error. Also added properties on website through controller. Pagination is still
remaining.
Corrected incorrectly working pager and property details page where
user can see details of property whose state is new, offer_received or
offer_accepted. Also users can not see archived properties.

Finished all the python training given by our mentor.
@robodoo
Copy link

robodoo commented Jan 16, 2025

Pull request status dashboard

@nipl-odoo nipl-odoo force-pushed the 18.0-training-nipl branch 2 times, most recently from 5a0e7fa to 9691a9b Compare January 16, 2025 06:13
Copy link

@adsh-odoo adsh-odoo left a comment

Choose a reason for hiding this comment

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

Hello @nipl-odoo
Some comments/suggestions
I can also see some extra blank lines remove them also.
Thanks!!

@http.route(
["/properties", "/properties/page/<int:page>"],
type="http",
auth="user",

Choose a reason for hiding this comment

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

we can use auth="public" here

Comment on lines 141 to 143
"context": {
"default_property_ids": self.ids,
},

Choose a reason for hiding this comment

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

it will not be needed we can get the selected property by self.env.context.get('active_ids')

Comment on lines 11 to 13
_sql_constraints = [
("name_uniq", "unique(name)", "Type must be unique"),
]

Choose a reason for hiding this comment

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

we write constraints after field definition

<field name="name">Estate Manager rules for all properties</field>
<field name="model_id" ref="estate.model_estate_property"/>
<field name="groups" eval="[Command.link(ref('estate.estate_group_manager'))]" />
<field name="domain_force">[]</field>

Choose a reason for hiding this comment

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

Suggested change
<field name="domain_force">[]</field>
<field name="domain_force">[(1, '=', 1)]</field>

<h1>
<field name="name" label="Property Name" placeholder="Property Name" />
</h1>
<field name="image" widget="image" options="{'size': [150, 150]}"/>

Choose a reason for hiding this comment

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

Generally, we put the image in the right side of the sheet

"website": "https://www.odoo.com",
"category": "Tutorials/Estate_Account",
"version": "0.1",
"application": True,

Choose a reason for hiding this comment

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

it's bridge module so we can remove the application true here.

_name = "estate.property.make.offer"
_description = "Estate Property Make Offer Wizard"

property_ids = fields.Many2many("estate.property", string="Properties")

Choose a reason for hiding this comment

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

I think there is no need to link this wizard with estate property

Comment on lines 14 to 37
failed_properties = []
for property in self.property_ids:
try:
self.env["estate.property.offer"].create(
{
"price": self.offer_price,
"property_id": property.id,
"partner_id": self.partner_id.id,
"validity": self.offer_validity,
}
)
except Exception:
failed_properties.append(property.name)
if failed_properties:
return {
"type": "ir.actions.client",
"tag": "display_notification",
"params": {
"message": "Failed to create offers for the following properties: "
+ ", ".join(failed_properties),
"type": "danger",
"next": {"type": "ir.actions.act_window_close"},
},
}

Choose a reason for hiding this comment

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

we can simplify this by taking the property_ids from context (from my previous comment) and creating offer directly inside them Let me know what you think.
Can you give it a try?

Comment on lines 1 to 4
from odoo import models, fields, api
from odoo.exceptions import UserError
from datetime import datetime
from dateutil.relativedelta import relativedelta

Choose a reason for hiding this comment

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

Suggested change
from odoo import models, fields, api
from odoo.exceptions import UserError
from datetime import datetime
from dateutil.relativedelta import relativedelta
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
from odoo.exceptions import UserError

Generally we first make external imports and then we import from odoo in alphabetical order.
Need to adapt in all files

Refactored code according to common coding guidelines followed here.
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