Skip to content

Commit

Permalink
[ADD] estate: created reports and added sample data for testing new f…
Browse files Browse the repository at this point in the history
…eatures

(estate): add property offers report and sample data for testing

- Created a new report for estate property offers (PDF format)
- Added sample data for testing new estate property features
- Fixed XML issues related to ir.actions.report and external ID conflicts
  • Loading branch information
aneg-odoo committed Sep 27, 2024
1 parent ea4b032 commit fa30f74
Show file tree
Hide file tree
Showing 21 changed files with 197 additions and 66 deletions.
1 change: 1 addition & 0 deletions estate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from . import models
from . import demo
from . import data
10 changes: 7 additions & 3 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@
"name": "Real_Estate",
"depends": ["base"],
"Description": "Estate Module by aneg",
"category": "Real Estate",
"category": "Real Estate/Brokerage",
"license": "LGPL-3",
"summary": "Real_Estate module for different purpose",
"author": "aneg_odoo",
"version": "0.1",
"application": True,
"installable": True,
"data": [
"security/ir.model.access.csv",
"views/estate_property_offer.xml",
"views/estate_property_views.xml",
"views/estate_property_offer.xml",
"views/estate_property_type.xml",
"views/estate_property_tag.xml",
"views/estate_menus.xml",
"views/res_users_view.xml",
"data/estate.property.type.csv",
"report/subtemplate_offers_table.xml",
"report/estate_property_templates.xml",
"report/estate_property_reports.xml",
"security/security.xml",
"security/ir.model.access.csv",
],
"demo": [
"demo/estate_demo.xml",
Expand Down
2 changes: 1 addition & 1 deletion estate/data/estate.property.type.csv
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ id,name
id4,Residential
id1,Commercial
id2,Industrial
id3,Land
id3,Land
4 changes: 0 additions & 4 deletions estate/demo/estate_demo.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<odoo>

<record id="estate_demo_data3" model="estate.property">
<field name="property_type" ref="id4" />
<field name="name">Big Villa</field>
Expand All @@ -16,7 +15,6 @@
<field name="garden">True</field>
<field name="garden_area">100000</field>
<field name="garden_orientation">south</field>

</record>
<record id="estate_demo_data5" model="estate.property">
<field name="property_type" ref="id4" />
Expand All @@ -32,8 +30,6 @@
<field name="facades">4</field>
<field name="garage">False</field>
</record>


<record id="estate_demo_data4" model="estate.property">
<field name="property_type" ref="id4" />
<field name="name">Trailor Home3</field>
Expand Down
1 change: 0 additions & 1 deletion estate/demo/estate_offer_demo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
<function model="estate.property.offer" name="action_confirm">
<value eval="[ref('estate_property_offer_demo_3')]" />
</function>

</odoo>
14 changes: 3 additions & 11 deletions estate/models/estate_property.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from odoo import api, models, fields
from datetime import datetime
from dateutil.relativedelta import relativedelta
from odoo import api, fields, models
from odoo.exceptions import UserError, ValidationError


class estateproperty(models.Model):
_name = "estate.property" #: name of the Model
_name = "estate.property"
_description = "estate_model"
_order = "id desc"

name = fields.Char("Title", default="Unknown")
myestate_model = fields.Text("Description")
postcode = fields.Char("Postcode")
Expand All @@ -32,7 +31,7 @@ class estateproperty(models.Model):
("new", "New"),
("offer received", "Offer Received"),
("offer accepted", "Offer Accepted"),
("sold", "Sold"),
("sold", "sold"),
("cancelled", "Cancelled"),
],
default="new",
Expand All @@ -48,7 +47,6 @@ class estateproperty(models.Model):
offer_id = fields.One2many("estate.property.offer", "property_id", string="Offers")
total = fields.Float(compute="_compute_total", string="Total Area (sqm)")
best_price = fields.Float(compute="_compute_price", string="Best offer")

_sql_constraints = [
(
"check_sellingprice_expectedprice_not_negative",
Expand Down Expand Up @@ -104,9 +102,3 @@ def _prevent_property_deletion(self):
for record in self:
if record.status not in ("new", "Cancelled"):
raise UserError("Only new and cancelled properties can be deleted")

# def check_limit(self, vals):
# self.status = "offer received"

# if vals.get("price") <= self.best_price:
# raise ValidationError("the offer must be higher than best price")
6 changes: 1 addition & 5 deletions estate/models/estate_property_offer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from odoo import api, models, fields
from datetime import date, timedelta
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class EstatePropertyOffer(models.Model):
_name = "estate.property.offer"
_description = "Estate Property Offer"
_order = "price desc"

price = fields.Float("Price")
status = fields.Selection(
[("Accepted", "Accepted"), ("Refused", "Refused")], readonly=True
Expand Down Expand Up @@ -46,12 +45,9 @@ def action_confirm(self):
def action_cancel(self):
for record in self:
record.status = "Refused"
# record.property_id.selling_price = 0

@api.model
def create(self, vals):
# self.env["estate.property"].browse(vals["property_id"]).check_limit(vals)
# return super().create(vals)
record = super().create(vals)
if record.property_id:
record.property_id.status = "offer received"
Expand Down
3 changes: 1 addition & 2 deletions estate/models/estate_property_tag.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from odoo import models, fields
from odoo import fields, models


class EstatePropertyTag(models.Model):
_name = "estate.property.tag"
_description = "EstatePropertyTag"
_order = "name"

name = fields.Char(string="tag", required=True)
_sql_constraints = [
("uniq_propertytag", "unique(name)", "A property tag name must be unique"),
Expand Down
4 changes: 1 addition & 3 deletions estate/models/estate_property_type.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from odoo import models, fields, api
from odoo import api, fields, models


class EstateProperty(models.Model):
_name = "estate.property.type"
_description = "EstatePropertyType"
_order = "name"

name = fields.Char("Property Types", required=True)
_sql_constraints = [
("uniq_propertytype", "unique(name)", "A property type name must be unique"),
Expand All @@ -18,7 +17,6 @@ class EstateProperty(models.Model):
sequence = fields.Integer(
"Sequence", default=1, help="To manually reorder property types"
)

api.depends("offer_id")

def _num_of_offers(self):
Expand Down
2 changes: 1 addition & 1 deletion estate/models/res_users.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from odoo import models, fields
from datetime import datetime
from odoo import fields, models


class Resusers(models.Model):
Expand Down
26 changes: 26 additions & 0 deletions estate/report/estate_property_reports.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<odoo>
<data>
<record id="report_estate_property_offers" model="ir.actions.report">
<field name="name">Property Offers</field>
<field name="model">estate.property</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">estate.report_property_offers</field>
<field name="report_file">estate.report_property_offers</field>
<field name="print_report_name">'Estate Property - %s' % (object.name or
'Attendee').replace('/','')</field>
<field name="binding_model_id" ref="model_estate_property" />
<field name="binding_type">report</field>
</record>
<record id="report_user_properties" model="ir.actions.report">
<field name="name">User Properties</field>
<field name="model">res.users</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">estate.report_user_properties3</field>
<field name="report_file">estate.report_user_properties3</field>
<field name="print_report_name">'Estate Users - %s' % (object.name or
'Attendee').replace('/','')</field>
<field name="binding_model_id" ref="base.model_res_users" />
<field name="binding_type">report</field>
</record>
</data>
</odoo>
67 changes: 67 additions & 0 deletions estate/report/estate_property_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="report_property_offers">
<t t-foreach="docs" t-as="property">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h1>
<strong>Salesman: </strong>
<span t-field="property.sale_id" />
</h1>
<h2>
<span t-field="property.name" />
</h2>
<div>
<strong>Expected Price: </strong>
<span t-field="property.expected_price" />
</div>
<div>
<strong>Status: </strong>
<span t-field="property.status" />
</div>
<t t-if="property.offer_id">
<t t-call="estate.report_property_offers_table" />
</t>
<t t-else="">
<p>No offers have been made yet !</p>
</t>
</div>
</t>
</t>
</t>
</template>
<template id="report_user_properties3">
<t t-foreach="docs" t-as="userproperty">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<t t-foreach="userproperty.property_ids" t-as="property">
<h1>
<strong>Salesman: </strong>
<span t-field="property.sale_id" />
</h1>
<h2>
<span t-field="property.name" />
</h2>
<div>
<strong>Expected Price: </strong>
<span t-field="property.expected_price" />
</div>
<div>
<strong>Status: </strong>
<span t-field="property.status" />
</div>
<t t-if="property.offer_id">
<t t-call="estate.report_property_offers_table" />
</t>
<t t-else="">
<p>No offers have been made yet !</p>
</t>
</t>
</div>
</t>
</t>
</t>
</template>
</odoo>
37 changes: 37 additions & 0 deletions estate/report/subtemplate_offers_table.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<odoo>
<template id="report_property_offers_table">
<t>
<table class="table">
<thead>
<tr>
<th>Price</th>
<th>Partner</th>
<th>Validitty(days)</th>
<th>Deadline</th>
<th>State</th>
</tr>
</thead>
<tbody>
<t t-set="offers" t-value="property.mapped('offer_id')" />
<tr t-foreach="offers" t-as="offer">
<td>
<span t-field="offer.price" />
</td>
<td>
<span t-field="offer.partner_id" />
</td>
<td>
<span t-field="offer.validity" />
</td>
<td>
<span t-field="offer.date_deadline" />
</td>
<td>
<span t-field="offer.status" />
</td>
</tr>
</tbody>
</table>
</t>
</template>
</odoo>
21 changes: 17 additions & 4 deletions estate/security/ir.model.access.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
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_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
estate.access_estate_property,access_estate_property,estate.model_estate_property,base.group_user,1,0,0,0
estate.access_estate_property_type,access_estate_property_type,estate.model_estate_property_type,base.group_user,1,0,0,0
estate.access_estate_property_tag,access_estate_property_tag,estate.model_estate_property_tag,base.group_user,1,0,0,0
estate.access_estate_property_offer,access_estate_property_offer,estate.model_estate_property_offer,base.group_user,1,0,0,0
estate.access_estate_property_manager,access_estate_property_manager,estate.model_estate_property,estate_group_manager,1,1,1,1
estate.access_estate_property_type_manager,access_estate_property_type_manager,estate.model_estate_property_type,estate_group_manager,1,1,1,1
estate.access_estate_property_tag_manager,access_estate_property_tag_manager,estate.model_estate_property_tag,estate_group_manager,1,1,1,1
estate.access_estate_property_offer_manager,access_estate_property_offer_manager,estate.model_estate_property_offer,estate_group_manager,1,1,1,1
estate.access_estate_property_agent,access_estate_property_agent,estate.model_estate_property,estate_group_user,1,1,1,0
estate.access_estate_property_type_agent,access_estate_property_type_agent,estate.model_estate_property_type,estate_group_user,1,0,0,0
estate.access_estate_property_tag_agent,access_estate_property_tag_agent,estate.model_estate_property_tag,estate_group_user,1,0,0,0






15 changes: 15 additions & 0 deletions estate/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<odoo>
<record id="estate_group_user" model="res.groups">
<field name="name">Agent</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage" />
<field name="comment">The agents can manage the properties under their care, or properties
which are not specifically under the care of any agent.</field>
</record>
<record id="estate_group_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="base.module_category_real_estate_brokerage" />
<field name="implied_ids" eval="[(4, ref('estate_group_user'))]" />
<field name="comment">The managers can configure the system (manage available types and
tags) as well as oversee every property in the pipeline..</field>
</record>
</odoo>
2 changes: 0 additions & 2 deletions estate/views/estate_property_type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<field name="res_model">estate.property.type</field>
<field name="view_mode">tree,form</field>
</record>

<record id="estate_property_type_tree_view" model="ir.ui.view">
<field name="name">state.property.type.tree.view</field>
<field name="model">estate.property.type</field>
Expand Down Expand Up @@ -49,6 +48,5 @@
</sheet>
</form>
</field>

</record>
</odoo>
Loading

0 comments on commit fa30f74

Please sign in to comment.