-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from kmee/16.0-add-account_statement_import_of…
…x_invert_type [ADD] Addon: account_statement_import_ofx_invert_type
- Loading branch information
Showing
10 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
======================================== | ||
Account Statement Import Ofx Invert Type | ||
======================================== | ||
|
||
KMEE | ||
|
||
Purpose | ||
======= | ||
|
||
This module does this and that... | ||
|
||
Explain the use case. | ||
|
||
Configuration | ||
============= | ||
|
||
To configure this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
Usage | ||
===== | ||
|
||
To use this module, you need to: | ||
|
||
#. Go to ... | ||
|
||
|
||
How to test | ||
=========== | ||
|
||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import wizards | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Statement Import Ofx Invert Type", | ||
"summary": """KMEE""", | ||
"version": "16.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "KMEE,Odoo Community Association (OCA)", | ||
"website": "https://github.com/KMEE/kmee-odoo-addons", | ||
"depends": [ | ||
"account_statement_import_ofx", | ||
], | ||
"data": [ | ||
"views/account_journal.xml", | ||
], | ||
"demo": [], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_journal |
12 changes: 12 additions & 0 deletions
12
account_statement_import_ofx_invert_type/models/account_journal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class AccountJournal(models.Model): | ||
|
||
_inherit = "account.journal" | ||
|
||
reverse_balance_of_entries_ofx = fields.Boolean() | ||
ignore_ofx_balance = fields.Boolean() |
19 changes: 19 additions & 0 deletions
19
account_statement_import_ofx_invert_type/views/account_journal.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 KMEE | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
|
||
<record model="ir.ui.view" id="account_journal_form_view"> | ||
<field name="model">account.journal</field> | ||
<field name="inherit_id" ref="account.view_account_journal_form" /> | ||
<field name="arch" type="xml"> | ||
<field name="account_control_ids" position="after"> | ||
<field | ||
name="reverse_balance_of_entries_ofx" | ||
string="Reverse Balance Of Entries OFX" | ||
/> | ||
<field name="ignore_ofx_balance" string="Ignore OFX Balance" /> | ||
</field> | ||
</field> | ||
</record> | ||
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import account_statement_import |
44 changes: 44 additions & 0 deletions
44
account_statement_import_ofx_invert_type/wizards/account_statement_import.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from decimal import Decimal | ||
|
||
from odoo import api, models | ||
|
||
|
||
class AccountStatementImport(models.TransientModel): | ||
|
||
_inherit = "account.statement.import" | ||
|
||
@api.model | ||
def _check_ofx(self, data_file): | ||
ofx = super()._check_ofx(data_file) | ||
journal_id = self.env["account.journal"].browse( | ||
self.env.context.get("journal_id") | ||
) | ||
reverse_balance_of_entries_ofx = journal_id.reverse_balance_of_entries_ofx | ||
ignore_ofx_balance = journal_id.ignore_ofx_balance | ||
if ofx and journal_id: | ||
if ignore_ofx_balance: | ||
last_statement = self.env["account.bank.statement"].search( | ||
[("journal_id", "=", journal_id.id)], limit=1, order="date asc" | ||
) | ||
balance = Decimal(last_statement.balance_end_real) | ||
for transaction in ofx.account.statement.transactions: | ||
if reverse_balance_of_entries_ofx: | ||
if transaction.type == "credit": | ||
transaction.type = "debit" | ||
elif transaction.type == "debit": | ||
transaction.type = "credit" | ||
transaction.amount = transaction.amount * (-1) | ||
else: | ||
pass | ||
|
||
if ignore_ofx_balance: | ||
balance += transaction.amount | ||
|
||
if ignore_ofx_balance: | ||
ofx.account.statement.balance = balance | ||
if not last_statement: | ||
ofx.account.statement.balance = False | ||
return ofx |
1 change: 1 addition & 0 deletions
1
...unt_statement_import_ofx_invert_type/odoo/addons/account_statement_import_ofx_invert_type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../account_statement_import_ofx_invert_type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import setuptools | ||
|
||
setuptools.setup( | ||
setup_requires=['setuptools-odoo'], | ||
odoo_addon=True, | ||
) |