Skip to content
Open
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Odoo tutorials

test
This repository hosts the code for the bases of the modules used in the
[official Odoo tutorials](https://www.odoo.com/documentation/latest/developer/tutorials.html).

Expand Down
3 changes: 3 additions & 0 deletions estate/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.languageServer": "None"
}
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
23 changes: 23 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ 'name': 'real estate app plh',
'depends': [
'base',],
'application': True,
'data':[
'security/ir.model.access.csv',
'views/estate_property_views_action.xml',
'views/estate_menus.xml',
'views/estate_list_view.xml',
'views/estate_form_view.xml',
'views/estate_search_view.xml',
'views/type_actions.xml',
'views/type_menus.xml',
'views/type_views.xml',
'views/tag_actions.xml',
'views/tag_menus.xml',
'views/tag_views.xml',
# 'views/offer_actions.xml',
# 'views/offer_menus.xml',
'views/offer_views.xml',

]
}
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 estate_property
from . import property_type
from . import property_tag
from . import property_offer
27 changes: 27 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from odoo import fields, models
from datetime import date, timedelta

class EstateProperty(models.Model):
_name = "estate.property"
_description = "reals estate properties"

name = fields.Char('Property Name',required=True)
offer_ids=fields.One2many("estate.property.offer","property_id",string="Offers Received")
tag_ids=fields.Many2many("estate.property.tags",string="Tags")
buyer_id=fields.Many2one("res.partner",string="Buyer")
salesperson_id=fields.Many2one("res.users",string="Sales Person",default=lambda self: self.env.user)
property_type_id = fields.Many2one("estate.property.types", string="Property Type")
description = fields.Text('The Descritption')
postcode = fields.Char()
date_availability = fields.Date(default=date.today()+ timedelta(days=90),copy=False)
expected_price = fields.Float(required=True)
selling_price = fields.Float(copy=False,readonly=True)
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([("North","North"),("South","South"),("East","East"),("West","West")])

Choose a reason for hiding this comment

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

Suggested change
garden_orientation = fields.Selection([("North","North"),("South","South"),("East","East"),("West","West")])
garden_orientation = fields.Selection([("north","North"),("south","South"),("east","East"),("west","West")])

Use lowercase keys for state values for consistency with Odoo's best practices.

active = fields.Boolean(default=True)
state = fields.Selection([("New","New"),("Offer Received","Offer Received"),("Offer Accpeted","Offer Accepted"),("Solde","Solde"),("Cancelled","Cancelled")],copy=False,default="New")

Choose a reason for hiding this comment

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

Suggested change
state = fields.Selection([("New","New"),("Offer Received","Offer Received"),("Offer Accpeted","Offer Accepted"),("Solde","Solde"),("Cancelled","Cancelled")],copy=False,default="New")
state = fields.Selection([
("new", "New"),
("offer_received", "Offer Received"),
("offer_accepted", "Offer Accepted"),
("sold", "Sold"),
("cancelled", "Cancelled")
], copy=False, default="new")

14 changes: 14 additions & 0 deletions estate/models/property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from odoo import fields, models
from datetime import date, timedelta

class EstatePropertyOffer(models.Model):
_name = "estate.property.offer"
_description = "reals estate properties offer"

property_type_id= fields.Char('Property Offer ID')

Choose a reason for hiding this comment

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

Suggested change
property_type_id= fields.Char('Property Offer ID')
property_offer_id= fields.Char('Property Offer ID')

misleading name

price = fields.Float('Le Prix')
status = fields.Selection([("Accepted","Accepted"),("Refused","Refused")],copy=False)

Choose a reason for hiding this comment

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

Suggested change
status = fields.Selection([("Accepted","Accepted"),("Refused","Refused")],copy=False)
status = fields.Selection([("accepted","Accepted"), ("refused","Refused")], copy=False)

partner_id=fields.Many2one("res.partner",required=True)
property_id=fields.Many2one("estate.property",required=True)

# properties = fields.One2many("estate.property","property_type_id",string="properties")
9 changes: 9 additions & 0 deletions estate/models/property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models
from datetime import date, timedelta

class EstatePropertyType(models.Model):

Choose a reason for hiding this comment

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

Suggested change
class EstatePropertyType(models.Model):
class EstatePropertyTag(models.Model):

_name = "estate.property.tags"

Choose a reason for hiding this comment

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

Suggested change
_name = "estate.property.tags"
_name = "estate.property.tag"

a record represents only one tag

_description = "common characteristics of the properties"

name = fields.Char('Property Tag Name',required=True)
properties = fields.Many2many("estate.property","tag_ids",string="properties")

Choose a reason for hiding this comment

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

Suggested change
properties = fields.Many2many("estate.property","tag_ids",string="properties")
property_ids = fields.Many2many("estate.property","tag_ids",string="properties")

10 changes: 10 additions & 0 deletions estate/models/property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models
from datetime import date, timedelta

class EstatePropertyType(models.Model):
_name = "estate.property.types"

Choose a reason for hiding this comment

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

Suggested change
_name = "estate.property.types"
_name = "estate.property.type"

Each record in this file represents a single estate property type, so the name should be clear and not misleading.

_description = "reals estate properties"

name = fields.Char('Property Type Name',required=True)
property_type_id= fields.Char('Property Type ID',required=True)

Choose a reason for hiding this comment

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

what is this field, why do you need it?

properties = fields.One2many("estate.property","property_type_id",string="properties")

Choose a reason for hiding this comment

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

Suggested change
properties = fields.One2many("estate.property","property_type_id",string="properties")
property_ids = fields.One2many("estate.property","property_type_id",string="properties")

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
estate.access_estate_property,access_estate_property,model_estate_property,base.group_user,1,1,1,1
estate.access_estate_property_types,access_estate_property_types,model_estate_property_types,base.group_user,1,1,1,1
estate.access_estate_property_tags,access_estate_property_tags,model_estate_property_tags,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,model_estate_property_offer,base.group_user,1,1,1,1
67 changes: 67 additions & 0 deletions estate/views/estate_form_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_view_form" model="ir.ui.view">
<field name="name">estate.property.view.form</field>
<field name="model">estate.property</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Test">
<sheet>

<group>



<group>

Choose a reason for hiding this comment

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

Suggested change
<sheet>
<group>
<group>
<sheet>
<group>
<group>

<field name="name"/>
</group>
<group>
Comment on lines +23 to +24

Choose a reason for hiding this comment

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

Suggested change
</group>
<group>

there is no need of putting each one of them in a group

<field name="expected_price"/>
</group>
</group>
<group>
<group>
<field name="date_availability"/>
</group>
<group>
Comment on lines +31 to +32

Choose a reason for hiding this comment

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

Suggested change
</group>
<group>

same here

<field name="selling_price"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<field name="description"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name="bedrooms"/>
<field name="property_type_id"/>
<field name="buyer_id"/>
<field name="salesperson_id"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="state"/>
</group>

Choose a reason for hiding this comment

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

Suggested change
<group>
<field name="description"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name="bedrooms"/>
<field name="property_type_id"/>
<field name="buyer_id"/>
<field name="salesperson_id"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="state"/>
</group>
<group>
<field name="description"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name="bedrooms"/>
<field name="property_type_id"/>
<field name="buyer_id"/>
<field name="salesperson_id"/>
<field name="living_area"/>
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="state"/>
</group>

respect indentation and format

</page>
<page string="Other Info">
<group>
<field name="buyer_id"/>
<field name="salesperson_id"/>
</group>

</page>
<page string="Offers">
<group>
<field name="offer_ids"/>
</group>

</page>
</notebook>
</sheet>
</form>
</field>

Choose a reason for hiding this comment

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

Suggested change
</field>

remove this line, it's useless

</record>

</odoo>
29 changes: 29 additions & 0 deletions estate/views/estate_list_view.xml

Choose a reason for hiding this comment

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

List views are typically used for summarizing key information. Fields like offer_ids, tag_ids, and living_area may not be relevant for a list view. Instead, prioritize fields that give a quick overview of the estate property.

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">estate.property.view.list</field>
<field name="model">estate.property</field>
<field name="type">list</field>
<field name="arch" type="xml">

<list string="Tests">

Choose a reason for hiding this comment

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

The string="Tests" on the tag seems unrelated to the content of the view. Replace it with a more appropriate name like Estate Properties.

Suggested change
<list string="Tests">
<list string="Estate Properties">

<field name="name"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name ="offer_ids" widget="many2many_tags"/>

Choose a reason for hiding this comment

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

Suggested change
<field name ="offer_ids" widget="many2many_tags"/>
<field name="offer_ids" widget="many2many_tags"/>

Choose a reason for hiding this comment

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

The offer_ids field uses the many2many_tags widget, which is not suitable for list views. Instead, consider showing a count or summary of related offers.

<field name="property_type_id"/>
<field name="buyer_id"/>
<field name="salesperson_id"/>
<field name="bedrooms"/>
<field name ="state"/>
<field name ="garden"/>
<field name ="postcode"/>
<field name ="date_availability"/>
<field name ="expected_price"/>
<field name ="selling_price"/>
<field name ="living_area"/>

Choose a reason for hiding this comment

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

Suggested change
<field name ="state"/>
<field name ="garden"/>
<field name ="postcode"/>
<field name ="date_availability"/>
<field name ="expected_price"/>
<field name ="selling_price"/>
<field name ="living_area"/>
<field name="state"/>
<field name="garden"/>
<field name="postcode"/>
<field name="date_availability"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="living_area"/>

</list>
</field>
</record>


</odoo>
10 changes: 10 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="test_first_level_menu" name="Properties">

Choose a reason for hiding this comment

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

use descriptive id for the menu item

Suggested change
<menuitem id="test_first_level_menu" name="Properties">
<menuitem id="estate_menu_properties" name="Properties">

<menuitem id="test_model_menu_action" action="estate_property_view" />

Choose a reason for hiding this comment

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

same here:

Suggested change
<menuitem id="test_model_menu_action" action="estate_property_view" />
<menuitem id="estate_menu_action_properties" action="estate_property_view" />

</menuitem>

</menuitem>

</odoo>
8 changes: 8 additions & 0 deletions estate/views/estate_property_views_action.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_view" model="ir.actions.act_window">
<field name="name">View properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,kanban,form</field>
</record>
</odoo>
35 changes: 35 additions & 0 deletions estate/views/estate_search_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_view_search" model="ir.ui.view">
<field name="name">estate.property.view.search</field>
<field name="model">estate.property</field>
<field name="type">search</field>
<field name="arch" type="xml">

<search string="Tests">

Choose a reason for hiding this comment

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

Suggested change
<search string="Tests">
<search string="Property Search">

<field name="name"/>
<field name="property_type_id"/>
<field name="bedrooms"/>
<field name="description"/>

Choose a reason for hiding this comment

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

why would someone search for a property by its description??

<field name ="postcode"/>
<field name ="date_availability"/>
<field name ="expected_price"/>
Comment on lines +14 to +16

Choose a reason for hiding this comment

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

Suggested change
<field name ="postcode"/>
<field name ="date_availability"/>
<field name ="expected_price"/>
<field name="postcode"/>
<field name="date_availability"/>
<field name="expected_price"/>

<field name="buyer_id"/>
<field name="salesperson_id"/>
<field name ="selling_price"/>
<field name ="living_area"/>
Comment on lines +20 to +21

Choose a reason for hiding this comment

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

Suggested change
<field name ="selling_price"/>
<field name ="living_area"/>
<field name="selling_price"/>
<field name="living_area"/>

<group expand="1" string="Group By">
<filter string="BedRooms" name="bedrooms" context="{'group_by':'bedrooms', 'residual_visible':True}"/>

Choose a reason for hiding this comment

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

Suggested change
<filter string="BedRooms" name="bedrooms" context="{'group_by':'bedrooms', 'residual_visible':True}"/>
<filter string="BedRooms" name="bedrooms" context="{'group_by':'bedrooms', 'residual_visible':True}"/>

</group>
<filter string="Postcode" name="bedrooms" context="{'group_by':'postcode', 'residual_visible':True}"/>
<filter string="Buyer" name="bedrooms" context="{'group_by':'buyer_id', 'residual_visible':True}"/>
<filter string="With Garden" name="garden" domain="[('garden', '=', True)]"/>
<filter string="Available" name="garden" domain="[('state', 'in',['New','Offer Received'] )]"/>

Choose a reason for hiding this comment

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

filters should have a unique name
you have three filters called bedroom and two filters called garden



</search>
</field>
</record>


</odoo>
8 changes: 8 additions & 0 deletions estate/views/offer_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_offer_view" model="ir.actions.act_window">
<field name="name">View property Offer</field>
<field name="res_model">estate.property.offer</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions estate/views/offer_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_settings" name="Settings">
<menuitem id="estate_offer_menu_action" action="estate_offer_view" />
</menuitem>

</menuitem>

</odoo>
53 changes: 53 additions & 0 deletions estate/views/offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<odoo>

<!-- the list view -->
<record id="estate_offer_view_list" model="ir.ui.view">
<field name="name">estate.offer.view.list</field>
<field name="model">estate.property.offer</field>
<field name="type">list</field>
<field name="arch" type="xml">

<list string="Tests">

Choose a reason for hiding this comment

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

Suggested change
<list string="Tests">
<list string="Property Offers List">

<field name="price"/>
<field name="partner_id"/>
<field name="status"/>


</list>
</field>
</record>

<!-- the form view -->

Choose a reason for hiding this comment

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

The fields are in a single group, which makes the form cluttered. Logical grouping is necessary for clarity. For example:

  • Financial details: price, date_deadline.
  • Customer details: partner_id.
  • Offer status: status.

<record id="estate_type_view_form" model="ir.ui.view">
<field name="name">estate.offer.view.form</field>
<field name="model">estate.property.offer</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Test">

Choose a reason for hiding this comment

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

Suggested change
<form string="Test">
<form string="Property Offer Form">

<sheet>
<group>
<field name="price" />
<field name="partner_id"/>
<field name="status"/>

</group>

Choose a reason for hiding this comment

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

Suggested change
<group>
<field name="price" />
<field name="partner_id"/>
<field name="status"/>
</group>
<group>
<field name="price" />
<field name="partner_id"/>
<field name="status"/>
</group>

</sheet>
</form>
</field>
</record>

<!-- search view -->
<record id="estate_tag_view_search" model="ir.ui.view">
<field name="name">estate.offer.view.search</field>
<field name="model">estate.property.offer</field>
<field name="type">search</field>
<field name="arch" type="xml">

<search string="Tests">

Choose a reason for hiding this comment

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

Suggested change
<search string="Tests">
<search string="Search Property Offers">

<field name="partner_id"/>

Choose a reason for hiding this comment

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

Only the partner_id field is available for searching, which is insufficient. Add fields like price, status, and date_deadline.

</search>
</field>
</record>

</odoo>
8 changes: 8 additions & 0 deletions estate/views/tag_actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_tag_view" model="ir.actions.act_window">
<field name="name">View property Tags</field>
<field name="res_model">estate.property.tags</field>
<field name="view_mode">list,form</field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions estate/views/tag_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="estate_menu_root" name="Real Estate">
<menuitem id="estate_settings" name="Settings">
<menuitem id="estate_tag_menu_action" action="estate_tag_view" />
</menuitem>

</menuitem>

</odoo>
Loading