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: added new real estate module #108

Draft
wants to merge 15 commits into
base: 17.0
Choose a base branch
from

Conversation

krku-odoo
Copy link

Training adding the estate module

Creating new module:
-model: estate.property with fields such as name bedrooms,living_area,facades,state
-views: Tree and Form views of estate properties.
-security: Access Right define in ir.model.access.csv file.
@krku-odoo krku-odoo force-pushed the 17.0-training-krku branch 2 times, most recently from f7ddd46 to 7527972 Compare August 7, 2024 09:20
The new module includes :
-Includes relationship between model
-Creating many_to_one relations in estate.property.type model
-Creating many_to_many relations in estate.property.tag model
-Creating one_to many relations in estate.property.offer model
Button & Action
-Creating two button cancelled and sold
-Initialize action for  both the buttons
-Added functionality cancelled property can not be sold and and sold property
can not be cancelled
-Created two button for offer accepted and refused through the icon and added
functionality on it, if click on refused icon then my offer status is refused
and click on accepted icon status will accepted.
End here chapter 9

Sql constraints & Python constrains
-Added functionality for expected price,offer price and selling price must be
positive and property_tag_name and property_type_name must be unique
through the _sql_constraints and using of unique keyword
-Add a constraint so that the selling price cannot be lower than 90% of the
expected price using of python_constrains and showing error using of
ValidationError .
@krku-odoo krku-odoo force-pushed the 17.0-training-krku branch 3 times, most recently from 59ff321 to 5c399ff Compare August 12, 2024 11:32
-Add the property type form view and showing all the property of this type
-Using of widgets creating statusbar to display state of the property
-Creating a record to view "estate.property" to Descending ID
-Creating a record to view "estate.property.offer" to Descending price
-Add the sequence
-Creating conditional display of buttons and fields
-Add tag colors
-Creating garden_area and orientation invisible
-Adding colour to accept and refuse button
-Creating offer is readonly when offer in sold,accept,cancel state
-Create the estate.property.offer and estate.property.tag list views editable.
-Create  the field date_availability on the estate.property list view optional
and hidden by default.
-Adding available filter by-default
-Add a filter_domain to the living area to include properties with an area equal
to or greater than the given value.
-Add state button for property type offer
…t model

Add business logic and view inheritance for real estate module

- Prevent deletion of properties not in 'New' or 'Canceled' state using
`ondelete`.
- Set property state to 'Offer Received' on
 offer creation and prevent creating offers with lower amounts than existing
ones.
- Add `property_ids` field to `res.users` model to list salesperson’s available
 properties.
- Extend `base.view_users_form` to display `property_ids` in a new notebook
page.
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 @krku-odoo

I have added a few remarks and a couple of suggestions.
Can you please have a look?

Thanks!!

else:
record.best_offer = 0.0

_sql_constraints = [

Choose a reason for hiding this comment

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

Generally, we define SQL constraints just after the field declarations.

Comment on lines 1 to 2
from odoo import api, models, fields
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 api, models, fields
from dateutil.relativedelta import relativedelta
from dateutil.relativedelta import relativedelta
from odoo import api, fields, model

We follows a convention in which we first import the external libraries and then imports from odoo in alphabetically order.

Comment on lines 42 to 50
if record.property_id.create_date and record.deadline_date:
flag = fields.Date.from_string(record.deadline_date)
flag1 = fields.Date.from_string(record.property_id.create_date)
if flag and flag1:
record.validity = (flag - flag1).days
else:
record.validity = 7
else:
record.validity = 7

Choose a reason for hiding this comment

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

Suggested change
if record.property_id.create_date and record.deadline_date:
flag = fields.Date.from_string(record.deadline_date)
flag1 = fields.Date.from_string(record.property_id.create_date)
if flag and flag1:
record.validity = (flag - flag1).days
else:
record.validity = 7
else:
record.validity = 7
record.validity = (record.deadline_date - record.property_id.create_date.date()).days

I think we can simplify it But make sure to check all the cases working fine.

</record>

</data>
</odoo>

Choose a reason for hiding this comment

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

Need a blank line at EOF check for other files as well

Comment on lines +33 to +38
if record.property_id.create_date:
record.deadline_date = record.property_id.create_date + relativedelta(
days=record.validity
)
else:
record.deadline_date = False

Choose a reason for hiding this comment

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

Suggested change
if record.property_id.create_date:
record.deadline_date = record.property_id.create_date + relativedelta(
days=record.validity
)
else:
record.deadline_date = False
record.deadline_date = record.property_id.create_date + relativedelta(
days=record.validity
)

Comment on lines 64 to 65
property_id = vals.get("property_id")
property_users = self.env["estate_property"].browse(property_id)

Choose a reason for hiding this comment

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

Suggested change
property_id = vals.get("property_id")
property_users = self.env["estate_property"].browse(property_id)
property = self.env["estate_property"].browse(vals.get("property_id"))

Comment on lines 7 to 12
<field name="view_mode">
tree,form
</field>
<field name="___domain">
[('property_type_id', '=', active_id)]
</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="view_mode">
tree,form
</field>
<field name="___domain">
[('property_type_id', '=', active_id)]
</field>
<field name="view_mode">tree,form</field>
<field name="___domain">[('property_type_id', '=', active_id)]</field>

Check in other files also

Comment on lines +36 to +41
<button type="action" name="%(estate.estate_property_offer_action)d" string="Offers" class="oe_stat_button" icon="fa-ticket">
<div class="o_stat_info">
<field name="offer_count" widget="statinfo" string="" />
<span class="o_stat_text">Offer</span>
</div>
</button>
Copy link

@adsh-odoo adsh-odoo Aug 13, 2024

Choose a reason for hiding this comment

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

Suggested change
<button type="action" name="%(estate.estate_property_offer_action)d" string="Offers" class="oe_stat_button" icon="fa-ticket">
<div class="o_stat_info">
<field name="offer_count" widget="statinfo" string="" />
<span class="o_stat_text">Offer</span>
</div>
</button>
<div name="button_box">
<button class="oe_stat_button" type="action" name="%(estate.estate_property_offer_action)d"
icon="fa-ticket">
<field string="Offers" name="offer_count" widget="statinfo"/>
</button>
</div>

we can do something like this to properly format the stat button.



class MyModel(models.Model):
_name = "estate_property"

Choose a reason for hiding this comment

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

Suggested change
_name = "estate_property"
_name = "estate.property"

Modify the model name as per the convention.

feat(estate_account): Implement invoice creation on property sale

- Created `estate_account` module, dependent on `estate` and `account` modules.
- Added logic in `estate.property` model to generate a customer invoice when a
property is marked as 'Sold'.
- The invoice includes:
  - A line charging 6% of the property's selling price.
  - A line charging an additional .00 as administrative fees.
Completed chapter till Chapter-13
Add minimal Kanban view for properties in real estate module

- Created a basic Kanban view displaying property names.
- Improved the view to conditionally show 'best price' and 'selling price' based
on offer status.
- Added fields: expected price, best price, selling price, and tags.
- Grouped properties by type by default and disabled drag-and-drop functionality.
- Added master data for standard Real Estate Property Types: Residential,
Commercial, Industrial, and Land.
- Added demo data for the estate module, including properties like Big Villa
and Trailer Home
- Created demo data for offers linked to demo properties using existing
partners.
- Ensured that demo properties have their Property Type set to Residential.
- Added date handling for demo offers to be relative to the module installation
date.
- Utilized `Command` methods to create offers directly within the One2many field
of a new property.
- Implemented data extension examples for XML-based record updates.
- Implemented a property offers PDF report using QWeb templates.
- Created `estate_property_templates.xml` to define the report template for
displaying property offers.
- Added `estate_property_reports.xml` for the ir.actions.report to include the
report in the module's business logic.
- Enhanced the report by adding logic to conditionally handle cases with no
offers using `t-if` and `t-else`.
- Introduced a sub-template to separate the table portion of the offers,
promoting code reuse.
- Created a new report for `res.users` to list all the Real Estate Properties
for a salesperson, including property offers.
- Extended the property report in the `estate_account` module to include invoice
 information for sold properties using QWeb inheritance.

Files Added:
- `estate/report/estate_property_templates.xml`
- `estate/report/estate_property_reports.xml`
- Updated `__manifest__.py` to include the new report files in the module's data
list.
*Add 'Properties' menu to list available properties with images and
pagination on website  using of controller.

- Created a 'Properties' menu on the website to display available properties in
 a grid.
- Added image support for properties and displayed them on the front end.
- Implemented pagination to display a maximum of 6 properties per page.
- Created a dedicated, responsive property detail page using Bootstrap.

*Add 'Add Offer' wizard to Real Estate module for bulk offer creation

- Added 'Add Offer' button to the estate property tree view header.
- Implemented wizard for selecting multiple properties to make an offer.
- Wizard includes fields for price, validity, and buyer details.
- Added 'Make an Offer' and 'Cancel' buttons to handle business logic and
cancellation.

*Implement security restrictions for Real Estate module

- Created security.xml file to define security groups and access rights.
- Added Real Estate Agent and Manager groups with appropriate access levels.
- Set access rights: full access for Managers, limited access for Agents, and r
estricted access for non-agents.
- Defined record rules to restrict access to properties based on the agent
assigned.
- Implemented bypass for invoice creation security checks in estate_account
 module using `sudo()`.
- Added company-based record rules for multi-company security management.
- Restricted Settings menu visibility to Managers only.
- Created different models for this: dental.patients, dental.allergies,
  dental.habits, dental.chronic.condition, dental.medical.aids,
  dental.medication
- Created appropriate views file for all of the models
- Added security file: ir.model.access.csv
- ADD the invoice
- Visible on Website
- Create form view for patient
-Create customer history
-Create Controller
-Show the the list of patient
-Redirect medical aid and personal and medical history to the  form view of these
-Create breadcrumb to all the route
-Create form view for Medical Aid and Personal
-Create list view for Medical History and  Dental History
-Create form view of each Dental History
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.

2 participants