Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] internal_transfer_with_agreed_amount: Migration to 17.0 t#71297 #1670

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
928face
[ADD] internal_transfer_with_agreed_amount: New module (#1393)
edy1192 Feb 6, 2020
4781bbf
[IMP] internal_transfer_with_agreed_amount: Add Spanish translation (…
edy1192 Apr 8, 2020
4753618
[FIX] internal_transfer_with_agreed_amount: Don't depend on enterpris…
luisg123v Aug 2, 2020
c8b8e3b
[FIX] internal_transfer_with_agreed_amount: Remove unnecessary headers
luisg123v Sep 3, 2020
a894498
[IMP] internal_transfer_with_agreed_amount: black, isort, prettier
CLaurelB Aug 8, 2023
5fa6d30
[REF] internal_transfer_with_agreed_amount: fix xml headers
CLaurelB Aug 8, 2023
3c9654e
[REF] internal_transfer_with_agreed_amount: split and rename files by…
CLaurelB Aug 8, 2023
16a57d9
[REF] internal_transfer_with_agreed_amount: refactor for readability …
CLaurelB Aug 8, 2023
330248d
[REF] internal_transfer_with_agreed_amount: refactor unit tests
CLaurelB Aug 8, 2023
37a6ca8
[REF] internal_transfer_with_agreed_amount: modify external IDs for i…
CLaurelB Aug 8, 2023
1c9e079
[I18N] internal_transfer_with_agreed_amount: update spanish translations
CLaurelB Aug 9, 2023
1bbd405
[MIG] internal_transfer_with_agreed_amount: Migrate module from v12.0…
CLaurelB Aug 9, 2023
b40d73e
[IMP] internal_transfer_with_agreed_amount: modify write vals in one …
CLaurelB Nov 2, 2023
658637f
[IMP] internal_transfer_with_agreed_amount: update tests to use compa…
CLaurelB Nov 8, 2023
22f5be2
[FIX] internal_transfer_with_agreed_amount: Fixing AssertionError in …
allanpa88 May 8, 2024
14d18cd
[FIX] internal_transfer_with_agreed_amount: fix README images referen…
CLaurelB Jun 13, 2024
483325e
[FIX] internal_transfer_with_agreed_amount: fix optional lints
CLaurelB Jun 13, 2024
64c240c
[MIG] internal_transfer_with_agreed_amount: Migration to 17.0
CLaurelB Jun 13, 2024
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
38 changes: 38 additions & 0 deletions internal_transfer_with_agreed_amount/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Internal transfers with an agreed amount
========================================

This module allows an internal transfer between different currencies, setting an agreed amount.

For this process the user must belong to the

"Allow to confirm an internal transfer with an agreed amount" group.

.. image:: /internal_transfer_with_agreed_amount/static/src/img/group.png
:align: center
:width: 400pt
:alt: Allow to confirm an internal transfer with an agreed amount group


This group allows to the user see the "Confirm with an agreed amount" button in the transfer

.. image:: /internal_transfer_with_agreed_amount/static/src/img/1.png
:align: center
:width: 400pt
:alt: Confirm with an agreed amount button


Then the agreed amount for the transfer must be established, the currency
will be the one set in the destination journal.

.. image:: /internal_transfer_with_agreed_amount/static/src/img/2.png
:align: center
:width: 400pt
:alt: Set agreed amount


This agreed amount will be used in the journal entries of the transfer.

.. image:: /internal_transfer_with_agreed_amount/static/src/img/3.png
:align: center
:width: 400pt
:alt: Journal entries
1 change: 1 addition & 0 deletions internal_transfer_with_agreed_amount/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import wizards
21 changes: 21 additions & 0 deletions internal_transfer_with_agreed_amount/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Internal transfers with an agreed amount",
"version": "17.0.1.0.0",
"author": "Vauxoo",
"website": "http://www.vauxoo.com/",
"license": "LGPL-3",
"category": "account",
"depends": [
"account",
],
"data": [
# Security
"security/ir.model.access.csv",
"security/res_groups_security.xml",
# Wizards
"wizards/internal_transfer_multicurrency_views.xml",
# Views
"views/account_payment_views.xml",
],
"installable": True,
}
124 changes: 124 additions & 0 deletions internal_transfer_with_agreed_amount/i18n/es.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * internal_transfer_with_agreed_amount
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 17.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-18 15:42+0000\n"
"PO-Revision-Date: 2024-06-18 15:42+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__agreed_amount
msgid "Agreed Amount"
msgstr "Monto Acordado"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,help:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__agreed_amount
msgid "Agreed amount in the currency of the destination bank."
msgstr "Cantidad acordada en la moneda del banco de destino."

#. module: internal_transfer_with_agreed_amount
#. odoo-python
#: code:addons/internal_transfer_with_agreed_amount/wizards/internal_transfer_multicurrency.py:0
#, python-format
msgid ""
"Agreed amount is available when there are two considered currencies. Currently, the following currencies are being considered:\n"
"- %s"
msgstr ""
"El monto acordado está disponible cuando hay dos monedas consideradas. Actualmente, las siguientes monedas se consideran:\n"
"- %s"

#. module: internal_transfer_with_agreed_amount
#: model:res.groups,name:internal_transfer_with_agreed_amount.allow_confirm_internal_transfer_with_agreed_amount
msgid "Allow to confirm an internal transfer with an agreed amount"
msgstr "Permitir confirmar una transferencia interna con un monto acordado"

#. module: internal_transfer_with_agreed_amount
#: model_terms:ir.ui.view,arch_db:internal_transfer_with_agreed_amount.view_internal_transfer_multicurrency
msgid "Apply"
msgstr "Aplicar"

#. module: internal_transfer_with_agreed_amount
#: model_terms:ir.ui.view,arch_db:internal_transfer_with_agreed_amount.view_internal_transfer_multicurrency
msgid "Cancel"
msgstr "Cancelar"

#. module: internal_transfer_with_agreed_amount
#: model_terms:ir.ui.view,arch_db:internal_transfer_with_agreed_amount.view_account_payment_form
msgid "Confirm with an agreed amount"
msgstr "Confirmar con un monto acordado"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__create_uid
msgid "Created by"
msgstr "Creado por"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__create_date
msgid "Created on"
msgstr "Creado en"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__currency_id
msgid "Currency"
msgstr "Moneda"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__display_name
msgid "Display Name"
msgstr "Nombre mostrado"

#. module: internal_transfer_with_agreed_amount
#: model_terms:ir.ui.view,arch_db:internal_transfer_with_agreed_amount.view_account_payment_form
msgid "Edit agreed amount"
msgstr "Editar monto acordado"

#. module: internal_transfer_with_agreed_amount
#: model_terms:ir.ui.view,arch_db:internal_transfer_with_agreed_amount.view_internal_transfer_multicurrency
msgid "Fill with the total amount that you will receive for this operation"
msgstr "Complete con el monto total que recibirá por esta operación"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__id
msgid "ID"
msgstr ""

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__write_uid
msgid "Last Updated by"
msgstr "Última actualización por"

#. module: internal_transfer_with_agreed_amount
#: model:ir.model.fields,field_description:internal_transfer_with_agreed_amount.field_internal_transfer_multicurrency__write_date
msgid "Last Updated on"
msgstr "Última actualización el"

#. module: internal_transfer_with_agreed_amount
#: model:ir.actions.act_window,name:internal_transfer_with_agreed_amount.action_internal_transfer_multicurrency
msgid "Specify the agreed amount"
msgstr "Especifique el monto acordado"

#. module: internal_transfer_with_agreed_amount
#: model:res.groups,comment:internal_transfer_with_agreed_amount.allow_confirm_internal_transfer_with_agreed_amount
msgid ""
"The user with this permission can make multi-currency transfers with an "
"agreed amount."
msgstr ""
"El usuario con este permiso puede realizar transferencias multi moneda con "
"un monto acordado."

#. module: internal_transfer_with_agreed_amount
#: model:ir.model,name:internal_transfer_with_agreed_amount.model_internal_transfer_multicurrency
msgid ""
"Wizard to modify the agreed amount with the bank on an internal transfer."
msgstr ""
"Wizard para modificar el monto acordado con el banco en una transferencia "
"interna."
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_internal_transfer_multicurrency,access_internal_transfer_multicurrency,model_internal_transfer_multicurrency,base.group_user,1,1,1,1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="allow_confirm_internal_transfer_with_agreed_amount" model="res.groups">
<field name="name">Allow to confirm an internal transfer with an agreed amount</field>
<field name="category_id" ref="base.module_category_usability" />
<field
name="comment"
>The user with this permission can make multi-currency transfers with an agreed amount.</field>
</record>
</odoo>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions internal_transfer_with_agreed_amount/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_internal_transfer_with_agreed_amount
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
from odoo.tests import Form, TransactionCase, tagged


@tagged("internal_transfer_multicurrency", "post_install", "-at_install")
class TestInternalTransferWithAgreedAmount(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
main_company = cls.env.ref("base.main_company")
main_company.transfer_account_id.write({"reconcile": True})
cls.currency = main_company.currency_id
cls.currency_eur = cls.env.ref("base.EUR")
cls.currency_eur.active = True
bank = cls.env["account.journal"].search([("type", "=", "bank")], limit=1)
cls.bank_journal = bank.copy()
cls.bank_journal.write({"name": "Bank " + cls.currency.name, "code": "BNK68"})
cls.bank_journal_eur = bank.copy({"currency_id": cls.currency_eur.id})
cls.bank_journal_eur.write({"name": "Bank EUR", "code": "BNK67"})
account = cls.bank_journal.default_account_id
payment_method = (
cls.bank_journal.inbound_payment_method_line_ids | cls.bank_journal.outbound_payment_method_line_ids
)
payment_method.payment_account_id = account

def create_internal_transfer(self, currency, journal, destination_journal, amount):
transfer = Form(self.env["account.payment"])
transfer.payment_type = "outbound"
transfer.journal_id = journal
transfer.currency_id = currency
transfer.is_internal_transfer = True
transfer.destination_journal_id = destination_journal
transfer.amount = amount
return transfer.save()

def create_multicurrency_transfer(self, payment, agreed_amount):
ctx = {"active_model": payment._name, "active_ids": payment.ids}
wizard = Form(self.env["internal.transfer.multicurrency"].with_context(**ctx))
wizard.agreed_amount = agreed_amount
wizard = wizard.save()
wizard.apply()
return wizard

def test_01_transfer_local_eur(self):
transfer = self.create_internal_transfer(self.currency, self.bank_journal, self.bank_journal_eur, 100)
self.create_multicurrency_transfer(transfer, 120)

# Check journal item in USD
aml = transfer.line_ids.filtered("reconciled")
self.assertRecordValues(
aml,
[
{
"balance": 100.0, # payment amount
"amount_currency": 120.0,
"currency_id": self.currency_eur.id,
}
],
)

# Check journal item in EUR
eur_aml = aml.full_reconcile_id.reconciled_line_ids.filtered(lambda line: line != aml)
self.assertRecordValues(
eur_aml,
[
{
"balance": -100.0, # payment amount
"amount_currency": -120.0, # Agreed amount
"currency_id": self.currency_eur.id,
}
],
)

def test_02_transfer_eur_local(self):
transfer = self.create_internal_transfer(self.currency_eur, self.bank_journal_eur, self.bank_journal, 100)
self.create_multicurrency_transfer(transfer, 80)

# Check journal item in USD
aml = transfer.line_ids.filtered("reconciled")
self.assertRecordValues(
aml,
[
{
"balance": 80.0, # Agreed amount
"amount_currency": 100.0,
"currency_id": self.currency_eur.id,
}
],
)

# Check journal item in EUR
eur_aml = aml.full_reconcile_id.reconciled_line_ids.filtered(lambda line: line != aml)
self.assertRecordValues(
eur_aml,
[
{
"balance": -80.0, # Agreed amount
"amount_currency": -100.0, # Payment amount
"currency_id": self.currency_eur.id,
}
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="view_account_payment_form" model="ir.ui.view">
<field name="name">account.payment.form.inherit</field>
<field name="model">account.payment</field>
<field name="inherit_id" ref="account.view_account_payment_form" />
<field name="arch" type="xml">
<xpath expr="//button[@name='action_post']" position="after">
<button
name="internal_transfer_with_agreed_amount.action_internal_transfer_multicurrency"
type="action"
class="oe_highlight"
string="Confirm with an agreed amount"
groups="internal_transfer_with_agreed_amount.allow_confirm_internal_transfer_with_agreed_amount"
invisible="not is_internal_transfer or state != 'draft'"
/>
<button
name="internal_transfer_with_agreed_amount.action_internal_transfer_multicurrency"
type="action"
class="oe_highlight"
string="Edit agreed amount"
groups="internal_transfer_with_agreed_amount.allow_confirm_internal_transfer_with_agreed_amount"
invisible="not is_internal_transfer or state in ('draft', 'cancelled')"
/>
</xpath>
</field>
</record>
</odoo>
1 change: 1 addition & 0 deletions internal_transfer_with_agreed_amount/wizards/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import internal_transfer_multicurrency
Loading
Loading