Skip to content
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

Oxp24 technical training Chariots_dev #69

Open
wants to merge 48 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
944b3e8
First commit
chariots-dev Sep 30, 2024
0a3783d
first commit.bis
chariots-dev Sep 30, 2024
610dc83
18.0.0 commit
chariots-dev Sep 30, 2024
89882ea
18.0.0.1 commit
chariots-dev Sep 30, 2024
a7c98b4
18.0.0.1 commit
chariots-dev Sep 30, 2024
9d6f45e
18.0.0.1
chariots-dev Sep 30, 2024
3fac579
18.0.0.1
chariots-dev Sep 30, 2024
249c9d4
18.0.0.2
chariots-dev Sep 30, 2024
b8d7bb4
18.0.0.2 manifest
chariots-dev Sep 30, 2024
99a0517
18.0.0.3 new estate.property fields
chariots-dev Sep 30, 2024
2a46954
18.0.0.3 again
chariots-dev Sep 30, 2024
6f0dba6
18.0.0.3
chariots-dev Sep 30, 2024
1515d80
18.0.0.4 required fields
chariots-dev Sep 30, 2024
9bac0f3
18.0.0.4 all users write/mod/del access
chariots-dev Sep 30, 2024
b729d33
18.0.0.5
chariots-dev Sep 30, 2024
bc16890
18.0.0.6
chariots-dev Sep 30, 2024
77bc860
18.0.0.7 state field added
chariots-dev Sep 30, 2024
35a64b8
18.0.0.8 list view
chariots-dev Sep 30, 2024
a9239da
18.0.0.9 form view
chariots-dev Sep 30, 2024
78150ba
18.0.0.9
chariots-dev Sep 30, 2024
d5f4833
18.0.0.9
chariots-dev Sep 30, 2024
111fdf3
18.0.0.9 bis
chariots-dev Sep 30, 2024
0651890
18.0.0.10 formatted list view
chariots-dev Sep 30, 2024
754a2fd
18.0.0.11 search view
chariots-dev Sep 30, 2024
91c2139
18.0.0.11
chariots-dev Sep 30, 2024
1ea9f3a
18.0.0.12 Property Types
chariots-dev Oct 1, 2024
16003ea
18.0.0.13 property other info relations
chariots-dev Oct 1, 2024
8f8a673
18.0.0.14 property tags
chariots-dev Oct 1, 2024
9b1af11
18.0.0.14 init file
chariots-dev Oct 1, 2024
451bc3d
18.0.0.14 fix form view def for tag_ids
chariots-dev Oct 1, 2024
3b86628
18.0.0.15 to update tag_ids relation
chariots-dev Oct 1, 2024
999f637
18.0.0.16 property offers
chariots-dev Oct 1, 2024
097ded8
18.0.0.16
chariots-dev Oct 1, 2024
5a1e24b
18.0.0.17
chariots-dev Oct 1, 2024
e3cb1c7
18.0.0.18
chariots-dev Oct 1, 2024
be78cb5
18.0.0.18
chariots-dev Oct 1, 2024
c735c41
18.0.0.18
chariots-dev Oct 1, 2024
b609339
18.0.0.19
chariots-dev Oct 1, 2024
01fbf75
18.0.0.20 computed total area
chariots-dev Oct 1, 2024
9fb13cf
18.0.0.20
chariots-dev Oct 1, 2024
ede8be7
18.0.0.21 best price
chariots-dev Oct 1, 2024
677e83a
18.0.0.22
chariots-dev Oct 1, 2024
712e707
18.0.0.23
chariots-dev Oct 1, 2024
7902ccb
18.0.0.23
chariots-dev Oct 1, 2024
65c5772
18.0.0.23
chariots-dev Oct 1, 2024
e7c4590
18.0.0.23
chariots-dev Oct 1, 2024
de706e9
18.0.0.23
chariots-dev Oct 1, 2024
a02df32
18.0.0.24
chariots-dev Oct 1, 2024
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
13 changes: 12 additions & 1 deletion estate/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{
"name": "Estate", # The name that will appear in the App list
"version": "16.0.0", # Version
"version": "18.0.0.24", # Version
"application": True, # This line says the module is an App, and not a module
"depends": ["base"], # dependencies
"data": [
# views
"views/estate_property_views.xml",
"views/estate_property_settings_views.xml",
"views/estate_property_offer_views.xml",
"views/estate_menus.xml",

# security
"security/res_groups.xml",
"security/ir.model.access.csv",
],
"demo": [
"demo/demo.xml",
],
"installable": True,
'license': 'LGPL-3',
Expand Down
8 changes: 8 additions & 0 deletions estate/demo/demo.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<odoo>
<data>
<record id="house_1" model="estate.property">
<field name="name">House Number 1</field>
<field name="expected_price">100000</field>
</record>
</data>
</odoo>
Empty file removed estate/models.py
Empty file.
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 estate_property_type
from . import estate_property_tag
from . import estate_property_offer
62 changes: 62 additions & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from odoo import models, fields, api

# this is creating a table
class RealEstate(models.Model):
Copy link

Choose a reason for hiding this comment

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

Usually we try to have the same as the name of the model so here EstateProperty

_name = "estate.property"
_description = "Real Estate Property"

# this is creating fields in the table
name = fields.Char(default="House", required=True)
description = fields.Text()
postcode = fields.Char()
date_availability = fields.Date(copy=False, default=fields.Date.add(value=fields.Date.today(), months=3))
expected_price = fields.Float(required=True)
selling_price = fields.Float(readonly=True, copy=False)
bedrooms = fields.Integer(default=3)
living_area = fields.Integer()
facades = fields.Integer()
garage = fields.Boolean()
garden = fields.Boolean()
garden_area = fields.Integer()
garden_orientation = fields.Selection(
string='Garden Orientation',
selection=[('n', 'North'), ('ne', 'Northeast'), ('e', 'East'), ('se', 'Southeast'), ('s', 'South'),
('sw', 'Southwest'), ('w', 'West'), ('nw', 'Northwest')],
help="Denotes which direction the garden is facing"
)
active = fields.Boolean(default=True)
state = fields.Selection(
required=True, copy= False, default='new', string='Property Status',
selection=[('new', 'New'), ('received', 'Offer Received'), ('accepted', 'Offer Accepted'), ('sold', 'Sold'), ('cancelled', 'Cancelled')],
help="Reflects the current status in the sales process"
)
property_type_id = fields.Many2one("estate.property.type", string="Property Type")
salesperson_id = fields.Many2one("res.users", string="Salesperson", default=lambda self: self.env.user)
buyer_id = fields.Many2one("res.partner", string="Buyer Name", copy=False)
tag_ids = fields.Many2many("estate.property.tag", string="Property Tags")
offer_ids = fields.One2many("estate.property.offer", "property_id", string="Offers")
total_area = fields.Float(compute="_compute_total_area")
best_price = fields.Float(compute="_compute_best_price")

@api.depends("living_area", "garden_area")
def _compute_total_area(self):
for record in self:
record.total_area = record.living_area + record.garden_area

@api.depends("offer_ids.price")
def _compute_best_price(self):

for record in self:
if not record.offer_ids:
record.best_price = 0
else:
record.best_price = max(record.offer_ids.mapped('price'))

@api.onchange("garden")
def _onchange_garden(self):
if self.garden:
self.garden_area=10
self.garden_orientation='n'
else:
self.garden_area=0
self.garden_orientation=''
32 changes: 32 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from odoo import models, fields, api

# this is creating a table
class RealEstate(models.Model):
Copy link

Choose a reason for hiding this comment

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

Here it should be EstatePropertyOffer for example

_name = "estate.property.offer"
_description = "Real Estate Property Offer"

# this is creating fields in the table
price = fields.Float(copy=False, required=True)
status = fields.Selection(
default="received", required=True,
selection=[('received', 'Offer Received'), ('accepted', 'Offer Accepted'), ('refused', 'Refused')],
)
partner_id = fields.Many2one('res.partner', required=True)
property_id = fields.Many2one('estate.property', required=True)
validity = fields.Integer(default = 7, required=True)
date_deadline = fields.Date(compute="_compute_deadline", inverse="_inverse_deadline")

@api.depends("validity")
def _compute_deadline(self):
for record in self:
if not record.create_date:
record.date_deadline = fields.Date.add(value=fields.Date.today(), days=record.validity)
else:
record.date_deadline = fields.Date.add(value=record.create_date, days=record.validity)
Comment on lines +22 to +25
Copy link

Choose a reason for hiding this comment

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

Just another way than the slides

Suggested change
if not record.create_date:
record.date_deadline = fields.Date.add(value=fields.Date.today(), days=record.validity)
else:
record.date_deadline = fields.Date.add(value=record.create_date, days=record.validity)
date = record.create_date or record.create_date
record.date_deadline = fields.Date.add(value=date, days=record.validity)


def _inverse_deadline(self):
for record in self:
if not record.create_date:
record.validity = (record.date_deadline - fields.Date.today()).days
else:
record.validity = (record.date_deadline - fields.Date.to_date(record.create_date)).days
9 changes: 9 additions & 0 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import models, fields

# this is creating a table
class RealEstate(models.Model):
Copy link

Choose a reason for hiding this comment

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

Same Comment here

_name = "estate.property.tag"
_description = "Real Estate Property Tags"

# this is creating fields in the table
name = fields.Char(copy=False, required=True)
9 changes: 9 additions & 0 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import models, fields

# this is creating a table
class RealEstate(models.Model):
_name = "estate.property.type"
_description = "Real Estate Property Type"

# this is creating fields in the table
name = fields.Char(copy=False, required=True)
6 changes: 6 additions & 0 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,1,1,1
estate.access_estate_property_manager,access_estate_property_manager,estate.model_estate_property,estate.estate_property_manager,1,1,1,1
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,1,1,1
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,1,1,1
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,1,1,1
5 changes: 5 additions & 0 deletions estate/security/res_groups.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<odoo>
<record id="estate_property_manager" model="res.groups">
<field name="name">Estate Property Manager</field>
</record>
</odoo>
11 changes: 11 additions & 0 deletions estate/views/estate_menus.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<odoo>
<menuitem id="real_test_app" name="REAL TEST">
<menuitem id="second_level_menu" name="Estate">
<menuitem id="third_level_menuitem" name="Properties" action="estate_property_window"/>
Copy link

Choose a reason for hiding this comment

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

Maybe the naming of the id could be more explicit here like "estate_property_menu"

</menuitem>
<menuitem id="second_level_menu2" name="Settings">
<menuitem id="third_level_menuitem2" name="Property Types" action="estate_property_type_window"/>
<menuitem id="third_level_menuitem3" name="Property Tags" action="estate_property_tag_window"/>
</menuitem>
</menuitem>
</odoo>
30 changes: 30 additions & 0 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<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 string="Estate Property Offers">
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<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">
<list string="Estate Property Offer">
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<field name="status"/>
</list>
</field>
</record>

</odoo>
14 changes: 14 additions & 0 deletions estate/views/estate_property_settings_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<odoo>
<record id="estate_property_type_window" model="ir.actions.act_window">
<field name="name">Estate Property Types</field>
<field name="res_model">estate.property.type</field>
<field name="view_mode">list,form</field>
</record>

<record id="estate_property_tag_window" model="ir.actions.act_window">
<field name="name">Estate Property Tags</field>
<field name="res_model">estate.property.tag</field>
<field name="view_mode">list,form</field>
</record>

</odoo>
100 changes: 100 additions & 0 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<odoo>
<record id="estate_property_window" model="ir.actions.act_window">
<field name="name">Estate Properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
</record>

<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 string="Estate Properties">
<field name="name" string="Title" width="20px"/>
<field name="postcode" width="10px"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability" string="Available From"/>
</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 string="Estate Property">
<sheet>
<group>
<group>
<field name="tag_ids" widget="many2many_tags"/>
<field name='property_type_id'/>
<field name='postcode'/>
<field name="date_availability" string="Available From"/>
</group>
<group>
<field name="expected_price"/>
<field name="best_price"/>
<field name="selling_price"/>
</group>
</group>
<notebook>
<page string="Description">
<group>
<group>
<field name="name" string="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"/>
<field name="total_area"/>
</group>
</group>
</page>
<page string="Offers">
<group>
<group>
<field name="offer_ids"/>
</group>
</group>
</page>
<page string="Other Info">
<group>
<group>
<field name="salesperson_id"/>
<field name="buyer_id"/>
</group>
</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 string="Property Search">
<field name="name" string="Title" />
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area" string="Living Area (sqm)"/>
<field name="facades"/>
<separator/>
<filter string="Archived" name="active" domain="[('active', '=', False)]"/>
<filter name="Available" domain="['|', ('state', '=', 'new'), ('state', '=', 'received')]"/>
<group expand="1" string="Group By">
<filter name="postcode" context="{'group_by':'postcode', 'residual_visible':True}"/>
</group>
</search>
</field>
</record>
</odoo>