houssine
4 years ago
9 changed files with 298 additions and 0 deletions
-
1easy_my_coop_loan_account/__init__.py
-
27easy_my_coop_loan_account/__manifest__.py
-
31easy_my_coop_loan_account/data/emc_loan_account_data.xml
-
3easy_my_coop_loan_account/models/__init__.py
-
39easy_my_coop_loan_account/models/account_move.py
-
86easy_my_coop_loan_account/models/company.py
-
65easy_my_coop_loan_account/models/loan_issue_line.py
-
22easy_my_coop_loan_account/views/loan_issue_line_view.xml
-
24easy_my_coop_loan_account/views/res_company_view.xml
@ -0,0 +1 @@ |
|||||
|
from . import models |
@ -0,0 +1,27 @@ |
|||||
|
# Copyright 2020 - ongoing Coop IT Easy SCRLfs (<http://www.coopiteasy.be>) |
||||
|
# - Houssine BAKKALI - <houssine@coopiteasy.be> |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
{ |
||||
|
"name": "Easy My Coop Loan Account", |
||||
|
"version": "12.0.1.0.0", |
||||
|
"depends": [ |
||||
|
"account", |
||||
|
"easy_my_coop_loan", |
||||
|
], |
||||
|
"author": "Coop IT Easy SCRLfs", |
||||
|
"category": "Cooperative management", |
||||
|
"website": "https://www.coopiteasy.be", |
||||
|
"license": "AGPL-3", |
||||
|
"summary": """ |
||||
|
This module brings the accounting part of the loan issue. |
||||
|
It has for purpose to generate all the accounting entries to the covered |
||||
|
use cases. |
||||
|
""", |
||||
|
"data": [ |
||||
|
"data/emc_loan_account_data.xml", |
||||
|
"views/res_company_view.xml", |
||||
|
"views/loan_issue_line_view.xml", |
||||
|
], |
||||
|
"installable": True, |
||||
|
} |
@ -0,0 +1,31 @@ |
|||||
|
<odoo> |
||||
|
<data noupdate="1"> |
||||
|
<record id="sequence_awaiting_loan_payment_journal" model="ir.sequence"> |
||||
|
<field name="name">Awaiting Loan Payment Journal</field> |
||||
|
<field eval="3" name="padding"/> |
||||
|
<field name="prefix">ALPJ/%(year)s/</field> |
||||
|
<field name="use_date_range">True</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="subscription_journal" model="account.journal"> |
||||
|
<field name="name">Awaiting Loan Payment Journal</field> |
||||
|
<field name="code">ALPJ</field> |
||||
|
<field name="type">general</field> |
||||
|
<field name="sequence_id" ref="sequence_awaiting_loan_payment_journal"/> |
||||
|
</record> |
||||
|
|
||||
|
<record id="sequence_loan_journal" model="ir.sequence"> |
||||
|
<field name="name">Loan Journal</field> |
||||
|
<field eval="3" name="padding"/> |
||||
|
<field name="prefix">LOANJ/%(year)s/</field> |
||||
|
<field name="use_date_range">True</field> |
||||
|
</record> |
||||
|
|
||||
|
<record id="loan_journal" model="account.journal"> |
||||
|
<field name="name">Loan Journal</field> |
||||
|
<field name="code">LOANJ</field> |
||||
|
<field name="type">general</field> |
||||
|
<field name="sequence_id" ref="sequence_loan_journal"/> |
||||
|
</record> |
||||
|
</data> |
||||
|
</odoo> |
@ -0,0 +1,3 @@ |
|||||
|
from . import company |
||||
|
from . import loan_issue_line |
||||
|
from . import account_move |
@ -0,0 +1,39 @@ |
|||||
|
# Copyright 2019 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 AccountMove(models.Model): |
||||
|
_inherit = "account.move" |
||||
|
|
||||
|
loan_issue_line = fields.One2many( |
||||
|
"loan.issue.line", |
||||
|
"awaiting_move_id", |
||||
|
string="Loan issue line", |
||||
|
readonly=True, |
||||
|
) |
||||
|
|
||||
|
|
||||
|
class AccountMoveLine(models.Model): |
||||
|
_inherit = "account.move.line" |
||||
|
|
||||
|
loan_issue_line = fields.One2many( |
||||
|
"loan.issue.line", |
||||
|
related="move_id.loan_issue_line", |
||||
|
) |
||||
|
|
||||
|
@api.multi |
||||
|
def check_full_reconcile(self): |
||||
|
super(AccountMoveLine, self).check_full_reconcile() |
||||
|
full_reconcile_id = self.mapped("full_reconcile_id") |
||||
|
loan_issue_line = self.mapped("loan_issue_line") |
||||
|
if full_reconcile_id and loan_issue_line: |
||||
|
for move_line in self: |
||||
|
if move_line.statement_id: |
||||
|
loan_issue_line.payment_date = move_line.date |
||||
|
loan_issue_line.with_context( |
||||
|
{"paid_by_bank_statement": True} |
||||
|
).action_paid() |
||||
|
print(full_reconcile_id) |
@ -0,0 +1,86 @@ |
|||||
|
# Copyright 2019 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 fields, models |
||||
|
|
||||
|
|
||||
|
class ResCompany(models.Model): |
||||
|
_inherit = "res.company" |
||||
|
|
||||
|
awaiting_loan_payment_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Awaiting Loan Payment Account", |
||||
|
domain=[ |
||||
|
("internal_type", "=", "receivable"), |
||||
|
("deprecated", "=", False), |
||||
|
], |
||||
|
help="This account serve to track awaiting payment." |
||||
|
" It only serve a bank reconciliation purpose to register the awaiting" |
||||
|
" loan payment as received/paid", |
||||
|
required=True, |
||||
|
) |
||||
|
loaner_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Loaner Account", |
||||
|
help="This account will be the default one as the" |
||||
|
" receivable account for the cooperators", |
||||
|
required=True, |
||||
|
) |
||||
|
expense_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Expense Account", |
||||
|
help="This account is used to register the loan debt due for more" |
||||
|
" than one year", |
||||
|
required=True, |
||||
|
) |
||||
|
debt_long_term_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Long Term Debt Account", |
||||
|
help="This account is used to register the loan debt due for more" |
||||
|
" than one year", |
||||
|
required=True, |
||||
|
) |
||||
|
debt_short_term_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Short Term Debt Account", |
||||
|
help="This account is used to register the loan debt due for the" |
||||
|
" current fiscal year", |
||||
|
required=True, |
||||
|
old_name="debt_short_term_account", |
||||
|
) |
||||
|
interest_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Interest Account", |
||||
|
help="This account is used to register the due loan interest", |
||||
|
required=True, |
||||
|
) |
||||
|
tax_account = fields.Many2one( |
||||
|
"account.account", |
||||
|
company_dependent=True, |
||||
|
string="Tax Account", |
||||
|
help="This account is used to register the tax to pay" |
||||
|
" to the tax administration", |
||||
|
required=True, |
||||
|
) |
||||
|
awaiting_loan_payment_journal = fields.Many2one( |
||||
|
"account.journal", |
||||
|
string="Awaiting loan payment journal", |
||||
|
help="This journal will be the default one as the" |
||||
|
" to track the payment from the loaners", |
||||
|
required=True, |
||||
|
) |
||||
|
loan_journal = fields.Many2one( |
||||
|
"account.journal", |
||||
|
string="Loan journal", |
||||
|
help="This journal will be the one used to register all" |
||||
|
" the loan account move lines", |
||||
|
required=True, |
||||
|
) |
@ -0,0 +1,65 @@ |
|||||
|
# Copyright 2019 Coop IT Easy SCRL fs |
||||
|
# Houssine BAKKALI <houssine@coopiteasy.be> |
||||
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). |
||||
|
|
||||
|
from datetime import date |
||||
|
|
||||
|
from odoo import api, fields, models, _ |
||||
|
from odoo.exceptions import UserError |
||||
|
|
||||
|
|
||||
|
class LoanIssueLine(models.Model): |
||||
|
_inherit = "loan.issue.line" |
||||
|
|
||||
|
awaiting_move_id = fields.Many2one( |
||||
|
"account.move", |
||||
|
string="Awaiting payment account move" |
||||
|
) |
||||
|
|
||||
|
@api.multi |
||||
|
def get_loan_move_line(self, move_id): |
||||
|
self.ensure_one() |
||||
|
move_line = { |
||||
|
"partner_id": self.partner_id.id, |
||||
|
"date_maturity": date.today(), |
||||
|
"move_id": move_id, |
||||
|
} |
||||
|
return move_line |
||||
|
|
||||
|
@api.multi |
||||
|
def create_waiting_payment_moves(self): |
||||
|
move_obj = self.env["account.move"] |
||||
|
move_line_obj = self.env["account.move.line"] |
||||
|
for line in self: |
||||
|
company = line.company_id |
||||
|
move_vals = { |
||||
|
"ref": line.reference, |
||||
|
"date": date.today(), |
||||
|
"journal_id": company.awaiting_loan_payment_journal.id, |
||||
|
} |
||||
|
move = move_obj.create(move_vals) |
||||
|
loan_vals = line.get_loan_move_line(move.id) |
||||
|
loaner_vals = line.get_loan_move_line(move.id) |
||||
|
|
||||
|
loan_vals["account_id"] = company.debt_long_term_account.id |
||||
|
loan_vals["credit"] = line.amount |
||||
|
|
||||
|
loaner_vals["account_id"] = company.awaiting_loan_payment_account.id |
||||
|
loaner_vals["debit"] = line.amount |
||||
|
|
||||
|
move_line_obj.create([loan_vals, loaner_vals]) |
||||
|
line.awaiting_move_id = move |
||||
|
|
||||
|
@api.multi |
||||
|
def action_request_payment(self): |
||||
|
self.create_waiting_payment_moves() |
||||
|
super(LoanIssueLine, self).action_request_payment() |
||||
|
|
||||
|
@api.multi |
||||
|
def action_paid(self): |
||||
|
paid_by = self.env.context.get("paid_by_bank_statement") |
||||
|
if paid_by: |
||||
|
super(LoanIssueLine, self).action_paid() |
||||
|
else: |
||||
|
raise UserError(_("The payment must be registered" |
||||
|
" by bank statement")) |
@ -0,0 +1,22 @@ |
|||||
|
<odoo> |
||||
|
|
||||
|
<record id="view_loan_issue_line_account_form" model="ir.ui.view"> |
||||
|
<field name="name">loan.issue.line.form</field> |
||||
|
<field name="model">loan.issue.line</field> |
||||
|
<field name="inherit_id" ref="easy_my_coop_loan.view_loan_issue_line_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<page name="interest_lines" position="after"> |
||||
|
<page name="accounting" string="Accounting"> |
||||
|
<group> |
||||
|
<group> |
||||
|
<field name="awaiting_move_id" readonly="True"/> |
||||
|
</group> |
||||
|
<group> |
||||
|
</group> |
||||
|
</group> |
||||
|
</page> |
||||
|
</page> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</odoo> |
@ -0,0 +1,24 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<odoo> |
||||
|
<record model="ir.ui.view" id="view_company_easy_my_coop_loan"> |
||||
|
<field name="name">res.company.form.easymy.coop</field> |
||||
|
<field name="inherit_id" ref="easy_my_coop.view_company_inherit_form2"/> |
||||
|
<field name="model">res.company</field> |
||||
|
<field name="arch" type="xml"> |
||||
|
<group name="coop_grp" position="before"> |
||||
|
<group name="coop_loan_grp" string="EasyMy Coop Loan" |
||||
|
groups="easy_my_coop.group_easy_my_coop_user"> |
||||
|
<field name="awaiting_loan_payment_account"/> |
||||
|
<field name="loaner_account"/> |
||||
|
<field name="expense_account"/> |
||||
|
<field name="debt_long_term_account"/> |
||||
|
<field name="debt_short_term_account"/> |
||||
|
<field name="interest_account"/> |
||||
|
<field name="tax_account"/> |
||||
|
<field name="awaiting_loan_payment_journal"/> |
||||
|
<field name="loan_journal"/> |
||||
|
</group> |
||||
|
</group> |
||||
|
</field> |
||||
|
</record> |
||||
|
</odoo> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue