Initial commit on branch odoo_DuyDat

This commit is contained in:
Duy Dat
2025-06-13 14:20:29 +07:00
commit 7819a1d6db
228 changed files with 4502 additions and 0 deletions
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Gayathri V (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
from . import loan_management_reports
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
################################################################################
#
# Cybrosys Technologies Pvt. Ltd.
#
# Copyright (C) 2025-TODAY Cybrosys Technologies(<https://www.cybrosys.com>).
# Author: Gayathri V (odoo@cybrosys.com)
#
# You can modify it under the terms of the GNU AFFERO
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details.
#
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
# (AGPL v3) along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
from odoo import api, models
class LoanDetails(models.AbstractModel):
"""fetch pdf report values"""
_name = 'report.advanced_loan_management.loan_report_template'
@api.model
def _get_report_values(self, doc_ids, data=None):
loan_id = self.env['loan.request'].browse(doc_ids)
data = {
'Loan_id': loan_id.id,
'Customer': loan_id.partner_id.name,
'CustomerAddress': f"{loan_id.partner_id.street} "
f"{loan_id.partner_id.city}" if loan_id.partner_id.city
else '',
'CustomerAddress2': f"{loan_id.partner_id.city}, "
f"{loan_id.partner_id.state_id.name}" if
loan_id.partner_id.city and loan_id.partner_id.state_id.name
else '',
'CustomerContact': loan_id.partner_id.phone,
'Loan_Type': loan_id.loan_type_id.name,
'Tenure': loan_id.tenure,
'Tenure_type': loan_id.loan_type_id.tenure_plan,
'Interest_Rate': str(loan_id.interest_rate * 100),
'Loan_Amount': str(loan_id.loan_amount),
}
"""Fetching values for the report using query and returns the value"""
query = """SELECT name as Name, date as Date, amount as Amount,
interest_amount as Interest_amount,state as State,
total_amount as Total_amount FROM repayment_line"""
check = """WHERE"""
condition = """loan_id='{cust}'""".format(cust=loan_id.id)
query = """{} {} {}""".format(query, check, condition)
self.env.cr.execute(query)
record = self.env.cr.dictfetchall()
record_sort = sorted(record, key=lambda x: x['date'])
return {
'docs': record_sort,
'doc_ids': doc_ids,
'data': data,
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDF report action-->
<record id="loan_management_report_action" model="ir.actions.report">
<field name="name">Loan Request</field>
<field name="model">loan.request</field>
<field name="report_type">qweb-pdf</field>
<field name="report_name">advanced_loan_management.loan_report_template</field>
<field name="report_file">advanced_loan_management.loan_report_template</field>
<field name="binding_model_id" ref="model_loan_request"/>
<field name="binding_type">report</field>
</record>
</odoo>
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- PDF report Template-->
<template id="loan_report_template">
<t t-call="web.html_container">
<t t-call="web.external_layout">
<div class="page">
<h3 align="center">Loan Report</h3>
<div>
<group>
<strong>Name:</strong>
<span t-esc="data['Customer']"/>
<br/>
<span t-esc="data['CustomerAddress']"/>
<br/>
<span t-esc="data['CustomerAddress2']"/>
<br/>
<span t-esc="data['CustomerContact']"/>
<br/>
</group>
</div>
<group>
<table class="table table-sm">
<thead>
<tr>
<th>Loan Type</th>
<th>Tenure</th>
<th>Loan Amount</th>
<th>Interest Rate</th>
</tr>
</thead>
<tbody>
<td align="center">
<t t-esc="data['Loan_Type']"/>
</td>
<td align="center">
<t t-esc="data['Tenure']"/>
</td>
<td align="center">
<t t-esc="data['Loan_Amount']"/>
</td>
<td align="center">
<t t-esc="data['Interest_Rate']"/> %
</td>
</tbody>
</table>
</group>
<br/>
<br/>
<h3 align="center">Amortization Schedule</h3>
<table class="table table-sm">
<thead>
<tr>
<th>SI.No</th>
<th>Name</th>
<th>Date</th>
<th>Amount</th>
<th>Interest Amount</th>
<th>Total Amount</th>
<th>State</th>
</tr>
</thead>
<tbody>
<t t-set="i" t-value="1"/>
<tr t-foreach="docs" t-as="line">
<td align="center">
<span t-esc="i"/>
<t t-set="i" t-value="i+1"/>
</td>
<td align="center">
<t t-esc="line['name']"/>
</td>
<td align="center">
<t t-esc="line['date']"/>
</td>
<td align="center">
<t t-esc="line['amount']"/>
</td>
<td align="center">
<t t-esc="line['interest_amount']"/>
</td>
<td align="center">
<t t-esc="line['total_amount']"/>
</td>
<td align="center"
t-att-style="'color: ' + ('green' if line['state'] == 'paid' else ('sienna' if line['state'] == 'invoiced' else 'red'))">
<t t-esc="{'unpaid': 'Unpaid', 'invoiced': 'Invoiced', 'paid': 'Paid'} [line['state']]"/>
</td>
</tr>
</tbody>
</table>
</div>
</t>
</t>
</template>
</odoo>