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 estate/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
10 changes: 10 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "real estate",
"description": "real estate renting management system",
Comment on lines +2 to +3

Choose a reason for hiding this comment

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

I would have capitalized these lines

"category": "Tutorials",
"version": "1.1",
"application": True,
"data": ["security/ir.model.access.csv", "views/views.xml", "views/menus.xml"],

Choose a reason for hiding this comment

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

Please split your data files (same comment for as many lists as possible):

Suggested change
"data": ["security/ir.model.access.csv", "views/views.xml", "views/menus.xml"],
"data": [
"security/ir.model.access.csv",
"views/views.xml",
"views/menus.xml",
],

If someone has to add a file, it will be way easier and keep a clear overview (with git history) of the changes.

"author": "OMKHA",

Choose a reason for hiding this comment

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

Suggested change
"author": "OMKHA",
"author": "Odoo",

As you are developing for Odoo, the company is the author of the file.

"license": "LGPL-3",
}
4 changes: 4 additions & 0 deletions estate/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import buildings_model
from . import building_type_model
from . import tags_model
from . import offers_model
8 changes: 8 additions & 0 deletions estate/models/building_type_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


class building_type_model(models.Model):

Choose a reason for hiding this comment

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

The class name should match the file name (for most cases) and follow the PascalCase convention.
As PEP8 says (https://peps.python.org/pep-0008/#class-names):

Class names should normally use the CapWords convention

Suggested change
class building_type_model(models.Model):
class BuildingType(models.Model):

_name = "estate.building_type"
_description = "Building Type Model"

name = fields.Char(required=True)
38 changes: 38 additions & 0 deletions estate/models/buildings_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from odoo import models, fields
from datetime import timedelta


class buildings_model(models.Model):
_name = "estate.buildings"
_description = "Buildings Model"

name = fields.Char()
description = fields.Text()
value = fields.Integer(copy=False)
availability_date = fields.Date(
default=fields.Date.today() + timedelta(days=90), copy=False

Choose a reason for hiding this comment

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

Use a lambda function or call a compute method because this will fix the default date to the server starting date

)
number_of_rooms = fields.Integer(default=2)
garden_orientation = fields.Selection(
[("north", "North"), ("south", "South"), ("east", "East"), ("west", "West")],
"garden Orientation",
)
active = fields.Boolean(default=True)
state = fields.Selection(
[
("new", "New"),
("offer received", "Offer Received"),
("offer accepted", "Offer Accepted"),
("sold", "Sold"),
("canceled", "Canceled"),
],
default="new",
)
post_code = fields.Integer(default=1000)
building_type_id = fields.Many2one("estate.building_type", string="Building Type")
buyer_id = fields.Many2one("res.partner", string="Buyer")
salesperson_id = fields.Many2one(
"res.users", string="Salesperson", default=lambda self: self.env.user
)
tag_ids = fields.Many2many("estate.building_tags", string="Tags")
offer_ids = fields.One2many("estate.offers", "building_id", string="Offers")
15 changes: 15 additions & 0 deletions estate/models/offers_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from odoo import models, fields


class offers_model(models.Model):
_name = "estate.offers"
_description = "Offers Model"

price = fields.Integer(required=True)
status = fields.Selection(
[("accepted", "Accepted"), ("refused", "Refused")],
string="Status",
required=True,
)
building_id = fields.Many2one("estate.buildings", string="Building")
partner_id = fields.Many2one("res.partner", string="Partner")
8 changes: 8 additions & 0 deletions estate/models/tags_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from odoo import models, fields


class building_tags_model(models.Model):
_name = "estate.building_tags"
_description = "Building Tags Model"

name = fields.Char(required=True)
5 changes: 5 additions & 0 deletions estate/security/ir.model.access.csv
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_first_model,access_first_model,model_estate_buildings,base.group_user,1,1,1,1
access_building_type_model,access_building_type_model,model_estate_building_type,base.group_user,1,1,1,1
access_building_tags_model,access_building_tags_model,model_estate_building_tags,base.group_user,1,1,1,1
access_offers_model,access_offers_model,model_estate_offers,base.group_user,1,1,1,1

Choose a reason for hiding this comment

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

Don't forget Unix conventions on text files' structure based on a line definition (cf. https://peps.python.org/pep-0008/ and https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206)

Check all XML files too

8 changes: 8 additions & 0 deletions estate/views/menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="test_menu_root" name="Estate FelBeit">
<menuitem id="test_first_level_menu" name="First Level">
<menuitem id="test_model_menu_action" action="some_model_action_1"/>
</menuitem>
</menuitem>
</odoo>
85 changes: 85 additions & 0 deletions estate/views/views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="some_model_action_1" model="ir.actions.act_window">
<field name="name">Test action 1</field>
<field name="res_model">estate.buildings</field>
<field name="view_mode">list,form</field>
</record>
<record id="list_view" model="ir.ui.view">
<field name="name">estate.buildings.list</field>
<field name="model">estate.buildings</field>
<field name="arch" type="xml">
<list string="test_list">
<field name="name"/>
<field name="number_of_rooms"/>
<field name="value"/>
<field name="state"/>
<field name="building_type_id"/>
</list>
</field>
</record>

<record id="first_form_view" model="ir.ui.view">
<field name="name">estate.buildings.form</field>
<field name="model">estate.buildings</field>
<field name="arch" type="xml">
<form string="Test">
<sheet>
<group>
<group>
<field name="name"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name="value"/>
<field name="state"/>
<field name="availability_date"/>
<field name="building_type_id"/>
</group>
<group>
<field name="number_of_rooms"/>
<field name="garden_orientation"/>
<field name="post_code"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description"/>
</group>
</page>
<page string="Info">
<group>
<field name="buyer_id"/>
<field name="salesperson_id"/>
</group>
</page>
<page string="Offers">
<field name="offer_ids">
<list>
<field name="price"/>
<field name="status"/>
<field name="partner_id"/>
</list>
</field>
</page>
</notebook>
</sheet>
</form>
</field>
</record>

<record id="first_search_view" model="ir.ui.view">
<field name="name">estate.buildings.search</field>
<field name="model">estate.buildings</field>
<field name="arch" type="xml">
<search string="test_search">
<field name="name"/>
<field name="value"/>
<separator/>
<filter string="Available" name="Available" domain="['|', ('state', '=', 'new' ), ('state', '=', 'offer received')]"/>

Choose a reason for hiding this comment

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

Maybe try something like [('state', 'in', ['new', 'offer_received'])]

<filter string="postcode" name="postcode" context="{'group_by':'post_code'}"/>
</search>

</field>
</record>

</odoo>