Skip to content

Commit

Permalink
[ADD] estate: Added the sprinkles
Browse files Browse the repository at this point in the history
  • Loading branch information
malm-odoo committed Oct 24, 2024
1 parent e8020f0 commit a8ffcf6
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class EstateProperty(models.Model):
_name = 'estate.property'
_description = 'Create real estate properties and keep track of status'
_order = 'id desc'

name = fields.Char(string="Name", required=True)
description = fields.Text(string="Description")
Expand Down
2 changes: 2 additions & 0 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
class EstatePropertyOffer(models.Model):
_name = 'estate.property.offer'
_description = 'Model representing the offers from partners to a specific property'
_order = 'price desc'

price = fields.Float(string="Price")
status = fields.Selection(
Expand All @@ -22,6 +23,7 @@ class EstatePropertyOffer(models.Model):
validity = fields.Integer(string="Validity", default=7)
date_deadline = fields.Date(compute='_compute_date_deadline', inverse='_inverse_date_deadline', string="Date Deadline")
create_date = fields.Date(default=lambda self: fields.Datetime.now())
property_type_id = fields.Many2one(related="property_id.property_type_id")

_sql_constraints = [
('check_offer_price', 'CHECK(price > 0)',
Expand Down
4 changes: 3 additions & 1 deletion estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from odoo import fields, models


class EstatePropertyType(models.Model):
class EstatePropertyTag(models.Model):
_name = 'estate.property.tag'
_description = 'Model representing the tags of each estate property'
_order = 'name'

name = fields.Char(string="Name", required=True)
color = fields.Integer(string="Color")

_sql_constraints = [
('check_unique_name', 'UNIQUE(name)', "This tag name already exists."),
Expand Down
13 changes: 12 additions & 1 deletion estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
from odoo import fields, models
from odoo import api, fields, models
from odoo.fields import One2many


class EstatePropertyType(models.Model):
_name = 'estate.property.types'
_description = 'Model representing the different types of properties'
_order = 'name'

name = fields.Char(string="Name", required=True)
property_ids = fields.One2many('estate.property', 'property_type_id')
sequence = fields.Integer(string='Sequence')
offer_ids = One2many('estate.property.offer', 'property_type_id')
offer_count = fields.Integer(compute="_compute_offer_count", string="Offer Count")

_sql_constraints = [
('check_unique_name', 'UNIQUE(name)', "This property type already exists."),
]

@api.depends('offer_ids')
def _compute_offer_count(self):
for record in self:
record.offer_count = len(record.offer_ids)
17 changes: 13 additions & 4 deletions estate/views/estate_property_offer_views.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
<?xml version="1.0"?>
<odoo>
<record id="estate_property_offer_action" model="ir.actions.act_window">
<field name="name">Property Type Offers</field>
<field name="res_model">estate.property.offer</field>
<field name="view_mode">list,form</field>
<field name="domain">[('property_type_id', '=', active_id)]</field>
</record>

<record id="property_offer_view_list" model="ir.ui.view">
<field name="name">List View</field>
<field name="model">estate.property.offer</field>
<field name="arch" type="xml">
<list string="Properties">
<list string="Properties" editable="bottom"
decoration-success="status in ['accepted']"
decoration-danger="status in ['refused']"
>
<field name="price"/>
<field name="partner_id"/>
<field name="validity"/>
<field name="date_deadline"/>
<button name="action_confirm" string="Confirm" type="object" icon="fa-check"/>
<button name="action_refuse" string="Refuse" type="object" icon="fa-times"/>
<field name="status"/>
<button name="action_confirm" string="Confirm" type="object" icon="fa-check" invisible="status in ['accepted', 'refused']"/>
<button name="action_refuse" string="Refuse" type="object" icon="fa-times" invisible="status in ['accepted', 'refused']"/>
</list>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion estate/views/estate_property_tag_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<field name="name">List View</field>
<field name="model">estate.property.tag</field>
<field name="arch" type="xml">
<list string="Properties">
<list string="Properties" editable="bottom">
<field name="name"/>
</list>
</field>
Expand Down
22 changes: 22 additions & 0 deletions estate/views/estate_property_types_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<field name="model">estate.property.types</field>
<field name="arch" type="xml">
<list string="Properties">
<field name="sequence" widget="handle"/>
<field name="name"/>
</list>
</field>
Expand All @@ -22,9 +23,30 @@
<field name="arch" type="xml">
<form string="View Form">
<sheet>
<div name="button_box" position="inside">
<button type="action"
icon="fa-money"
string="Offers"
name="%(estate.estate_property_offer_action)d">
<field name="offer_count" string="Offers" widget="statinfo"/>
</button>
</div>
<group>
<h1><field name="name"/></h1>
</group>
<notebook>
<page string="Properties">
<group>
<field name="property_ids">
<list>
<field name="name"/>
<field name="expected_price"/>
<field name="state"/>
</list>
</field>
</group>
</page>
</notebook>
</sheet>
</form>
</field>
Expand Down
29 changes: 18 additions & 11 deletions estate/views/estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
<field name="name">Properties</field>
<field name="res_model">estate.property</field>
<field name="view_mode">list,form</field>
<field name="context">{'search_default_state': True}</field>
</record>

<record id="estate_property_view_list" model="ir.ui.view">
<field name="name">List View</field>
<field name="model">estate.property</field>
<field name="arch" type="xml">
<list string="Properties">
<list string="Properties"
decoration-success="state in ['offer_received', 'offer_accepted']"
decoration-bf="state in ['offer_accepted']"
decoration-muted="state in ['sold']"
>
<field name="name"/>
<field name="tag_ids" widget="many2many_tags"/>
<field name="property_type_id"/>
Expand All @@ -19,7 +24,7 @@
<field name="living_area"/>
<field name="expected_price"/>
<field name="selling_price"/>
<field name="date_availability"/>
<field name="date_availability" optional="true"/>
</list>
</field>
</record>
Expand All @@ -35,7 +40,9 @@
<field name="postcode"/>
<field name="expected_price"/>
<field name="bedrooms"/>
<field name="living_area"/>
<field name="living_area"
filter_domain="[('living_area', '>=', self)]"
/>
<field name="facades"/>
<filter string="Available"
name="state"
Expand All @@ -58,19 +65,19 @@
<field name="arch" type="xml">
<form string="View Form">
<header>
<button name="action_sold" type="object" string="SOLD"/>
<button name="action_cancel" type="object" string="CANCEL"/>
<button name="action_sold" type="object" string="SOLD" invisible="state in ['sold', 'cancelled']"/>
<button name="action_cancel" type="object" string="CANCEL" invisible="state in ['sold', 'cancelled']"/>
<field name="state" readonly="state in ['sold', 'cancelled']" widget="statusbar"/>
</header>
<sheet>
<group>
<h1><field name="name"/></h1>
</group>
<group>
<field name="tag_ids" widget="many2many_tags"/>
<field name="tag_ids" widget="many2many_tags" options="{'color_field': 'color'}"/>
</group>
<group>
<field name="state" readonly="state in ['sold', 'cancelled']"/>
<field name="property_type_id"/>
<field name="property_type_id" options="{'no_create': true}"/>
<field name="postcode"/>
<field name="expected_price"/>
<field name="best_price"/>
Expand All @@ -86,14 +93,14 @@
<field name="facades"/>
<field name="garage"/>
<field name="garden"/>
<field name="garden_area"/>
<field name="garden_orientation"/>
<field name="garden_area" invisible="not garden"/>
<field name="garden_orientation" invisible="not garden"/>
<field name="total_area"/>
</group>
</page>
<page string="Offers">
<group>
<field name="offer_ids"/>
<field name="offer_ids" readonly="state in ['offer_accepted', 'sold', 'cancelled']"/>
</group>
</page>
<page string="Other Info">
Expand Down

0 comments on commit a8ffcf6

Please sign in to comment.