-
Notifications
You must be signed in to change notification settings - Fork 2.8k
19.0 estate tutorial shsak #1047
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
Draft
shsak-odoo
wants to merge
8
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-estate-tutorial-shsak
base: 19.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b97bbe1
[ADD] estate: added init file and manifest file to make it a module
shsak-odoo 3c98f61
[IMP] estate: Create estate property model with more field set
shsak-odoo 9a90538
[IMP] estate: Grant base users full access to estate property by sec…
shsak-odoo 5a8d5d3
[IMP] estate: Added menus, actions, and views for the UI
shsak-odoo b31e223
[IMP] estate: Added form, search, filters, groups views
shsak-odoo 502ebb0
[IMP] estate: Implement relations between modules
shsak-odoo 859c071
[IMP] estate: Add compute fields and onchanges for offer and garden
shsak-odoo d46ed71
[IMP] estate: Added Action button in Property and Offer Model
shsak-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| 'name': 'Real Estate', | ||
| 'version': '1.0', | ||
| 'depends': ['base'], | ||
| 'author': 'Shivam Saksham(shsak)', | ||
| 'category': 'Sales', | ||
| 'description': """ | ||
| An Real Estate App to buy, sell, and rent properties. | ||
| """, | ||
| 'application': True, | ||
| 'license': 'LGPL-3', | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/estate_property_offer_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_menus.xml', | ||
| ], | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| from . import estate_property | ||
| from . import estate_property_type | ||
| from . import estate_property_tag | ||
| from . import estate_property_offer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| from odoo import models, fields, api, exceptions | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate_property' | ||
| _description = 'Estate Property details' | ||
|
|
||
| name = fields.Char(required=True) | ||
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_availability = fields.Date( | ||
| default=lambda self: fields.Date.add(fields.Date.today(), months=3), | ||
| copy=False | ||
| ) | ||
| expected_price = fields.Float(required=True) | ||
| selling_price = fields.Float(readonly=True, copy=False) | ||
| bedrooms = fields.Integer(default=2) | ||
| living_area = fields.Integer() | ||
| facades = fields.Integer() | ||
| garage = fields.Boolean() | ||
| garden = fields.Boolean() | ||
| garden_area = fields.Integer() | ||
| garden_orientation = fields.Selection( | ||
| string='Garden Orientation', | ||
| selection=[('north', 'North'), ('south', 'South'), ('east', 'East'), ('west', 'West')] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have to follow the same quote in the same file. |
||
| ) | ||
| state = fields.Selection( | ||
| string='Status', | ||
| selection=[('new', 'New'), ('offer_received', 'Offer Received'), ('offer_accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')], | ||
| default='new', | ||
| required=True, | ||
| copy=False | ||
| ) | ||
| active = fields.Boolean(default=True) | ||
| property_type_id = fields.Many2one('estate.property.type', string='Type') | ||
| buyer = fields.Many2one('res.partner', copy=False) | ||
| salesperson = fields.Many2one('res.users', string='Salesman', default=lambda self: self.env.user) | ||
| tag_ids = fields.Many2many('estate.property.tag', string='Tag') | ||
| offer_ids = fields.One2many('estate.property.offer', 'property_id') | ||
| total_area = fields.Integer(compute='_compute_total_area') | ||
| best_price = fields.Float(compute='_compute_best_price') | ||
|
|
||
| @api.depends('living_area', 'garden_area') | ||
| def _compute_total_area(self): | ||
| for record in self: | ||
| record.total_area = record.living_area + record.garden_area | ||
|
|
||
| @api.depends('offer_ids.price') | ||
| def _compute_best_price(self): | ||
| for record in self: | ||
| record.best_price = max(record.offer_ids.mapped('price') or [0]) | ||
|
|
||
| @api.onchange('garden') | ||
| def _onchange_garden(self): | ||
| if self.garden: | ||
| self.garden_orientation = 'north' | ||
| self.garden_area = 10 | ||
| else: | ||
| self.garden_orientation = None | ||
| self.garden_area = 0 | ||
|
|
||
| def cancel_property_sale(self): | ||
| for record in self: | ||
| if record.state == 'sold': | ||
| raise exceptions.UserError('A sold property cannot be cancelled') | ||
| else: | ||
| record.state = 'cancelled' | ||
| return True | ||
|
|
||
| def set_property_sold(self): | ||
| for record in self: | ||
| if record.state == 'cancelled': | ||
| raise exceptions.UserError('A cancelled property cannot be Sold') | ||
| else: | ||
| record.state = 'sold' | ||
| return True | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from odoo import models, fields, api, exceptions | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = 'estate.property.offer' | ||
| _description = 'Offer to buy the property' | ||
|
|
||
| price = fields.Float() | ||
| status = fields.Selection( | ||
| string='Status', | ||
| selection=[('accepted', 'Accepted'), ('refused', 'Refused')], | ||
| copy=False, | ||
| ) | ||
| partner_id = fields.Many2one('res.partner', required=True) | ||
| property_id = fields.Many2one('estate_property', required=True) | ||
| validity = fields.Integer(default=7) | ||
| date_deadline = fields.Date(compute='_compute_offer_date_deadline', inverse='_inverse_offer_date_deadline') | ||
|
|
||
| @api.depends('create_date', 'validity') | ||
| def _compute_offer_date_deadline(self): | ||
| for record in self: | ||
| if record.create_date: | ||
| record.date_deadline = fields.Date.add(record.create_date.date(), days=record.validity) | ||
| else: | ||
| record.date_deadline = fields.Date.add(fields.Date.today(), days=record.validity) | ||
|
|
||
| def _inverse_offer_date_deadline(self): | ||
| for record in self: | ||
| record.validity = (record.date_deadline - record.create_date.date()).days | ||
|
|
||
| def action_offer_accepted(self): | ||
| for record in self: | ||
| if record.status == 'accepted': | ||
| return False | ||
| if record.property_id.buyer: | ||
| raise exceptions.UserError('An another offer is already accepted') | ||
| record.property_id.selling_price = record.price | ||
| record.property_id.buyer = record.partner_id | ||
| record.status = 'accepted' | ||
| return True | ||
|
|
||
| def action_offer_refused(self): | ||
| for record in self: | ||
| record.status = 'refused' | ||
| return True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = "estate.property.tag" | ||
| _description = "Tag for the property" | ||
|
|
||
| name = fields.Char(required=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from odoo import models, fields | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = "estate.property.type" | ||
| _description = "Defines the type of Real Estate Property" | ||
|
|
||
| name = fields.Char(required=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| id,name,model_id/id,group_id/id,perm_read,perm_write,perm_create,perm_unlink | ||
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||
| <odoo> | ||||||||
| <menuitem id="estate_menu_root" name="Real Estate"> | ||||||||
| <menuitem id="estate_first_level_menu" name="Advertisement"> | ||||||||
| <menuitem id="estate_property_model_menu_action" action="estate_property_action" /> | ||||||||
| </menuitem> | ||||||||
|
|
||||||||
| <menuitem id="estate_first_level_setting_menu" name="Settings"> | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
For better visibility. |
||||||||
| <menuitem id="estate_property_type_model_menu_action" | ||||||||
| action="estate_property_type_action" /> | ||||||||
| <menuitem id="estate_property_tag_model_menu_action" | ||||||||
| action="estate_property_tag_action" /> | ||||||||
| </menuitem> | ||||||||
| </menuitem> | ||||||||
| </odoo> | ||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <odoo> | ||
| <record id="estate_property_offer_list_view" model="ir.ui.view"> | ||
| <field name="name">estate_property_offer_form</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="Offers"> | ||
| <field name="price" /> | ||
| <field name="partner_id" string="Partner" /> | ||
| <field name="validity" string="Validity (days)" /> | ||
| <field name="date_deadline" /> | ||
| <button name="action_offer_accepted" string="Accept" type="object" icon="fa-check"/> | ||
| <button name="action_offer_refused" string="Refuse" type="object" icon="fa-close" /> | ||
| <field name="status" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_form_view" model="ir.ui.view"> | ||
| <field name="name">Property Offer List</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Offer"> | ||
| <sheet> | ||
| <group> | ||
| <field name="price" /> | ||
| <field name="partner_id" string="Partener" /> | ||
| <field name="validity" string="Validity (days)" /> | ||
| <field name="date_deadline" /> | ||
| <field name="status" /> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <odoo> | ||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Tags</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <odoo> | ||
| <record id="estate_property_type_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Types</field> | ||
| <field name="res_model">estate.property.type</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| </odoo> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| <odoo> | ||
| <record id="estate_property_form_view" model="ir.ui.view"> | ||
| <field name="name">estate_property_form</field> | ||
| <field name="model">estate_property</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="Description"> | ||
| <haeder> | ||
| <group col="2"> | ||
| <button type="object" name="cancel_property_sale" string="Cancel" /> | ||
| <button type="object" name="set_property_sold" string="Sold" /> | ||
| </group> | ||
| </haeder> | ||
| <sheet> | ||
| <h1> | ||
| <field name="name" nolabel="True" /> | ||
| </h1> | ||
| <field name="tag_ids" widget="many2many_tags" class="mb-5" /> | ||
| <group> | ||
| <group> | ||
| <field name="property_type_id" string="Property Type" /> | ||
| <field name="postcode" /> | ||
| <field name="date_availability" string="Available From" /> | ||
| </group> | ||
| <group> | ||
| <field name="expected_price" /> | ||
| <field name="selling_price" /> | ||
| <field name="best_price" /> | ||
| </group> | ||
| </group> | ||
| <notebook> | ||
| <page string="Description"> | ||
| <group col="2"> | ||
| <field name="description" /> | ||
| <field name="bedrooms" /> | ||
| <field name="living_area" string="Living Area (sqm)" /> | ||
| <field name="facades" /> | ||
| <field name="garage" /> | ||
| <field name="garden" /> | ||
| <field name="garden_area" string="Garden Area (sqm)" /> | ||
| <field name="garden_orientation" /> | ||
| <field name="state" /> | ||
| <field name="total_area" /> | ||
| </group> | ||
| </page> | ||
| <page string="Offers"> | ||
| <list> | ||
| <field name="offer_ids" widget="one2many_list" /> | ||
| </list> | ||
| </page> | ||
| <page string="Other Info"> | ||
| <group> | ||
| <field name="salesperson" /> | ||
| <field name="buyer" /> | ||
| </group> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_list_view" model="ir.ui.view"> | ||
| <field name="name">Properties List</field> | ||
| <field name="model">estate_property</field> | ||
| <field name="arch" type="xml"> | ||
| <list string="Properties"> | ||
| <field name="name" string="Title" /> | ||
| <field name="postcode" /> | ||
| <field name="property_type_id" /> | ||
| <field name="bedrooms" /> | ||
| <field name="living_area" string="Living Area (sqm)" /> | ||
| <field name="expected_price" /> | ||
| <field name="selling_price" /> | ||
| <field name="date_availability" string="Available From" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_search_options_view" model="ir.ui.view"> | ||
| <field name="name">Properties Search</field> | ||
| <field name="model">estate_property</field> | ||
| <field name="arch" type="xml"> | ||
| <search string="Property Search"> | ||
| <field name="name" string="Title" /> | ||
| <field name="postcode" /> | ||
| <field name="expected_price" /> | ||
| <field name="bedrooms" /> | ||
| <field name="living_area" string="Living Area (sqm)" /> | ||
| <field name="facades" /> | ||
| <field name="property_type_id" string="Type" /> | ||
| <filter name="available" string="Available" | ||
| domain="['|', ('state', '=', 'new'), ('state', '=', 'offer_received')]" /> | ||
| <filter name="group_by_postcode" string="Postcode" context="{'group_by':'postcode'}" /> | ||
| </search> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_action" model="ir.actions.act_window"> | ||
| <field name="name">Properties</field> | ||
| <field name="res_model">estate_property</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
| </odoo> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please follow the same quote in the same file?