Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP][14.0]account_loan: add loan lines menu item #1730

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions account_loan/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"wizard/account_loan_post_view.xml",
"views/account_loan_view.xml",
"views/account_move_view.xml",
"views/account_loan_lines_view.xml",
],
"installable": True,
"external_dependencies": {
Expand Down
21 changes: 21 additions & 0 deletions account_loan/model/account_loan_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class AccountLoanLine(models.Model):
readonly=True,
ondelete="cascade",
)
company_id = fields.Many2one(
"res.company", readonly=True, related="loan_id.company_id"
)
partner_id = fields.Many2one(
"res.partner", readonly=True, related="loan_id.partner_id"
)
is_leasing = fields.Boolean(
related="loan_id.is_leasing",
readonly=True,
Expand All @@ -49,6 +55,21 @@ class AccountLoanLine(models.Model):
readonly=True,
related="loan_id.long_term_loan_account_id",
)
journal_id = fields.Many2one(
"account.journal",
readonly=True,
related="loan_id.journal_id",
)
short_term_loan_account_id = fields.Many2one(
"account.account",
readonly=True,
related="loan_id.short_term_loan_account_id",
)
interest_expenses_account_id = fields.Many2one(
"account.account",
readonly=True,
related="loan_id.interest_expenses_account_id",
)
currency_id = fields.Many2one(
"res.currency",
related="loan_id.currency_id",
Expand Down
65 changes: 65 additions & 0 deletions account_loan/views/account_loan_lines_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="account_loan_lines_view" model="ir.ui.view">
<field name="name">account.loan.lines.view</field>
<field name="model">account.loan.line</field>
<field name="arch" type="xml">
<tree create="0" import="0">
<field name="sequence" />
<field name="loan_id" />
<field name="date" />
<field name="rate" />
<field name="pending_principal_amount" />
<field name="payment_amount" />
<field name="principal_amount" />
<field name="interests_amount" />
<field name="long_term_pending_principal_amount" />
<field name="long_term_principal_amount" />
<field name="company_id" optional="hide" />
<field name="partner_id" optional="hide" />
<field name="journal_id" optional="hide" />
<field name="short_term_loan_account_id" optional="hide" />
<field name="long_term_loan_account_id" optional="hide" />
<field name="interest_expenses_account_id" optional="hide" />
<groupby name="loan_id">
<button name="edit" type="edit" icon="fa-edit" title="Edit" />
</groupby>
</tree>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
</tree>
<groupby name="loan_id">
<button name="edit" type="edit" icon="fa-edit" title="Edit"/>
</groupby>
</tree>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the advices. Now it shown the edit button when grouping.

</field>
</record>

<record id="view_account_loan_lines_search" model="ir.ui.view">
<field name="name">Loan Items</field>
<field name="model">account.loan.line</field>
<field name="arch" type="xml">
<search>
<field name="loan_id" />
<field name="partner_id" />
<group expand='0' string='Group by...'>
<filter
string='Loan'
name="group_by_loan_id"
context="{'group_by': 'loan_id'}"
/>
</group>
</search>
</field>
</record>

<record id="account_loan_lines_action" model="ir.actions.act_window">
<field name="name">Loan Items</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.loan.line</field>
<field name="view_mode">tree,pivot,graph</field>
<field name="view_id" ref="account_loan_lines_view" />
<field name="context">{'search_default_group_by_loan_id': 1}</field>
</record>

<menuitem
id="account_loan_lines_menu"
parent="loan_menu"
sequence="20"
name="Loan Items"
action="account_loan_lines_action"
/>
</odoo>
12 changes: 10 additions & 2 deletions account_loan/views/account_loan_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,18 @@
<field name="name">Loans</field>
<field name="res_model">account.loan</field>
</record>

<menuitem
id="account_loan_menu"
id="loan_menu"
name="Loans"
parent="account.menu_finance_entries"
sequence="80"
sequence="75"
/>

<menuitem
id="account_loan_menu"
parent="loan_menu"
sequence="10"
name="Loans"
action="account_loan_action"
/>
Expand Down
Loading