-
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.
[ADD] Addon: account_statement_import_ofx_invert_type
- Loading branch information
Showing
10 changed files
with
163 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", | ||
"website": "https://github.com/KMEE/kmee-odoo-addons", | ||
"depends": [ | ||
"account_statement_import_ofx", | ||
], | ||
"data": [ | ||
"views/res_config_settings.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 res_config_settings |
35 changes: 35 additions & 0 deletions
35
account_statement_import_ofx_invert_type/models/res_config_settings.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,35 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResConfigSettings(models.TransientModel): | ||
|
||
_inherit = "res.config.settings" | ||
|
||
flip_transactions_ofx = fields.Boolean( | ||
string="Enable Transaction Flip", | ||
help="""Enable or disable the feature to flip credit/debit | ||
transaction types during OFX import.""", | ||
) | ||
|
||
def set_values(self): | ||
super().set_values() | ||
self.env["ir.config_parameter"].sudo().set_param( | ||
"account_statement_import_ofx_invert_type.flip_transactions_ofx", | ||
str(self.flip_transactions_ofx), | ||
) | ||
|
||
def get_values(self): | ||
res = super(ResConfigSettings, self).get_values() | ||
res.update( | ||
flip_transactions_ofx=self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param( | ||
"account_statement_import_ofx_invert_type.flip_transactions_ofx", | ||
default="False", | ||
) | ||
== "True" | ||
) | ||
return res |
33 changes: 33 additions & 0 deletions
33
account_statement_import_ofx_invert_type/views/res_config_settings.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,33 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!-- Copyright 2024 KMEE | ||
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). --> | ||
<odoo> | ||
<record id="view_account_statement_import_config" model="ir.ui.view"> | ||
<field | ||
name="name" | ||
>res.config.settings.view.form.inherit.account_statement_import</field> | ||
<field name="model">res.config.settings</field> | ||
<field name="inherit_id" ref="account.res_config_settings_view_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//div[div[field[@name='module_account_bank_statement_import_ofx']]]" | ||
position="after" | ||
> | ||
<div class="col-12 col-lg-6 o_setting_box" title=""> | ||
<div class="o_setting_left_pane"> | ||
<field name="flip_transactions_ofx" /> | ||
</div> | ||
<div class="o_setting_right_pane"> | ||
<label | ||
for="flip_transactions_ofx" | ||
string="Flip Transactions OFX" | ||
/> | ||
<div class="text-muted"> | ||
Flip transactions statements in OFX | ||
</div> | ||
</div> | ||
</div> | ||
</xpath> | ||
</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 |
34 changes: 34 additions & 0 deletions
34
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,34 @@ | ||
# Copyright 2024 KMEE | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
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) | ||
flip_transactions_ofx = ( | ||
self.env["ir.config_parameter"] | ||
.sudo() | ||
.get_param( | ||
"account_statement_import_ofx_invert_type.flip_transactions_ofx", | ||
default="False", | ||
) | ||
== "True" | ||
) | ||
if ofx and flip_transactions_ofx: | ||
for transaction in ofx.account.statement.transactions: | ||
if transaction.type == "credit": | ||
transaction.type = "debit" | ||
transaction.amount = transaction.amount * (-1) | ||
elif transaction.type == "debit": | ||
transaction.type = "credit" | ||
transaction.amount = transaction.amount * (-1) | ||
else: | ||
pass | ||
|
||
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, | ||
) |