Skip to content

Commit

Permalink
[IMP] estate: Implemented PDF Reports
Browse files Browse the repository at this point in the history
After this commit:
 Implemented Minimal Template
 Implemented Sub Templeted
 Implemented Report Inheritance
  • Loading branch information
niku-odoo committed Aug 30, 2024
1 parent f9ce537 commit ae252ec
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 26 deletions.
5 changes: 4 additions & 1 deletion estate/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
'view/estate_property_tag_view.xml',
'view/res_users_view.xml',
'view/estate_menus.xml',
'data/property_type.xml'
'data/property_type.xml',
'report/estate_property_template.xml',
'report/estate_property_report.xml',
'report/estate_property_subtemplate.xml'
],
'demo': [
'demo/estate_property_demo.xml',
Expand Down
43 changes: 21 additions & 22 deletions estate/demo/estate_demo_offers.xml
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<odoo>
<record id="azure_interior_big_villa_1" model="estate.property.offer">
<field name="partner_id" ref="base.res_partner_12"/>
<field name="property_id" ref="demo_big_villa"/>
<field name="price">10000</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)"/>
<field name="partner_id" ref="base.res_partner_12" />
<field name="property_id" ref="demo_big_villa" />
<field name="price">10000</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)" />
</record>

<record id="azure_interior_big_villa_2" model="estate.property.offer">
<field name="partner_id" ref="base.res_partner_12"/>
<field name="property_id" ref="demo_big_villa"/>
<field name="price">1500000</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)"/>
<field name="partner_id" ref="base.res_partner_12" />
<field name="property_id" ref="demo_big_villa" />
<field name="price">1500000</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)" />
</record>

<record id="decco_addict_big_villa_3" model="estate.property.offer">
<field name="partner_id" ref="base.res_partner_2"/>
<field name="property_id" ref="demo_big_villa"/>
<field name="price">1500001</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)"/>
<field name="partner_id" ref="base.res_partner_2" />
<field name="property_id" ref="demo_big_villa" />
<field name="price">1500001</field>
<field name="validity">14</field>
<field name="date_deadline" eval="DateTime.now() + relativedelta(days=14)" />
</record>

<function model="estate.property.offer" name="action_accept">
<value eval="[ref('azure_interior_big_villa_1')]"/>
<value eval="[ref('azure_interior_big_villa_1')]" />
</function>

<function model="estate.property.offer" name="action_refused">
<value eval="[ref('azure_interior_big_villa_2')]"/>
<value eval="[ref('azure_interior_big_villa_2')]" />
</function>

<function model="estate.property.offer" name="action_refused">
<value eval="[ref('decco_addict_big_villa_3')]"/>
<value eval="[ref('decco_addict_big_villa_3')]" />
</function>

</odoo>

</odoo>
22 changes: 22 additions & 0 deletions estate/report/estate_property_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<record id="action_property_offer_report" model="ir.actions.report">
<field name="name">Estate Property Report</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="binding_model_id" ref="estate.model_estate_property" />
<field name="binding_type">report</field>
</record>

<record id="action_user_offer_report" model="ir.actions.report">
<field name="name">Estate User Property</field>
<field name="model">res.users</field>
<field name="report_type">qweb-html</field>
<field name="report_name">estate.report_salesperson_properties</field>
<field name="binding_model_id" ref="base.model_res_users" />
<field name="binding_type">report</field>
</record>
</data>
</odoo>
36 changes: 36 additions & 0 deletions estate/report/estate_property_subtemplate.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="estate_property_offer_subtemplate">
<table class="table">
<thead>
<tr>
<th>Price</th>
<th>Partner</th>
<th>Validity (days)</th>
<th>Deadline</th>
<th>State</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>
67 changes: 67 additions & 0 deletions estate/report/estate_property_template.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">
<h2>
<span t-field="property.name" />
</h2>
<div>
<strong>Salesman: </strong>
<span t-field="property.salesperson" />
</div>
<div>
<strong>Expected Price: </strong>
<span t-field="property.expected_price" />
</div>
<div class="state">
<strong>Status: </strong>
<span t-field="property.state" />
</div>
<t t-if="property.offer_ids">
<t t-call="estate.estate_property_offer_subtemplate" />
</t>
<t t-else="">
<p>
<b>No offer found</b>
</p>
</t>
</div>
</t>
</t>
</t>
</template>
<template id="report_salesperson_properties">
<t t-foreach="docs" t-as="user">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h2>Salesman: <span t-field="user.name" />
</h2>
<t t-foreach="user.property_ids" t-as="property">
<div>
<h3>
<span t-field="property.name" />
</h3>
<div>
<strong>Expected Price: </strong>
<span t-field="property.expected_price" />
</div>
<div>
<strong>Status: </strong>
<span t-field="property.state" />
</div>
<t t-set="offers" t-value="property.mapped('offer_ids')" />
<t t-call="estate.estate_property_offer_subtemplate">
<t t-set="offers" t-value="offers" />
</t>
</div>
</t>
</div>
</t>
</t>
</t>
</template>
</odoo>
3 changes: 2 additions & 1 deletion estate/view/estate_property_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@
<tree string="Channel" decoration-success="state in ['offer Accepted','offer Received']"
decoration-bf="state in ['offer Accepted']" decoration-muted="state=='sold'">
<header>
<button name="%(estate_add_offer_wizard_action)d" type="action" string="Add Offer" />
<button name="%(estate_add_offer_wizard_action)d" type="action"
string="Add Offer" />
</header>
<field name="name" />
<field name="postcode" />
Expand Down
7 changes: 5 additions & 2 deletions estate_account/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
'version': '1.0',
'category': 'Real Estate',
'depends': ['estate', 'account'],
'data': [],
'license': 'LGPL-3',
'data': [
'report/estate_account_report.xml',
],
'installable': True,
'application': True
'application': True,

}
12 changes: 12 additions & 0 deletions estate_account/report/estate_account_report.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<odoo>
<template id="report_property_offers_inherit" inherit_id="estate.report_property_offers">
<xpath expr="//div[@class='state']" position="after">
<t t-if="property.state == 'sold'">
<div>
<strong>!!!Invoice has been already created!!!</strong>
</div>
</t>
</xpath>
</template>
</odoo>

0 comments on commit ae252ec

Please sign in to comment.