316 lines
17 KiB
XML
316 lines
17 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<odoo>
|
|
|
|
<!-- ==================================================================
|
|
Loans
|
|
================================================================== -->
|
|
|
|
<record id="dn_loan_form_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.form</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<form string="Loan">
|
|
<header>
|
|
<button name="action_confirm" string="Confirm" type="object"
|
|
class="btn-primary" groups="account.group_account_invoice"
|
|
invisible="state != 'draft'" data-hotkey="q"/>
|
|
<button name="action_open_compute_wizard" string="Compute Schedule"
|
|
type="object" class="btn-secondary"
|
|
groups="account.group_account_manager"
|
|
invisible="state != 'draft'"/>
|
|
<button name="action_upload_amortization_schedule" string="Import"
|
|
type="object" class="btn-secondary"
|
|
groups="account.group_account_manager"
|
|
invisible="state != 'draft'"/>
|
|
<button name="action_reset_schedule" string="Clear Schedule"
|
|
type="object" class="btn-secondary"
|
|
groups="account.group_account_manager"
|
|
invisible="state != 'draft' or not line_ids"
|
|
confirm="This deletes the whole amortization schedule. Continue?"/>
|
|
<button name="action_close" string="Close" type="object"
|
|
class="btn-secondary" groups="account.group_account_manager"
|
|
invisible="state != 'running'"/>
|
|
<button name="action_cancel" string="Cancel" type="object"
|
|
class="btn-secondary" groups="account.group_account_manager"
|
|
invisible="state != 'running'"
|
|
confirm="The generated entries will be reversed. Continue?"/>
|
|
<button name="action_set_to_draft" string="Set to Draft" type="object"
|
|
class="btn-secondary" groups="account.group_account_manager"
|
|
invisible="state in ('draft', 'running')"/>
|
|
<button name="action_reopen" string="Reopen" type="object"
|
|
class="btn-secondary" groups="account.group_account_manager"
|
|
invisible="state != 'closed'"/>
|
|
<field name="state" widget="statusbar"
|
|
statusbar_visible="draft,running,closed"/>
|
|
</header>
|
|
<sheet>
|
|
<div class="oe_button_box" name="button_box">
|
|
<button class="oe_stat_button" icon="fa-list-alt" type="object"
|
|
name="action_open_loan_entries"
|
|
invisible="state == 'draft'">
|
|
<field string="Posted Entries" name="nb_posted_entries"
|
|
widget="statinfo"/>
|
|
</button>
|
|
</div>
|
|
<!-- Needed so the company and its currency are available
|
|
when the record is still being created. -->
|
|
<field name="company_id" invisible="1"/>
|
|
<field name="currency_id" invisible="1"/>
|
|
<field name="is_wrong_date" invisible="1"/>
|
|
<field name="amount_borrowed_difference" invisible="1"/>
|
|
<field name="interest_difference" invisible="1"/>
|
|
<field name="duration_difference" invisible="1"/>
|
|
<div class="oe_title">
|
|
<label for="name"/>
|
|
<h1>
|
|
<field name="name" placeholder="Loan name"/>
|
|
</h1>
|
|
</div>
|
|
<group>
|
|
<group>
|
|
<field name="amount_borrowed" widget="monetary"
|
|
readonly="state != 'draft'"
|
|
decoration-danger="amount_borrowed_difference != 0"/>
|
|
<field name="interest" widget="monetary"
|
|
readonly="state != 'draft'"
|
|
decoration-danger="interest_difference != 0"/>
|
|
<field name="outstanding_balance" widget="monetary"/>
|
|
</group>
|
|
<group>
|
|
<field name="date" readonly="state != 'draft'"
|
|
decoration-danger="is_wrong_date"/>
|
|
<label for="duration"/>
|
|
<div class="o_row">
|
|
<field name="duration" readonly="state != 'draft'"
|
|
decoration-danger="duration_difference != 0"
|
|
class="oe_inline"/>
|
|
<div class="text-muted ms-1 oe_inline"
|
|
invisible="duration != 1">month</div>
|
|
<div class="text-muted ms-1 oe_inline"
|
|
invisible="duration == 1">months</div>
|
|
</div>
|
|
<field name="method" readonly="state != 'draft'"/>
|
|
</group>
|
|
</group>
|
|
<field name="loan_properties" columns="2"/>
|
|
<notebook>
|
|
<page string="Amortization Schedule" name="schedule">
|
|
<field name="line_ids" readonly="state != 'draft'"
|
|
context="{'default_loan_id': id}">
|
|
<list editable="bottom" limit="120"
|
|
decoration-info="not is_payment_move_posted"
|
|
decoration-muted="is_payment_move_posted">
|
|
<field name="currency_id" column_invisible="1"/>
|
|
<field name="sequence" width="40px"/>
|
|
<field name="date"/>
|
|
<field name="principal" sum="Total Principal"/>
|
|
<field name="interest" sum="Total Interest"/>
|
|
<field name="payment" sum="Total Payment"/>
|
|
<field name="outstanding_balance"/>
|
|
<field name="long_term_theoretical_balance"
|
|
optional="show"/>
|
|
<field name="short_term_theoretical_balance"
|
|
optional="show"/>
|
|
<field name="is_payment_move_posted"
|
|
widget="boolean_toggle" optional="hide"/>
|
|
</list>
|
|
</field>
|
|
</page>
|
|
<page string="Settings" name="settings">
|
|
<group>
|
|
<group string="Accounts">
|
|
<field name="long_term_account_id"
|
|
readonly="state != 'draft'"
|
|
options="{'no_create': True}"/>
|
|
<field name="short_term_account_id"
|
|
readonly="state != 'draft'"
|
|
options="{'no_create': True}"/>
|
|
<field name="expense_account_id"
|
|
readonly="state != 'draft'"
|
|
options="{'no_create': True}"/>
|
|
</group>
|
|
<group string="Booking">
|
|
<field name="journal_id" readonly="state != 'draft'"
|
|
options="{'no_create': True}"/>
|
|
<field name="skip_until_date"
|
|
readonly="state != 'draft'"
|
|
placeholder="No installment skipped"/>
|
|
<field name="analytic_distribution"
|
|
widget="analytic_distribution"
|
|
readonly="state != 'draft'"/>
|
|
<field name="company_id" groups="base.group_multi_company"
|
|
readonly="1" force_save="1"/>
|
|
</group>
|
|
</group>
|
|
</page>
|
|
</notebook>
|
|
</sheet>
|
|
<chatter/>
|
|
</form>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="dn_loan_list_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.list</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<list string="Loans"
|
|
decoration-info="state == 'draft'"
|
|
decoration-muted="state in ('closed', 'cancelled')">
|
|
<field name="currency_id" column_invisible="1"/>
|
|
<field name="name"/>
|
|
<field name="date" string="Start Date"/>
|
|
<field name="end_date"/>
|
|
<field name="amount_borrowed" sum="Total Amounts Borrowed"/>
|
|
<field name="outstanding_balance" sum="Total Outstanding Balance"/>
|
|
<field name="state" widget="badge"
|
|
decoration-info="state == 'draft'"
|
|
decoration-success="state == 'running'"
|
|
decoration-danger="state in ('closed', 'cancelled')"/>
|
|
<field name="method" optional="hide"/>
|
|
<field name="long_term_account_id" optional="hide"/>
|
|
<field name="short_term_account_id" optional="hide"/>
|
|
<field name="expense_account_id" optional="hide"/>
|
|
<field name="company_id" groups="base.group_multi_company"
|
|
optional="hide"/>
|
|
</list>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="dn_loan_kanban_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.kanban</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<kanban class="o_kanban_mobile" sample="1">
|
|
<field name="currency_id"/>
|
|
<templates>
|
|
<t t-name="card">
|
|
<div class="row mb-2">
|
|
<field name="name" class="fw-bold fs-5 col-9"/>
|
|
<div class="col-3 text-end">
|
|
<field name="state" widget="label_selection"
|
|
options="{'classes': {'draft': 'primary',
|
|
'running': 'success',
|
|
'closed': 'secondary',
|
|
'cancelled': 'danger'}}"/>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<field name="amount_borrowed" widget="monetary"/>
|
|
</div>
|
|
<div class="col-6 text-end text-muted">
|
|
<field name="date"/>
|
|
</div>
|
|
</div>
|
|
<div class="row mt-1">
|
|
<div class="col-12 text-muted">
|
|
<div class="oe_inline">Outstanding: </div>
|
|
<field name="outstanding_balance" widget="monetary"/>
|
|
</div>
|
|
</div>
|
|
</t>
|
|
</templates>
|
|
</kanban>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="dn_loan_search_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.search</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<search string="Search Loan">
|
|
<field name="name" string="Loan"
|
|
filter_domain="['|', ('name', 'ilike', self),
|
|
('display_name', 'ilike', self)]"/>
|
|
<field name="loan_properties"/>
|
|
<filter string="Current" name="current"
|
|
domain="[('state', 'in', ('draft', 'running'))]"
|
|
help="Draft and running loans"/>
|
|
<filter string="Running" name="running"
|
|
domain="[('state', '=', 'running')]"/>
|
|
<filter string="Closed" name="closed"
|
|
domain="[('state', '=', 'closed')]"/>
|
|
<separator/>
|
|
<filter string="Loan Date" name="loan_date" date="date"/>
|
|
<group>
|
|
<filter string="Status" name="group_state" domain="[]"
|
|
context="{'group_by': 'state'}"/>
|
|
<filter string="Method" name="group_method" domain="[]"
|
|
context="{'group_by': 'method'}"/>
|
|
<filter string="Loan Date" name="group_date" domain="[]"
|
|
context="{'group_by': 'date'}"/>
|
|
</group>
|
|
</search>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="dn_loan_pivot_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.pivot</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<pivot sample="1">
|
|
<field name="date" interval="year" type="col"/>
|
|
<field name="name" type="row"/>
|
|
<field name="amount_borrowed" type="measure"/>
|
|
</pivot>
|
|
</field>
|
|
</record>
|
|
|
|
<record id="dn_loan_graph_view" model="ir.ui.view">
|
|
<field name="name">dn.loan.graph</field>
|
|
<field name="model">dn.loan</field>
|
|
<field name="arch" type="xml">
|
|
<graph type="line" sample="1">
|
|
<field name="date" interval="year"/>
|
|
<field name="name"/>
|
|
<field name="amount_borrowed" type="measure"/>
|
|
<field name="interest" type="measure"/>
|
|
</graph>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- ==================================================================
|
|
Actions
|
|
================================================================== -->
|
|
|
|
<record id="action_dn_loan" model="ir.actions.act_window">
|
|
<field name="name">Loans</field>
|
|
<field name="res_model">dn.loan</field>
|
|
<field name="search_view_id" ref="dn_loan_search_view"/>
|
|
<field name="context">{'search_default_current': 1}</field>
|
|
<field name="view_ids" eval="[(5, 0, 0),
|
|
(0, 0, {'view_mode': 'list', 'view_id': ref('dn_loan_list_view')}),
|
|
(0, 0, {'view_mode': 'form', 'view_id': ref('dn_loan_form_view')}),
|
|
(0, 0, {'view_mode': 'kanban', 'view_id': ref('dn_loan_kanban_view')}),
|
|
(0, 0, {'view_mode': 'pivot', 'view_id': ref('dn_loan_pivot_view')}),
|
|
(0, 0, {'view_mode': 'graph', 'view_id': ref('dn_loan_graph_view')}),
|
|
]"/>
|
|
<field name="help" type="html">
|
|
<p class="o_view_nocontent_smiling_face">
|
|
Record your first loan
|
|
</p>
|
|
<p>
|
|
Enter the amount, the rate and the term, then let the schedule be
|
|
computed: the interest and principal entries are posted
|
|
automatically, and the part of the principal falling due within a
|
|
year is reclassified to the short term account every month.
|
|
</p>
|
|
</field>
|
|
</record>
|
|
|
|
<!-- ==================================================================
|
|
Menus
|
|
================================================================== -->
|
|
|
|
<!-- Under "Assets & Liabilities", next to the assets: a loan is the mirror
|
|
image of an asset, so it belongs in the same group. Sequence 62 is what
|
|
Enterprise uses, leaving 60 for the asset register. -->
|
|
<menuitem id="menu_dn_loan"
|
|
action="action_dn_loan"
|
|
parent="accountant_cn.account_assets_liabilities_menu"
|
|
sequence="62"
|
|
groups="account.group_account_readonly"/>
|
|
|
|
</odoo>
|