-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[ADD] estate: estate_property model added #1151
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
maram-odoo
wants to merge
9
commits into
odoo:19.0
Choose a base branch
from
odoo-dev:19.0-real-estate-tutorial-maram
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.
+473
−0
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ad01e4c
[IMP] estate: add security access for estate.property
maram-odoo b9fcefb
[IMP] estate: views,menu and some relational fields are added
maram-odoo f35432e
[FIX] estate: fixed python date fucnion to odoo built in function
maram-odoo ee2c502
[FIX] estate: removed unnecessary import and depends
maram-odoo e390172
[IMP] estate: some computed fields and methods introdced and styling …
maram-odoo b12a4f3
[IMP] estate: method implemented for inverse fields
maram-odoo 658f2c4
[FIX] estate: compute and inverse method fixed by using correct date …
maram-odoo d058ad4
[IMP] estate: added some buttons and their methods and introduced exc…
maram-odoo 046f6be
[IMP] estate: added some return for methods and added buyer after off…
maram-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
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 |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| # custom ignore | ||
| custom_module/ | ||
|
|
||
|
|
||
| # Byte-compiled / optimized / DLL files | ||
| __pycache__/ | ||
| *.py[cod] | ||
|
|
||
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,18 @@ | ||
| { | ||
| "name": "Estate", | ||
| "application": True, | ||
| "description": "Specific Real Estate Module", | ||
| "depends": ["base"], | ||
| "data": [ | ||
| "security/res_groups.xml", | ||
| "security/ir.model.access.csv", | ||
| "views/estate_property_views.xml", | ||
| "views/estate_property_tag_views.xml", | ||
| "views/estate_property_type_views.xml", | ||
| "views/estate_property_offer_views.xml", | ||
| "views/estate_menus.xml", | ||
| ], | ||
| "installable": True, | ||
| "author": "Maram-Odoo", | ||
| "license": "LGPL-3", | ||
| } |
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_tag | ||
| from . import estate_property_type | ||
| 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,100 @@ | ||
| from dateutil.relativedelta import relativedelta | ||
| from odoo import fields, models, api | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = "estate.property" | ||
| _description = "Estate Property Management Module" | ||
|
|
||
| name = fields.Char(string="Title", required=True) | ||
| description = fields.Text(string="Description") | ||
| postcode = fields.Char(string="Post Code") | ||
| date_availability = fields.Date( | ||
| string="Availability From", | ||
| default=lambda self: fields.Date.today() + relativedelta(months=3), | ||
| copy=False, | ||
| ) | ||
| expected_price = fields.Float(string="Expected Price", required=True) | ||
| selling_price = fields.Float(string="Selling Price", readonly=True, copy=False) | ||
| bedrooms = fields.Integer(string="Bed Rooms", default=2) | ||
| living_area = fields.Integer(string="Living Area") | ||
| facades = fields.Integer(string="Facades") | ||
| garage = fields.Boolean(string="Garage") | ||
| garden = fields.Boolean(string="Garden") | ||
| garden_area = fields.Integer(string="Garden Area") | ||
| garden_orientation = fields.Selection( | ||
| string="Garden Orientation", | ||
| selection=[ | ||
| ("north", "North"), | ||
| ("south", "South"), | ||
| ("east", "East"), | ||
| ("west", "West"), | ||
| ], | ||
| ) | ||
| state = fields.Selection( | ||
| string="Status", | ||
| default="new", | ||
| copy=False, | ||
| required=True, | ||
| selection=[ | ||
| ("new", "New"), | ||
| ("offer_received", "Offer Received"), | ||
| ("accepted", "Accepted"), | ||
| ("sold", "Sold"), | ||
| ("canceled", "Cancelled"), | ||
| ], | ||
| ) | ||
| active = fields.Boolean(string="Active", default=True) | ||
| tag_ids = fields.Many2many("estate.property.tag", string="Property Tag") | ||
| property_type_id = fields.Many2one("estate.property.type", string="Property Type") | ||
| salesman_id = fields.Many2one( | ||
| "res.users", string="Salesman", default=lambda self: self.env.uid | ||
| ) | ||
| buyer_id = fields.Many2one("res.partner", string="Buyer", copy=False) | ||
| offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers") | ||
| total_area = fields.Float(compute="_compute_total_area") | ||
| best_offer = fields.Float(compute="_compute_best_offer") | ||
|
|
||
| @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_offer(self): | ||
| for record in self: | ||
| if record.offer_ids: | ||
| prices = record.offer_ids.mapped("price") | ||
| record.best_offer = max(prices) | ||
| else: | ||
| record.best_offer = 0.0 | ||
|
|
||
| @api.onchange("garden") | ||
| def onchange_garden(self): | ||
| if self.garden: | ||
| self.garden_area = 1000 | ||
| self.garden_orientation = "north" | ||
| else: | ||
| self.garden_area = 0 | ||
| self.garden_orientation = False | ||
|
|
||
| def action_sold(self): | ||
| for record in self: | ||
| if record.state != "canceled": | ||
| record.state = "sold" | ||
| else: | ||
| raise UserError( | ||
| "You cannot move to canceled stage after sold the property" | ||
| ) | ||
| return True | ||
|
|
||
| def action_cencel(self): | ||
| for record in self: | ||
| if record.state != "sold": | ||
| record.state = "canceled" | ||
| else: | ||
| raise UserError( | ||
| "You cannot move to sold stage after cenceled the property" | ||
| ) | ||
| 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,70 @@ | ||
| from odoo import fields, models, api | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "Estate Property Offer" | ||
|
|
||
| price = fields.Float(required=True, string="Offer Price") | ||
| partner_id = fields.Many2one("res.partner", required=True, string="Partner") | ||
| property_id = fields.Many2one("estate.property", required=True, string="Property") | ||
| status = fields.Selection( | ||
| string="Status", | ||
| copy=False, | ||
| selection=[ | ||
| ("accepted", "Accepted"), | ||
| ("refuse", "Refused"), | ||
| ], | ||
| ) | ||
| date_deadline = fields.Date( | ||
| string="Deadline Date", | ||
| compute="_compute_date_deadline", | ||
| inverse="_inverse_date_deadline", | ||
| store=True, | ||
| ) | ||
| validity = fields.Integer( | ||
| string="Validity", | ||
| default=7, | ||
| store=True, | ||
| ) | ||
|
|
||
| # alternative : create_date = record.create_date.date() | ||
| @api.depends("validity") | ||
| def _compute_date_deadline(self): | ||
| for record in self: | ||
| if record.validity: | ||
| create_date = ( | ||
| fields.Date.to_date(record.create_date) or fields.Date.today() | ||
| ) | ||
| record.date_deadline = fields.Date.add( | ||
| create_date, days=record.validity | ||
| ) | ||
|
|
||
| def _inverse_date_deadline(self): | ||
| for record in self: | ||
| if record.date_deadline: | ||
| create_date = ( | ||
| fields.Date.to_date(record.create_date) or fields.Date.today() | ||
| ) | ||
| record.validity = (record.date_deadline - create_date).days | ||
|
|
||
| @api.onchange("date_deadline") | ||
| def _onchange_validity(self): | ||
| if self.date_deadline: | ||
| create_date = fields.Date.to_date(self.create_date) or fields.Date.today() | ||
| self.validity = (self.date_deadline - create_date).days | ||
|
|
||
| def action_accept_offer(self): | ||
| for record in self: | ||
| if not (record.property_id.selling_price): | ||
| record.property_id.selling_price = record.price | ||
| record.status = "accepted" | ||
| record.property_id.buyer_id = record.partner_id | ||
| else: | ||
| raise UserError("You cannot accept multiple offer") | ||
|
|
||
| def action_refuse_offer(self): | ||
| for record in self: | ||
| record.status = "refuse" | ||
| 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 fields, models | ||
|
|
||
|
|
||
| class EstatePropertyTag(models.Model): | ||
| _name = "estate.property.tag" | ||
| _description = "Estate Property Tag" | ||
|
|
||
| name = fields.Char(string="Property Tags", 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 fields, models | ||
|
|
||
|
|
||
| class EstatePropertyType(models.Model): | ||
| _name = "estate.property.type" | ||
| _description = "Estate Property Types" | ||
|
|
||
| name = fields.Char(string="Property Types", 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,7 @@ | ||
| id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
| access_estate_property,estate.property,model_estate_property,base.group_user,1,1,1,1 | ||
| access_estate_property_tag,estate.property.tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
| access_estate_property_type,estate.property.type,model_estate_property_type,base.group_user,1,1,1,1 | ||
| access_estate_property_offer,estate.property.offer,model_estate_property_offer,base.group_user,1,1,1,1 | ||
| access_estate_property_manager,estate.property manager,model_estate_property,group_estate_manager,1,1,1,1 | ||
| access_estate_property_user,estate.property user,model_estate_property,group_estate_user,1,0,1,0 |
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,12 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="group_estate_manager" model="res.groups"> | ||
| <field name="name">Estate Manager</field> | ||
| </record> | ||
|
|
||
| <record id="group_estate_user" model="res.groups"> | ||
| <field name="name">Estate User</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,31 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <menuitem id="estate_menu_root" | ||
| name="Real Estate"> | ||
|
|
||
| <menuitem id="estate_menu_advertisements" | ||
| name="Advertisement"> | ||
|
|
||
| <menuitem id="estate_menu_properties" | ||
| name="Properties" | ||
| action="estate_property_action" /> | ||
|
|
||
| </menuitem> | ||
|
|
||
| <menuitem id="estate_menu_settings" | ||
| name="Settings"> | ||
|
|
||
| <menuitem id="estate_menu_property_tags" | ||
| name="Property Tags" | ||
| action="estate_property_tag_action" /> | ||
|
|
||
| <menuitem id="estate_menu_property_types" | ||
| name="Property Types" | ||
| action="estate_property_type_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,22 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_offer_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.view.list</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <list editable="bottom"> | ||
| <field name="price" /> | ||
| <field name="partner_id" /> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| <button name="action_accept_offer" type="object" title="Accept Offer" | ||
| icon="fa-check" /> | ||
| <button name="action_refuse_offer" type="object" title="Refuse Offer" | ||
| icon="fa-times" /> | ||
| <field name="status" /> | ||
| </list> | ||
| </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,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_tag_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.view.list</field> | ||
| <field name="model">estate.property.tag</field> | ||
| <field name="arch" type="xml"> | ||
| <list> | ||
| <field name="name" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.tag.view.form</field> | ||
| <field name="model">estate.property.tag</field> | ||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <sheet> | ||
| <group> | ||
| <field name="name" /> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Estate 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,34 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_type_view_list" model="ir.ui.view"> | ||
| <field name="name">estate.property.type.view.list</field> | ||
| <field name="model">estate.property.type</field> | ||
| <field name="arch" type="xml"> | ||
| <list> | ||
| <field name="name" /> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_type_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.type.view.form</field> | ||
| <field name="model">estate.property.type</field> | ||
| <field name="arch" type="xml"> | ||
| <form string="form_view_hai"> | ||
| <sheet> | ||
| <group> | ||
| <field name="name" /> | ||
| </group> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_type_action" model="ir.actions.act_window"> | ||
| <field name="name">Estate Property Type</field> | ||
| <field name="res_model">estate.property.type</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
Oops, something went wrong.
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.
Leave one space before it for better readability.