Skip to content

Commit

Permalink
[IMP] estate: add property reports in estate module
Browse files Browse the repository at this point in the history
- Improved the report by including additional data fields and ensuring the PDF
 output matches the data accurately.
- Implemented conditional logic to handle cases with no offers, displaying a
 message instead of an empty table.
- Inherited and extended the property report to add invoice details.
  • Loading branch information
pkgu-odoo committed Aug 30, 2024
1 parent a93fa0d commit 2d10d68
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 1 deletion.
3 changes: 3 additions & 0 deletions estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
'views/estate_property_type_view.xml',
'views/estate_property_tag.xml',
'views/estate_property_offer.xml',
'report/estate_property_offer_template.xml',
'report/estate_property_reports.xml',
'report/estate_property_templates.xml',
'views/res_user.xml',
'views/estate_menus.xml',
],
Expand Down
35 changes: 35 additions & 0 deletions estate/report/estate_property_offer_template.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<odoo>
<template id="estate_property_offer_template">
<table class="table">
<thead>
<tr>
<th>Price</th>
<th>Patner</th>
<th>Validity</th>
<th>Deadline</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<t t-set="offers" t-value="property.mapped('offer_ids')"/>
<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>
</template>
</odoo>
23 changes: 23 additions & 0 deletions estate/report/estate_property_reports.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<odoo>
<record id="report_estate_property_offers" model="ir.actions.report">
<field name="name">Print Property</field>
<field name="model">estate.property</field>
<field name="report_type">qweb-html</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_offers - %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_estate_property_offer" model="ir.actions.report">
<field name="name">User Property Offers Report</field>
<field name="model">res.users</field>
<field name="report_type">qweb-html</field>
<field name="report_name">estate.report_user_property_offers</field>
<field name="report_file">estate.report_user_property_offers</field>
<field name="print_report_name">'User Estate Property - %s' % (object.name or 'Attendee').replace('/','')</field>
<field name="binding_model_id" ref="base.model_res_users"/>
<field name="binding_type">report</field>
</record>
</odoo>
65 changes: 65 additions & 0 deletions estate/report/estate_property_templates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<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">
<h2>
<span t-field="property.name"/>
</h2>
<div>
<strong>Salesman:</strong>
<span t-field="property.sell_person_id"/>
</div>
<div>
<strong>Expected Price: </strong>
<span t-field="property.expected_price"/>
</div>
<div>
<strong>Status:</strong>
<span t-field="property.state"/>
</div>
<t t-if="property.offer_ids">
<t t-call="estate.estate_property_offer_template"/>
</t>
<t t-else="">
<strong>No offers yet made for this property</strong>
</t>
</div>
</t>
</t>
</t>
</template>
<template id="report_user_property_offers">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="user">
<t t-call="web.external_layout">
<div class="page">
<h1>
<strong t-field="user.name"/>
</h1>
<t t-foreach="user.property_ids" t-as="property">
<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.state"/>
</div>
<t t-if="property.offer_ids">
<t t-call="estate.estate_property_offer_template"/>
</t>
<t t-else="">
<strong>No offers yet made for this property</strong>
</t>
</t>
</div>
</t>
</t>
</t>
</template>
</odoo>
2 changes: 1 addition & 1 deletion estate_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'name': 'Estate Account',
'version': '1.0',
'depends': ['estate', 'account'],
'data': [],
'data': ['report/estate_account_property_report.xml'],
'installable': True,
'application': True,
'auto_install': False,
Expand Down
15 changes: 15 additions & 0 deletions estate_account/report/estate_account_property_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<odoo>
<template id="report_property_invoice_extension" inherit_id="estate.report_property_offers">
<xpath expr="//div[@class='page']" position="before">
<!-- Add a line for invoice details -->
<t t-if="property.state == 'sold'">
<div>
<strong>
Your Invoice is has already created
</strong>
</div>
</t>
</xpath>
</template>
</odoo>

0 comments on commit 2d10d68

Please sign in to comment.