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

[14.0][IMP] account_payment_order: Add Transfer moves dates #1305

Merged
Merged
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
198 changes: 0 additions & 198 deletions account_payment_order/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -1316,201 +1316,3 @@ msgstr "el"
msgid "otherwise, new payment orders will be created (one per payment mode)."
msgstr ""
"En caso contrario, se crearán nuevas órdenes (una por cada modo de pago)."

#~ msgid "SMS Delivery error"
#~ msgstr "Error de entrega del SMS"

#~ msgid "Accounting Entries Options"
#~ msgstr "Opciones de asientos contables"

#~ msgid "Generate Accounting Entries On File Upload"
#~ msgstr "Generar asientos contables al subir el archivo"

#~ msgid "Move Option"
#~ msgstr "Opciones de asiento"

#, python-format
#~ msgid ""
#~ "On the payment mode '%s', you must choose an option for the 'Move Option' "
#~ "parameter."
#~ msgstr ""
#~ "En el modo de pago '%s', debe escoger una opción para las 'Opciones de "
#~ "asiento'."

#~ msgid "One move per payment date"
#~ msgstr "Un asiento por fecha de pago"

#~ msgid "One move per payment line"
#~ msgstr "Un asiento por línea de pago"

#~ msgid "Post Move"
#~ msgstr "Publicar movimiento"

#~ msgid "Bank Payment Line"
#~ msgstr "Línea de pago bancario"

#~ msgid "Bank Payment Line Ref"
#~ msgstr "Ref. de la línea de pago bancario"

#~ msgid "Bank Payment Lines"
#~ msgstr "Líneas de pago bancario"

#, python-format
#~ msgid "Can not reconcile: no move line for payment line %s of partner '%s'."
#~ msgstr ""
#~ "No se puede conciliar: no hay apunte para la línea de pago %s de la "
#~ "empresa '%s'."

#, python-format
#~ msgid ""
#~ "Cannot delete a payment order line whose payment order is in state '%s'. "
#~ "You need to cancel it first."
#~ msgstr ""
#~ "No se puede eliminar una línea de una orden de pago cuyo estado es '%s'. "
#~ "Primero debes cancelarla."

#, python-format
#~ msgid "Debit bank line %s"
#~ msgstr "Línea de adeudo de banco %s"

#, python-format
#~ msgid "Debit order %s"
#~ msgstr "Orden de cobro %s"

#, python-format
#~ msgid ""
#~ "For partner '%s', the account of the account move line to pay (%s) is "
#~ "different from the account of of the transit move line (%s)."
#~ msgstr ""
#~ "Para la empresa '%s', la cuenta del apunte a pagar (%s) es diferente de "
#~ "la cuenta del apunte de tránsito (%s)."

#, python-format
#~ msgid "Move line '%s' of partner '%s' has already been reconciled"
#~ msgstr "El apunte '%s' de la empresa '%s' ya ha sido conciliado"

#~ msgid "Order"
#~ msgstr "Orden"

#, python-format
#~ msgid "Payment bank line %s"
#~ msgstr "Línea de pago bancario %s"

#, python-format
#~ msgid "Payment order %s"
#~ msgstr "Orden %s"

#~ msgid "Related Payment Lines"
#~ msgstr "Líneas de pago relacionadas"

#~ msgid "Search Bank Payment Lines"
#~ msgstr "Buscar líneas de pago bancario"

#~ msgid ""
#~ "The bank payment lines are used to generate the payment file. They are "
#~ "automatically created from transaction lines upon confirmation of the "
#~ "payment order: one bank payment line can group several transaction lines "
#~ "if the option 'Group Transactions in Payment Orders' is active on the "
#~ "payment mode."
#~ msgstr ""
#~ "Las líneas de pago bancarias se usan para generar el archivo de pago. Se "
#~ "crean automáticamente de las líneas de transacciones en la confirmación "
#~ "de la orden: una línea de pago bancario puede agrupar varias líneas de "
#~ "transacción si la opción 'Agrupar transacciones en las órdenes' está "
#~ "activada en el modo de pago."

#~ msgid "Total Amount"
#~ msgstr "Importe total"

#, python-format
#~ msgid "%d payment lines added to the existing draft payment order %s."
#~ msgstr "%d líneas de pago añadidas a la orden de pago en borrador %s."

#, python-format
#~ msgid ""
#~ "%d payment lines added to the new draft payment order %s which has been "
#~ "automatically created."
#~ msgstr ""
#~ "%d líneas de pago añadidas a una nueva orden de pago en borrador %s que "
#~ "ha sido creada automáticamente."

#~ msgid "Done"
#~ msgstr "Realizado"

#~ msgid "Done Date"
#~ msgstr "Fecha de realización"

#~ msgid ""
#~ "Journal to write payment entries when confirming payment/debit orders of "
#~ "this mode"
#~ msgstr ""
#~ "Diario al que escribir los asientos contables cuando se confirme la orden "
#~ "de cobro/pago de este modo"

#~ msgid "Number of Bank Lines"
#~ msgstr "Número de líneas bancarias"

#~ msgid "Offsetting Account"
#~ msgstr "Cuenta de compensación"

#~ msgid ""
#~ "On the payment mode '%s', you must select a value for the 'Transfer "
#~ "Account'."
#~ msgstr ""
#~ "En el modo de pago '%s', debe seleccionar un valor para la 'Cuenta de "
#~ "transferencia'."

#~ msgid ""
#~ "On the payment mode '%s', you must select a value for the 'Transfer "
#~ "Journal'."
#~ msgstr ""
#~ "En el modo de pago '%s', debe seleccionar un valor para el 'Diario de "
#~ "transferencia'."

#~ msgid ""
#~ "On the payment mode '%s', you must select an option for the 'Offsetting "
#~ "Account' parameter"
#~ msgstr ""
#~ "En el modo de pago '%s', debe seleccionar una opción para el parámetro "
#~ "'Cuenta de compensación'"

#~ msgid ""
#~ "Pay off lines in 'file uploaded' payment orders with a move on this "
#~ "account. You can only select accounts that are marked for reconciliation"
#~ msgstr ""
#~ "Las líneas de pago de la orden se conciliarán en la 'subida de archivo' "
#~ "con un apunte a esta cuenta. Sólo puede seleccionar las cuentas que están "
#~ "marcadas para conciliación"

#~ msgid "Transaction Lines"
#~ msgstr "Líneas de transacción"

#~ msgid "Transfer Account"
#~ msgstr "Cuenta de transferencia"

#~ msgid "Transfer Journal"
#~ msgstr "Diario de transferencia"

#~ msgid "Transfer Journal Entries"
#~ msgstr "Asientos de transferencia"

#~ msgid "Due date"
#~ msgstr "Fecha de vencimiento"

#~ msgid "ISO"
#~ msgstr "ISO"

#~ msgid "Invoice"
#~ msgstr "Factura"

#~ msgid "No Journal Entry on invoice %s"
#~ msgstr "No se ha encontrado asiento en la factura %s"

#~ msgid "Payment Order / Payment"
#~ msgstr "Orden de Pago / Pago"

#~ msgid "Account Entry"
#~ msgstr "Asiento contable"

#~ msgid "report.account_payment_order.print_account_payment_order_main"
#~ msgstr "report.account_payment_order.print_account_payment_order_main"
14 changes: 14 additions & 0 deletions account_payment_order/models/account_payment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright 2019 ACSONE SA/NV
# Copyright 2022 Tecnativa - Pedro M. Baeza
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import api, fields, models
Expand Down Expand Up @@ -43,3 +44,16 @@ def _compute_payment_method_fields(self):
and pay.available_payment_method_ids.code == "manual"
)
return res

def _prepare_move_line_default_vals(self, write_off_line_vals=None):
"""Overwrite date_maturity of the move_lines that are generated when related
to a payment order.
"""
vals_list = super()._prepare_move_line_default_vals(
write_off_line_vals=write_off_line_vals
)
if not self.payment_order_id:
return vals_list
for vals in vals_list:
vals["date_maturity"] = self.payment_line_ids[0].date
return vals_list
2 changes: 1 addition & 1 deletion account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _prepare_account_payment_vals(self):
"destination_account_id": self.move_line_id.account_id.id,
"company_id": self.order_id.company_id.id,
"amount": sum(self.mapped("amount_currency")),
"date": self[:1].date,
"date": fields.Date.today(),
"currency_id": self.currency_id.id,
"ref": self.order_id.name,
"payment_reference": " - ".join([line.communication for line in self]),
Expand Down
26 changes: 25 additions & 1 deletion account_payment_order/tests/test_payment_order_inbound.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright 2017 Camptocamp SA
# Copyright 2017 Creu Blanca
# Copyright 2019-2022 Tecnativa - Pedro M. Baeza
# Copyright 2024 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from datetime import date, timedelta

from freezegun import freeze_time

from odoo.exceptions import UserError, ValidationError
from odoo.tests.common import Form, tagged

Expand Down Expand Up @@ -141,3 +143,25 @@ def test_creation(self):
payment_order.cancel2draft()
payment_order.unlink()
self.assertEqual(len(self.payment_order_obj.search(self.domain)), 0)

@freeze_time("2024-04-01")
def test_creation_transfer_move_date(self):
self.inbound_order.date_prefered = "fixed"
self.inbound_order.date_scheduled = "2024-06-01"
self.inbound_order.draft2open()
payment_move = self.inbound_order.payment_ids.move_id
self.assertEqual(payment_move.date, date(2024, 4, 1)) # now
self.assertEqual(
payment_move.line_ids.mapped("date_maturity"),
[date(2024, 6, 1), date(2024, 6, 1)],
)
self.assertEqual(self.inbound_order.payment_count, 1)
self.inbound_order.open2generated()
self.inbound_order.generated2uploaded()
self.assertEqual(self.inbound_order.state, "uploaded")
payment_move = self.inbound_order.payment_ids.move_id
self.assertEqual(payment_move.date, date(2024, 4, 1)) # now
self.assertEqual(
payment_move.line_ids.mapped("date_maturity"),
[date(2024, 6, 1), date(2024, 6, 1)],
)
3 changes: 1 addition & 2 deletions account_payment_order/tests/test_payment_order_outbound.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,7 @@ def test_manual_line_and_manual_date(self):
outbound_order.draft2open()
self.assertEqual(outbound_order.payment_count, 2)
self.assertEqual(
outbound_order.payment_line_ids[0].date,
outbound_order.payment_line_ids[0].payment_ids.date,
outbound_order.payment_line_ids[0].payment_ids.date, fields.Date.today()
)
self.assertEqual(
outbound_order.payment_line_ids[1].date,
Expand Down
Loading