-
Notifications
You must be signed in to change notification settings - Fork 3k
[ADD] implemented new estate module #1196
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
base: 19.0
Are you sure you want to change the base?
Changes from all commits
fcf9eaa
3e41dec
9daca4f
3beeef5
764c9d8
5385020
6f729bd
42208db
427723d
c6dec2b
bb747a5
e82503f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "python.languageServer": "None" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| 'name': "Real Estate", | ||
| 'version': "0.1.0", | ||
| 'author': "keman-odoo", | ||
| 'license': "LGPL-3", | ||
| 'category': "Tutorials", | ||
| 'depends': ['base'], | ||
| 'summary': "manage properties, track buyers offers and handle property sales efficiently", | ||
| 'sequence': "3", | ||
|
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. why sequence = 3?
Author
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. 'sequence': 3 is used to control the order in which the module appears in the Apps menu. |
||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_property_type_views.xml', | ||
| 'views/estate_property_tag_views.xml', | ||
| 'views/estate_menus.xml', | ||
| 'views/estate_property_offer_views.xml' | ||
| ], | ||
| } | ||
| 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 |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,102 @@ | ||||||
| from dateutil.relativedelta import relativedelta | ||||||
|
|
||||||
| from odoo import api, fields, models | ||||||
| from odoo.exceptions import UserError | ||||||
|
|
||||||
|
|
||||||
| class EstateProperty(models.Model): | ||||||
| _name = "estate.property" | ||||||
| _description = " Real estate Property" | ||||||
|
|
||||||
| def _default_validity(self): | ||||||
|
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
We have to follow the coding guidelines. |
||||||
| return fields.Date.today() + relativedelta(months=+3) | ||||||
|
|
||||||
| @api.depends("living_area", "garden_area") | ||||||
| def _compute_total_area(self): | ||||||
| self.total_area = self.garden_area + self.living_area | ||||||
|
|
||||||
| @api.depends("offer_ids.price") | ||||||
| def _compute_best_price(self): | ||||||
| prices = self.offer_ids.mapped("price") | ||||||
| self.best_price = max(prices) if prices else 0 | ||||||
|
Comment on lines
+15
to
+21
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. It will break multiple records. |
||||||
|
|
||||||
| name = fields.Char(required=True, default="UNKNOWN") | ||||||
| description = fields.Text() | ||||||
| postcode = fields.Char() | ||||||
| date_availability = fields.Date(default=_default_validity, 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() | ||||||
| active = fields.Boolean(default=True) | ||||||
| garden_orientation = fields.Selection( | ||||||
| [ | ||||||
| ('north', 'North'), | ||||||
| ('south', 'South'), | ||||||
| ('east', 'East'), | ||||||
| ('west', 'West') | ||||||
| ], | ||||||
| string="Garden Orientation" | ||||||
| ) | ||||||
| state = fields.Selection( | ||||||
| [ | ||||||
| ('new', 'New'), | ||||||
| ('offer_received', 'Offer Received'), | ||||||
| ('offer_accepted', 'Offer Accepted'), | ||||||
| ('sold', 'Sold'), | ||||||
| ('cancelled', 'Cancelled'), | ||||||
| ], | ||||||
| default='new', | ||||||
| copy=False, | ||||||
| required=True, | ||||||
| ) | ||||||
| property_type_id = fields.Many2one( | ||||||
| "estate.property.type", | ||||||
| string="property type", | ||||||
| ) | ||||||
| buyer_id = fields.Many2one( | ||||||
| "res.partner", | ||||||
| string="Buyer", | ||||||
| ) | ||||||
| user_id = fields.Many2one( | ||||||
| "res.users", | ||||||
| string="Salesperson", | ||||||
| default=lambda self: self.env.user, | ||||||
| ) | ||||||
| tags_ids = fields.Many2many( | ||||||
| "estate.property.tag", | ||||||
| string="tags", | ||||||
| ) | ||||||
| offer_ids = fields.One2many( | ||||||
| "estate.property.offer", | ||||||
| "property_id", | ||||||
| ) | ||||||
| total_area = fields.Float(compute="_compute_total_area") | ||||||
| best_price = fields.Float(compute="_compute_best_price") | ||||||
|
|
||||||
| @api.onchange("garden") | ||||||
| def _onchange_garden(self): | ||||||
| if self.garden: | ||||||
| self.garden_area = 10 | ||||||
| self.garden_orientation = 'north' | ||||||
| else: | ||||||
| self.garden_area = 0 | ||||||
| self.garden_orientation = False | ||||||
|
|
||||||
| def action_sold(self): | ||||||
| for record in self: | ||||||
| if record.state == 'cancelled': | ||||||
| raise UserError("Cancelled property can not be sold") | ||||||
|
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. Make this error message translatable. |
||||||
| else: | ||||||
| record.state = 'sold' | ||||||
|
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 can not sell property without an accepted offer. |
||||||
|
|
||||||
| def action_cancle(self): | ||||||
| for record in self: | ||||||
| if record.state == 'sold': | ||||||
| raise UserError("Sold property can not be Cancelled") | ||||||
|
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. Make this error message translatable. |
||||||
| else: | ||||||
| record.state = 'cancelled' | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| from datetime import timedelta | ||
|
|
||
| from odoo import api, fields, models | ||
| from odoo.exceptions import UserError | ||
|
|
||
|
|
||
| class EstatePropertyOffer(models.Model): | ||
| _name = "estate.property.offer" | ||
| _description = "estate property offers" | ||
|
|
||
| @api.depends("create_date", "validity") | ||
| def _compute_date_deadline(self): | ||
| for record in self: | ||
| if record.create_date: | ||
| record.date_deadline = record.create_date + \ | ||
| timedelta(days=record.validity) | ||
| else: | ||
| record.date_deadline = fields.Date.today() + timedelta(days=record.validity) | ||
|
|
||
| def _inverse_date_deadline(self): | ||
| for record in self: | ||
| if record.create_date and record.date_deadline: | ||
| record.validity = (record.date_deadline - | ||
| record.create_date.date()).days | ||
|
Comment on lines
+11
to
+24
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. Please follow the coding guidelines. |
||
|
|
||
| price = fields.Float() | ||
| status = fields.Selection( | ||
| [ | ||
| ('accepted', 'Accepted'), | ||
| ('refused', 'Refused'), | ||
| ], | ||
| string="Status", | ||
| 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_date_deadline", | ||
| inverse="_inverse_date_deadline" | ||
| ) | ||
|
|
||
| def action_confirm(self): | ||
| for record in self: | ||
| for offer in record.property_id.offer_ids: | ||
| if offer.status == "accepted": | ||
| raise UserError("Only one offer can be acceped....") | ||
| record.status = "accepted" | ||
| record.property_id.selling_price = record.price | ||
| record.property_id.buyer_id = record.partner_id | ||
|
|
||
| def action_cancel(self): | ||
| for record in self: | ||
| if record.status == 'accepted': | ||
| record.status = "refused" | ||
| record.property_id.selling_price = False | ||
| record.property_id.buyer_id = False | ||
| else: | ||
| record.status = 'refused' | ||
| 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 = "property tag" | ||
|
|
||
| name = fields.Char(required=True) |
| 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 = "estate property" | ||
|
|
||
| name = fields.Char(required=True) |
| 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 | ||
| access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1 | ||
| access_estate_property_type,access_estate_property_type,model_estate_property_type,base.group_user,1,1,1,1 | ||
| access_estate_property_tag,access_estate_property_tag,model_estate_property_tag,base.group_user,1,1,1,1 | ||
| access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| <odoo> | ||
| <menuitem id="estate_menu_root" name="Real Estate"/> | ||
| <menuitem id="estate_advertisements_menu" | ||
| name="Advertisements" | ||
| parent="estate_menu_root"/> | ||
| <menuitem id="estate_property_menu_action" | ||
| name="Properties" | ||
| parent="estate_advertisements_menu" | ||
| action="estate_property_action"/> | ||
| <menuitem id="estate_setting_menu" | ||
| name="Settings" | ||
| parent="estate_menu_root"/> | ||
| <menuitem id="estate_property_type_menu_action" | ||
| name="property type" | ||
| parent="estate_setting_menu" | ||
| action="estate_property_type_action"/> | ||
| <menuitem id="estate_property_tag_menu_action" | ||
| name="property tag" | ||
| parent="estate_setting_menu" | ||
| action="estate_property_tag_action"/> | ||
| <menuitem id="estate_property_tag_menu_action" | ||
| name="Property Tag" | ||
| parent="estate_setting_menu" | ||
| action="estate_property_tag_action"/> | ||
|
Comment on lines
+17
to
+24
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. Why two manu? |
||
| </odoo> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?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.list</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <list> | ||
| <field name="price"/> | ||
| <field name="partner_id"/> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| <button name="action_confirm" title="Accept" type="object" icon="fa-check"/> | ||
| <button name="action_cancel" title="Refuse" type="object" icon="fa-times"/> | ||
| <field name="status"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_offer_view_form" model="ir.ui.view"> | ||
| <field name="name">estate.property.offer.form</field> | ||
| <field name="model">estate.property.offer</field> | ||
| <field name="arch" type="xml"> | ||
| <form> | ||
| <group> | ||
| <field name="partner_id"/> | ||
| <field name="price"/> | ||
| <field name="validity" /> | ||
| <field name="date_deadline" /> | ||
| </group> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_tag_action" model="ir.actions.act_window"> | ||
| <field name="name">Property Tag</field> | ||
| <field name="res_model">estate.property.tag</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <odoo> | ||
|
|
||
| <record id="estate_property_type_action" model="ir.actions.act_window"> | ||
| <field name="name">Properties type</field> | ||
| <field name="res_model">estate.property.type</field> | ||
| <field name="view_mode">list,form</field> | ||
| </record> | ||
|
|
||
| </odoo> |
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.
unneccary diff.