houssine
4 years ago
4 changed files with 92 additions and 12 deletions
-
24easy_my_coop_loan_account/models/account_fiscal_year.py
-
1easy_my_coop_loan_account/wizard/__init__.py
-
44easy_my_coop_loan_account/wizard/end_of_year_operation.py
-
35easy_my_coop_loan_account/wizard/end_of_year_operation.xml
@ -0,0 +1 @@ |
|||||
|
from . import end_of_year_operation |
@ -0,0 +1,44 @@ |
|||||
|
# Copyright 2020 Coop IT Easy SCRL fs |
||||
|
# Houssine BAKKALI <houssine@coopiteasy.be> |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
from odoo import api, fields, models |
||||
|
|
||||
|
|
||||
|
class LoanEndOfYearOperation(models.TransientModel): |
||||
|
_name = "loan.end.of.year.operation" |
||||
|
|
||||
|
operation_type = fields.Selection( |
||||
|
[("eoy_debt", "End of year debt operation"), |
||||
|
("eoy_interest", "End of year interest operation")], |
||||
|
required=True, |
||||
|
string="Operation type" |
||||
|
) |
||||
|
ongoing_fy_id = fields.Many2one( |
||||
|
comodel_name="account.fiscal.year", |
||||
|
string="Ongoing fiscal year", |
||||
|
required=True |
||||
|
) |
||||
|
|
||||
|
@api.multi |
||||
|
def run(self): |
||||
|
afy_obj = self.env["account.fiscal.year"] |
||||
|
|
||||
|
loan_issues = self.env["loan.issue"].browse( |
||||
|
self._context.get("active_ids") |
||||
|
) |
||||
|
|
||||
|
last_fy_day = self.ongoing_fy_id.date_to |
||||
|
next_fy = afy_obj.get_next_fiscal_year(last_fy_day) |
||||
|
|
||||
|
if self.operation_type == "debt_eoy": |
||||
|
if next_fy: |
||||
|
interest_lines = self.search([ |
||||
|
('due_date', '>=', next_fy.date_from), |
||||
|
('due_date', '<=', next_fy.date_to), |
||||
|
('due_loan_amount', '>', 0), |
||||
|
("loan_issue_id", "in", loan_issues.ids) |
||||
|
]) |
||||
|
|
||||
|
interest_lines.generate_loan_due_fy(last_fy_day) |
||||
|
elif self.operation_type == "eoy_interest": |
||||
|
print() |
@ -0,0 +1,35 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<odoo> |
||||
|
<record id="view_loan_end_of_year_operation" model="ir.ui.view"> |
||||
|
<field name="name">End of year loan operation</field> |
||||
|
<field name="model">loan.end.of.year.operation</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<form string="End of year loan operation"> |
||||
|
<p class="oe_grey"> |
||||
|
End of year loan operation. |
||||
|
</p> |
||||
|
<group> |
||||
|
<field name="operation_type"/> |
||||
|
<field name="ongoing_fy_id"/> |
||||
|
</group> |
||||
|
<footer> |
||||
|
<button name="run" string="Run" type="object" |
||||
|
class="btn-primary"/> |
||||
|
<button string="Cancel" class="btn-default" |
||||
|
special="cancel"/> |
||||
|
</footer> |
||||
|
</form> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<act_window id="action_view_loan_end_of_year_operation" |
||||
|
multi="True" |
||||
|
key2="client_action_multi" |
||||
|
name="End of year loan operation" |
||||
|
res_model="loan.end.of.year.operation" |
||||
|
src_model="loan.issue" |
||||
|
view_mode="form" |
||||
|
view_type="form" |
||||
|
target="new" |
||||
|
groups="easy_my_coop.group_easy_my_coop_manager"/> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue