-
-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] account_internal_transfer: add new module
- Loading branch information
1 parent
1d814c3
commit 6456cff
Showing
20 changed files
with
1,173 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,97 @@ | ||
========================= | ||
Account Internal Transfer | ||
========================= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:73f8125495ad9aa22dda0b0f8d9d1b4e5315a111370102d3436477a593ded623 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Beta | ||
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fbank--payment-lightgray.png?logo=github | ||
:target: https://github.com/OCA/bank-payment/tree/14.0/account_internal_transfer | ||
:alt: OCA/bank-payment | ||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png | ||
:target: https://translation.odoo-community.org/projects/bank-payment-14-0/bank-payment-14-0-account_internal_transfer | ||
:alt: Translate me on Weblate | ||
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png | ||
:target: https://runboat.odoo-community.org/builds?repo=OCA/bank-payment&target_branch=14.0 | ||
:alt: Try me on Runboat | ||
|
||
|badge1| |badge2| |badge3| |badge4| |badge5| | ||
|
||
This module allows you to create internal transfers compatible with payment orders. | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Configuration | ||
============= | ||
|
||
#. Go to Accounting > Configuration > Settings: | ||
|
||
- Go to Bank & Cash section. | ||
- Define one payable account and one receivable account. | ||
|
||
Usage | ||
===== | ||
|
||
#. Create internal transfers: | ||
|
||
- Go to Invoicing > Accounting > Bank and Cash > Internal Transfers. | ||
- Create a new record. | ||
- A Journal Entry will be created with the accounts we defined in the settings. | ||
- Create a Payment Order and select the move line of the Journal Entry. | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/bank-payment/issues>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
If you spotted it first, help us to smash it by providing a detailed and welcomed | ||
`feedback <https://github.com/OCA/bank-payment/issues/new?body=module:%20account_internal_transfer%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Escodoo | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Wesley Oliveira <[email protected]> | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
This module is maintained by the OCA. | ||
|
||
.. image:: https://odoo-community.org/logo.png | ||
:alt: Odoo Community Association | ||
:target: https://odoo-community.org | ||
|
||
OCA, or the Odoo Community Association, is a nonprofit organization whose | ||
mission is to support the collaborative development of Odoo features and | ||
promote its widespread use. | ||
|
||
This module is part of the `OCA/bank-payment <https://github.com/OCA/bank-payment/tree/14.0/account_internal_transfer>`_ project on GitHub. | ||
|
||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. |
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 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,19 @@ | ||
# Copyright 2024 - TODAY, Escodoo | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
{ | ||
"name": "Account Internal Transfer", | ||
"summary": """ | ||
Account Internal Transfer""", | ||
"version": "14.0.1.0.0", | ||
"license": "AGPL-3", | ||
"author": "Escodoo,Odoo Community Association (OCA)", | ||
"website": "https://github.com/OCA/bank-payment", | ||
"depends": ["account", "account_menu", "account_payment_order"], | ||
"data": [ | ||
"views/account_internal_transfer_views.xml", | ||
"views/res_config_settings.xml", | ||
"security/ir.model.access.csv", | ||
], | ||
"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,3 @@ | ||
from . import account_internal_transfer | ||
from . import res_company | ||
from . import res_config_settings |
194 changes: 194 additions & 0 deletions
194
account_internal_transfer/models/account_internal_transfer.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,194 @@ | ||
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import api, fields, models | ||
|
||
|
||
class AccountInternalTransfer(models.Model): | ||
_name = "account.internal.transfer" | ||
_inherit = ["mail.thread", "mail.activity.mixin"] | ||
_description = "Internal Transfers" | ||
_order = "id desc" | ||
_check_company_auto = True | ||
|
||
name = fields.Char( | ||
string="Name", | ||
related="move_id.name", | ||
copy=False, | ||
readonly=True, | ||
store=True, | ||
) | ||
company_id = fields.Many2one( | ||
comodel_name="res.company", | ||
string="Company", | ||
readonly=True, | ||
default=lambda self: self.env.company, | ||
) | ||
transfer_journal_id = fields.Many2one( | ||
comodel_name="account.journal", | ||
string="Transfer Journal", | ||
required=True, | ||
domain="[('company_id', '=', company_id)]", | ||
) | ||
outgoing_journal_id = fields.Many2one( | ||
comodel_name="account.journal", | ||
string="Outgoing Journal", | ||
required=True, | ||
domain="[('company_id', '=', company_id)]", | ||
) | ||
destination_journal_id = fields.Many2one( | ||
comodel_name="account.journal", | ||
string="Destination Journal", | ||
required=True, | ||
domain="[('company_id', '=', company_id)]", | ||
) | ||
outgoing_partner_bank_id = fields.Many2one( | ||
comodel_name="res.partner.bank", | ||
string="Outgoing Bank Account", | ||
check_company=True, | ||
related="outgoing_journal_id.bank_account_id", | ||
store=True, | ||
readonly=True, | ||
) | ||
destination_partner_bank_id = fields.Many2one( | ||
comodel_name="res.partner.bank", | ||
string="Destination Bank Account", | ||
check_company=True, | ||
related="destination_journal_id.bank_account_id", | ||
store=True, | ||
readonly=True, | ||
) | ||
currency_id = fields.Many2one( | ||
comodel_name="res.currency", | ||
readonly=True, | ||
related="company_id.currency_id", | ||
store=True, | ||
) | ||
amount = fields.Monetary( | ||
currency_field="currency_id", | ||
string="Amount", | ||
required=True, | ||
default=0.0, | ||
) | ||
date = fields.Date( | ||
string="Date", | ||
required=True, | ||
) | ||
date_maturity = fields.Date( | ||
string="Due Date", | ||
required=True, | ||
) | ||
move_id = fields.Many2one( | ||
comodel_name="account.move", | ||
string="Journal Entry", | ||
readonly=True, | ||
ondelete="cascade", | ||
check_company=True, | ||
) | ||
state = fields.Selection( | ||
string="Status", | ||
default="draft", | ||
related="move_id.state", | ||
copy=False, | ||
readonly=True, | ||
store=True, | ||
tracking=True, | ||
) | ||
|
||
def _create_account_move(self): | ||
move_vals = { | ||
"date": self.date, | ||
"journal_id": self.transfer_journal_id.id, | ||
"ref": "Internal Transfer", | ||
"line_ids": [ | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "Transfer to " + self.destination_journal_id.name, | ||
"account_id": self.company_id.transfer_payable_account_id.id, | ||
"partner_id": self.company_id.partner_id.id, | ||
"debit": 0.0, | ||
"credit": self.amount, | ||
"date_maturity": self.date_maturity, | ||
"partner_bank_id": self.destination_partner_bank_id.id, | ||
}, | ||
), | ||
( | ||
0, | ||
0, | ||
{ | ||
"name": "Transfer from " + self.outgoing_journal_id.name, | ||
"account_id": self.company_id.transfer_receivable_account_id.id, | ||
"partner_id": self.company_id.partner_id.id, | ||
"debit": self.amount, | ||
"credit": 0.0, | ||
"date_maturity": self.date_maturity, | ||
"partner_bank_id": self.outgoing_partner_bank_id.id, | ||
}, | ||
), | ||
], | ||
} | ||
move_id = self.env["account.move"].create(move_vals) | ||
return move_id | ||
|
||
@api.model | ||
def create(self, vals): | ||
record = super(AccountInternalTransfer, self).create(vals) | ||
move_id = record._create_account_move() | ||
record.move_id = move_id | ||
return record | ||
|
||
def _syncronize_account_move(self): | ||
if self.move_id.id: | ||
move = self.env["account.move"].browse(self.move_id.id) | ||
credit_line = move.line_ids.filtered(lambda x: x.credit > 0) | ||
debit_line = move.line_ids.filtered(lambda x: x.debit > 0) | ||
move.write( | ||
{ | ||
"date": self.date, | ||
"journal_id": self.transfer_journal_id.id, | ||
"line_ids": [ | ||
( | ||
1, | ||
credit_line.id, | ||
{ | ||
"name": "Transfer to " | ||
+ self.destination_journal_id.name, | ||
"credit": self.amount, | ||
"date_maturity": self.date_maturity, | ||
"partner_bank_id": self.destination_partner_bank_id.id, | ||
}, | ||
), | ||
( | ||
1, | ||
debit_line.id, | ||
{ | ||
"name": "Transfer from " | ||
+ self.outgoing_journal_id.name, | ||
"debit": self.amount, | ||
"date_maturity": self.date_maturity, | ||
"partner_bank_id": self.outgoing_partner_bank_id.id, | ||
}, | ||
), | ||
], | ||
} | ||
) | ||
|
||
def write(self, vals): | ||
res = super(AccountInternalTransfer, self).write(vals) | ||
if "move_id" not in vals: | ||
self._syncronize_account_move() | ||
return res | ||
|
||
def action_confirm(self): | ||
if self.move_id: | ||
self.move_id.action_post() | ||
|
||
def action_cancel(self): | ||
if self.move_id: | ||
self.move_id.button_cancel() | ||
|
||
def action_draft(self): | ||
if self.move_id: | ||
self.move_id.button_draft() |
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 @@ | ||
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class ResCompany(models.Model): | ||
_inherit = "res.company" | ||
|
||
transfer_payable_account_id = fields.Many2one( | ||
comodel_name="account.account", | ||
domain="[('internal_type', '=', 'payable'), ('company_id', '=', company_id)]", | ||
string="Internal Transfer Payable Account", | ||
) | ||
transfer_receivable_account_id = fields.Many2one( | ||
comodel_name="account.account", | ||
domain="[('internal_type', '=', 'receivable'), ('company_id', '=', company_id)]", | ||
string="Internal Transfer Receivable Account", | ||
) |
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,21 @@ | ||
# Copyright 2024 - TODAY, Wesley Oliveira <[email protected]> | ||
# 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" | ||
|
||
transfer_payable_account_id = fields.Many2one( | ||
comodel_name="account.account", | ||
related="company_id.transfer_payable_account_id", | ||
string="Internal Transfer Payable Account", | ||
readonly=False, | ||
) | ||
transfer_receivable_account_id = fields.Many2one( | ||
comodel_name="account.account", | ||
related="company_id.transfer_receivable_account_id", | ||
string="Internal Transfer Receivable Account", | ||
readonly=False, | ||
) |
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,4 @@ | ||
#. Go to Accounting > Configuration > Settings: | ||
|
||
- Go to Bank & Cash section. | ||
- Define one payable account and one receivable account. |
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,4 @@ | ||
* `Escodoo <https://www.escodoo.com.br>`_: | ||
|
||
* Marcel Savegnago <[email protected]> | ||
* Wesley Oliveira <[email protected]> |
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 @@ | ||
This module allows you to create internal transfers compatible with payment orders. |
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 @@ | ||
#. Create internal transfers: | ||
|
||
- Go to Invoicing > Accounting > Bank and Cash > Internal Transfers. | ||
- Create a new record. | ||
- A Journal Entry will be created with the accounts we defined in the settings. | ||
- Create a Payment Order and select the move line of the Journal Entry. |
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 @@ | ||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink | ||
access_account_internal_transfer,account.internal.transfer,model_account_internal_transfer,account.group_account_user,1,1,1,1 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.