Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions account_internal_transfer/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
=========================
Account Internal Transfer
=========================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:f25729ef78da1af9c04e61ccf41f10312f8d1a5bd16268dcc6a7fadd12c1e1cd
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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-Escodoo%2Faccount--addons-lightgray.png?logo=github
:target: https://github.com/Escodoo/account-addons/tree/14.0/account_internal_transfer
:alt: Escodoo/account-addons

|badge1| |badge2| |badge3|

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 Accounting > 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/Escodoo/account-addons/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/Escodoo/account-addons/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 <marcel.savegnago@escodoo.com.br>
* Wesley Oliveira <wesley.oliveira@escodoo.com.br>

Maintainers
~~~~~~~~~~~

This module is part of the `Escodoo/account-addons <https://github.com/Escodoo/account-addons/tree/14.0/account_internal_transfer>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions account_internal_transfer/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
19 changes: 19 additions & 0 deletions account_internal_transfer/__manifest__.py
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",
"website": "https://github.com/Escodoo/account-addons",
"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": [],
}
3 changes: 3 additions & 0 deletions account_internal_transfer/models/__init__.py
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 account_internal_transfer/models/account_internal_transfer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# 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()
19 changes: 19 additions & 0 deletions account_internal_transfer/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# 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",
)
21 changes: 21 additions & 0 deletions account_internal_transfer/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 - TODAY, Wesley Oliveira <wesley.oliveira@escodoo.com.br>
# 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,
)
4 changes: 4 additions & 0 deletions account_internal_transfer/readme/CONFIGURE.rst
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.
4 changes: 4 additions & 0 deletions account_internal_transfer/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* `Escodoo <https://www.escodoo.com.br>`_:

* Marcel Savegnago <marcel.savegnago@escodoo.com.br>
* Wesley Oliveira <wesley.oliveira@escodoo.com.br>
1 change: 1 addition & 0 deletions account_internal_transfer/readme/DESCRIPTION.rst
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.
6 changes: 6 additions & 0 deletions account_internal_transfer/readme/USAGE.rst
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.
2 changes: 2 additions & 0 deletions account_internal_transfer/security/ir.model.access.csv
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.
Loading