Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,4 @@ dmypy.json

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ops, I shouldn't see this file here :)
environmental files like this one (or .vscode) for example shouldn't be pushed with your commit

# Pyre type checker
.pyre/
.vscode/settings.json
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
11 changes: 11 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
'name': "Estate",
'depends': ["base"],
'application': True,
'installable': True,
'data': [
'security/ir.model.access.csv',
'views/estate_property_views.xml',
'views/estate_menus_views.xml'
]
}
1 change: 1 addition & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import estate_property
41 changes: 41 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from dateutil.relativedelta import relativedelta
from odoo import fields, models

Comment thread
msho-odoo marked this conversation as resolved.

class EstatePropertyModel(models.Model):
_name = "estate_property"
_description = "The details of a property"

name = fields.Char('Estate Name', required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=fields.Date.today()+relativedelta(months=3))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

directly valuating the fields.Date at default will work when imported but it will be stuck at this value, you should use lambda function. Search the codebase for it and let me know if you have any question :)

expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True)
bedrooms = fields.Integer(default=2)
living_area = fields.Integer()
facades = fields.Integer()
has_garage = fields.Boolean()
has_garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[
('east', 'East'),
('west', 'West'),
('north', 'North'),
('south', 'South'),
]
)
state = fields.Selection(
string='State',
selection=[
('new', 'New'),
('offer_received', 'Offer Received'),
('offer_accepted', 'Offer Accepted'),
('sold', 'Sold'),
('cancelled', 'Cancelled'),
],
default='new'
)
active = fields.Boolean(default=True)
2 changes: 2 additions & 0 deletions estate/security/ir.model.access.csv
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_model,access_estate_model,model_estate_property,base.group_user,1,1,1,1
11 changes: 11 additions & 0 deletions estate/views/estate_menus_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_fist_level_menu" name="Advertisements">
<menuitem
id="estate_property_menu_action"
action="estate_property_action"
/>
</menuitem>
</menuitem>
</odoo>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please Always check your runbot and make sure it's not red :)
it should be telling you you are missing a new line on the EOF here :)

98 changes: 98 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

<odoo>
<!-- Action Handler -->
<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>

<!-- List View -->
<record id="estate_property_list" model="ir.ui.view">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be id="estate_property_view_list" according to coding guidelines
I am writing this to grab your attention to the existing of such guidelines, you can have a look there although you might come across some existing files in the codebase that are not following this comment for example (maybe they are old enough or the team is not strict on conventions) but you should always follow guidelines for new diffs in the code :)

<field name="name">estate.property.list</field>
<field name="model">estate_property</field>
<field name="arch" type="xml">
<list string="Estates">
<field string="Estate" name="name"/>
<field name="postcode"/>
<field name="bedrooms"/>
<field string="Living Area (sqm)" name="living_area"/>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nitpick: usually we have name attribute before string so other developers see right away what field you are referring to

<field name="expected_price"/>
<field name="selling_price"/>
<field string="Available From" name="date_availability"/>
</list>
</field>
</record>

<!-- Form View -->
<record id="estate_property_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>
<h1><field name="name"></field></h1>
<group>
<group>
<field name="postcode"/>
<field string="Available From" name="date_availability"/>
</group>
<group>
<field name="expected_price"/>
<field name="selling_price"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description"/>
</group>
<group>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="facades"/>
<field name="has_garage"/>
<field name="has_garden"/>
<field name="garden_area" string="Garden Area (sqm)" invisible="not has_garden"/>
<field name="garden_orientation" invisible="not has_garden"/>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<!-- SearchBar -->
<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 string="Search properties">
<field string="Title" name="name"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field string="Living Area (sqm)" name="living_area"/>
<field name="facades"/>

<filter string="Available" name="available" domain="['|',('state', '=', 'New'), ('state', '=', 'offer_received')]"></filter>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The key you check on is 'new' not 'New'
This could be easier to read

Suggested change
<filter string="Available" name="available" domain="['|',('state', '=', 'New'), ('state', '=', 'offer_received')]"></filter>
<filter string="Available" name="available" domain="[('state', 'in', ('new', 'offer_received'))]"></filter>

<group>
<filter string="PostCode" name="postcode" context="{'group_by':'postcode'}"/>
</group>
</search>
</field>
</record>

<!--
<record id="[ID given to this record]" model="[Model being modified]">
<field name="name">[name for this field]</field>
<field name="model">[Model from which to gather data]</field>
<field name="arch" type="[Type of data architecture]">
<list string="Estates">
<field string="[Column String Visible]" name="[Data name from Model]"/>
</list>
</field>
</record>
-->
Comment on lines +87 to +97

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Delete unneeded comments please :)

</odoo>