-
Notifications
You must be signed in to change notification settings - Fork 3k
[ADD] estate: add real estate advertisement module #1220
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
dbeabf0
428b78f
43182a5
7f5cfad
16ae220
26f577d
fcf5279
41105af
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 @@ | ||
| from . import models |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| 'name': 'Estate', | ||
| 'version': '1.1', | ||
| 'category': 'Tutorials', | ||
| 'summary': 'The Real Estate Advertisement module', | ||
| 'description': 'Try installing the App', | ||
| 'depends': ['base'], | ||
| 'application': True, | ||
| 'installable': True, | ||
| 'author': 'times', | ||
| 'website': 'https://www.odoo.com/app/estate', | ||
| 'license': 'LGPL-3', | ||
| 'data': [ | ||
| 'security/ir.model.access.csv', | ||
| 'views/estate_property_views.xml', | ||
| 'views/estate_menus.xml', | ||
| ], | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| from . import estate_property |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| from odoo import fields, models | ||
|
|
||
|
|
||
| class EstateProperty(models.Model): | ||
| _name = 'estate.property' | ||
| _description = "estate property used to buy and sell houses" | ||
|
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. Where is this description displayed?
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. Its the model’s informal name. You can see that displayed in Setting > Technical > Database Structure > Models > Description(column) |
||
| _log_access = False | ||
|
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. What is
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. _log_access(bool) is used to decide whether create the automatic(access log fields: create_uid, create_date, write_uid, write_date) fields or not. |
||
|
|
||
| name = fields.Char(required=True) | ||
| description = fields.Text() | ||
| postcode = fields.Char() | ||
| date_availability = fields.Date( | ||
| default=lambda self: fields.Date.add(fields.Date.context_today(self), months=3), | ||
| copy=False | ||
| ) | ||
| expected_price = fields.Float(required=True) | ||
| selling_price = fields.Float(readonly=True, copy=False) | ||
|
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. What does
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. it prevents the field value to be copied over to the new record while duplicated |
||
| 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( | ||
| selection=[ | ||
| ('north', "North"), | ||
| ('south', "South"), | ||
| ('east', "East"), | ||
| ('west', "West"), | ||
| ], | ||
| ) | ||
| active = fields.Boolean(default=True) | ||
| state = fields.Selection( | ||
| selection=[ | ||
| ('new', "New"), | ||
| ('offer_received', "Offer Received"), | ||
| ('offer_accepted', "Offer Accepted"), | ||
| ('sold', "Sold"), | ||
| ('cancelled', "Cancelled"), | ||
| ], | ||
| default='new', | ||
| copy=False, | ||
| required=True, | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 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 | ||
|
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. Can you explain me what happens when you write this line?
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. it creates a row in the ir_model_access table . what it does : it gives internal users( base.group_user ) access to estate property model with read, write, create and delete permissions |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <?xml version="1.0" encoding="UTF-8" ?> | ||
| <odoo> | ||
| <menuitem id="estate_root_menu" name="Real Estate" web_icon="estate,static/description/icon.png"> | ||
|
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. Does this web icon show in the UI?
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. |
||
| <menuitem id="estate_first_level_menu" name="Advertisements"> | ||
| <menuitem id="estate_property_menu_action" name="Properties" action="estate_property_action"/> | ||
| </menuitem> | ||
| </menuitem> | ||
| </odoo> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| <?xml version='1.0' encoding='UTF-8'?> | ||
| <odoo> | ||
| <record id="estate_property_view_list" model="ir.ui.view"> | ||
| <field name='name'>estate.property.list</field> | ||
| <field name='model'>estate.property</field> | ||
| <field name='arch' type='xml'> | ||
| <list> | ||
| <field name='name' string="Title"/> | ||
| <field name='postcode'/> | ||
| <field name='bedrooms' width="200px"/> | ||
| <field name='living_area' string="Living Area (sqm)" width="200px"/> | ||
| <field name='expected_price' width="200px"/> | ||
| <field name='selling_price' width="200px"/> | ||
| <field name='date_availability' string="Available From" width="200px"/> | ||
| </list> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id='estate_property_view_form' model='ir.ui.view'> | ||
| <field name='name'>estate.property.form</field> | ||
| <field name='model'>estate.property</field> | ||
| <field name='arch' type='xml'> | ||
| <form> | ||
| <sheet> | ||
| <div class="oe_title mb16"> | ||
| <h1> | ||
| <label for="name" string="Property Name"/> | ||
| <field name='name' placeholder="Flat no 1"/> | ||
| </h1> | ||
| </div> | ||
| <group col='2'> | ||
| <group> | ||
| <field name='postcode'/> | ||
| <field name='date_availability' string='Available From'/> | ||
|
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. When do we use view level string and field level string?
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. We use the field-level string in model python file(estate_property.py) to set the global default label for the field. We use the view-level string in xml views (as seen on line 34 for date_availability) when we need to override that default for a specific view to provide better context to the user without changing the model's core definition. |
||
| </group> | ||
| <group> | ||
| <field name='expected_price'/> | ||
| <field name='selling_price'/> | ||
| </group> | ||
| </group> | ||
| <notebook> | ||
| <page string='Description'> | ||
| <group> | ||
| <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'/> | ||
| </group> | ||
| </page> | ||
| </notebook> | ||
| </sheet> | ||
| </form> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id='estate_property_search' model='ir.ui.view'> | ||
| <field name='name'>estate.property.search</field> | ||
| <field name='model'>estate.property</field> | ||
| <field name='arch' type='xml'> | ||
| <search> | ||
| <field name='name' string="Title"/> | ||
| <field name='postcode'/> | ||
| <field name='expected_price'/> | ||
| <field name='bedrooms'/> | ||
| <field name='living_area' string="Living Area (sqm)" filter_domain="[('living_area', '>=', self)]"/> | ||
| <field name='facades'/> | ||
| <filter name='active' string='Archived' domain='[("active", "=", False)]'/> | ||
| <separator/> | ||
| <filter name='state' string='Available' domain='["|", ("state", "=", "new"), ("state", "=", "offer_received")]'/> | ||
| <filter name='postcode' string="Postcode" context="{'group_by':'postcode'}"/> | ||
| </search> | ||
| </field> | ||
| </record> | ||
|
|
||
| <record id="estate_property_action" model="ir.actions.act_window"> | ||
|
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. What is a window action?
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. A window action is used to create a link between our model and its views by specifying the res_model and view_mode |
||
| <field name="name">Properties</field> | ||
| <field name="res_model">estate.property</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.
What is
dependsused for?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.
if the app is dependent on functions/features of other odoo modules, they must be defined in the depends field. it will load that modules before installing our app