-
Notifications
You must be signed in to change notification settings - Fork 748
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
base: master
Are you sure you want to change the base?
Changes from all commits
944b3e8
0a3783d
610dc83
89882ea
a7c98b4
9d6f45e
3fac579
249c9d4
b8d7bb4
99a0517
2a46954
6f0dba6
1515d80
9bac0f3
b729d33
bc16890
77bc860
35a64b8
a9239da
78150ba
d5f4833
111fdf3
0651890
754a2fd
91c2139
1ea9f3a
16003ea
8f8a673
9b1af11
451bc3d
3b86628
999f637
097ded8
5a1e24b
e3cb1c7
be78cb5
c735c41
b609339
01fbf75
9fb13cf
ede8be7
677e83a
712e707
7902ccb
65c5772
e7c4590
de706e9
a02df32
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,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> |
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 |
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): | ||
_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='' |
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): | ||||||||||||||
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. 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
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. Just another way than the slides
Suggested change
|
||||||||||||||
|
||||||||||||||
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 |
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): | ||
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. 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) |
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) |
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 |
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> |
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"/> | ||
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. 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> |
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> |
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> |
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> |
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.
Usually we try to have the same as the name of the model so here EstateProperty