Automatic Update form OCA2FC Migrator

This commit is contained in:
Flectra Community Bot 2021-06-06 02:13:20 +00:00 committed by OCA2FC Migrator Bot
parent aabef79168
commit 84fc0fad18
24 changed files with 329 additions and 65 deletions

View File

@ -15,7 +15,7 @@ addon | version | summary
[account_payment_sale](account_payment_sale/) | 2.0.1.0.0| Adds payment mode on sale orders
[account_payment_purchase_stock](account_payment_purchase_stock/) | 2.0.1.0.0| Integrate Account Payment Purchase with Stock
[account_payment_purchase](account_payment_purchase/) | 2.0.1.0.0| Adds Bank Account and Payment Mode on Purchase Orders
[account_payment_partner](account_payment_partner/) | 2.0.1.1.2| Adds payment mode on partners and invoices
[account_payment_partner](account_payment_partner/) | 2.0.1.2.0| Adds payment mode on partners and invoices
[account_banking_pain_base](account_banking_pain_base/) | 2.0.1.0.0| Base module for PAIN file generation
[account_banking_sepa_direct_debit](account_banking_sepa_direct_debit/) | 2.0.1.1.0| Create SEPA files for Direct Debit
[account_banking_sepa_credit_transfer](account_banking_sepa_credit_transfer/) | 2.0.1.0.0| Create SEPA XML files for Credit Transfers

View File

@ -9,8 +9,8 @@ Most of the files are
Copyright 2014-2016 Akretion (http://www.akretion.com/)
Copyright 2016 Akretion (http://www.akretion.com/)
Copyright 2017 ForgeFlow S.L.
Copyright 2018 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
Copyright 2018 Tecnativa - Carlos Dauden
Copyright 2021 Tecnativa - Víctor Martínez
Copyright 2018 Flectra Community
Many files also contain contributions from third

View File

@ -104,8 +104,9 @@ Contributors
* Angel Moya <angel.moya@domatix.com>
* `Tecnativa <https://www.tecnativa.com>`_:
* Pedro M. Baeza <pedro.baeza@tecnativa.com>
* Carlos Dauden <carlos.dauden@tecnativa.com>
* Pedro M. Baeza
* Carlos Dauden
* Víctor Martínez
* `DynApps <https://www.dynapps.be>`_:
* Raf Ven <raf.ven@dynapps.be>

View File

@ -1,15 +1,16 @@
# Copyright 2014 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# Copyright 2014 Tecnativa - Pedro M. Baeza
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
{
"name": "Account Payment Partner",
"version": "2.0.1.1.2",
"version": "2.0.1.2.0",
"category": "Banking addons",
"license": "AGPL-3",
"summary": "Adds payment mode on partners and invoices",
"author": "Akretion, " "Tecnativa, " "Odoo Community Association (OCA)",
"author": "Akretion, Tecnativa, Odoo Community Association (OCA)",
"website": "https://gitlab.com/flectra-community/bank-payment",
"depends": ["account_payment_mode"],
"data": [

View File

@ -162,6 +162,11 @@ msgstr ""
msgid "Payment Modes"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -206,6 +211,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -173,6 +173,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Modes de pagament"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -217,6 +222,13 @@ msgstr "Mostra en les factures el número de compte bancari parcial o complet"
msgid "Supplier Payment Mode"
msgstr "Mode de pagament del proveïdor"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, fuzzy, python-format

View File

@ -168,6 +168,11 @@ msgstr ""
msgid "Payment Modes"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -212,6 +217,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -169,6 +169,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Zahlungsmodi"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -213,6 +218,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr "Zahlungsmethode des Lieferanten"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -8,16 +8,16 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-23 03:38+0000\n"
"PO-Revision-Date: 2021-04-18 16:46+0000\n"
"POT-Creation-Date: 2021-05-25 12:38+0000\n"
"PO-Revision-Date: 2021-05-25 14:40+0200\n"
"Last-Translator: Nelson Ramírez Sánchez <info@konos.cl>\n"
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.3.2\n"
"X-Generator: Poedit 2.3\n"
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.account_payment_mode_form
@ -173,6 +173,11 @@ msgstr "Dominio de Tipo de Pago Modo Filtro"
msgid "Payment Modes"
msgstr "Modos de pago"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr "Modo de pago para rectificaciones"
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -221,6 +226,15 @@ msgstr "Mostrar en facturas nº de cuenta bancaria parcial o completo"
msgid "Supplier Payment Mode"
msgstr "Modo de pago de proveedor"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
"Este modo de pago se utilizará cuando se realicen facturas rectificativas "
"provenientes del modo de pago actual."
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 13.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2021-04-01 03:48+0000\n"
"PO-Revision-Date: 2021-05-30 19:48+0000\n"
"Last-Translator: Ignacio Buioli <ibuioli@gmail.com>\n"
"Language-Team: none\n"
"Language: es_AR\n"
@ -170,6 +170,11 @@ msgstr "Tipo de Filtro Dominio de Modo de Pago"
msgid "Payment Modes"
msgstr "Modos de Pago"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr "Modo de pago para reembolsos"
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -214,6 +219,15 @@ msgstr "Mostrar en las facturas el número de cuenta bancaria parcial o total"
msgid "Supplier Payment Mode"
msgstr "Modo de Pago del Proveedor"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
"Este modo de pago se utilizará cuando se realicen reembolsos provenientes "
"del modo de pago actual."
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -170,6 +170,11 @@ msgstr "Modo de pago Tipo de filtro Dominio"
msgid "Payment Modes"
msgstr "Modos de pago"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -214,6 +219,13 @@ msgstr "Mostrar en las facturas el número de cuenta bancaria total o parcial"
msgid "Supplier Payment Mode"
msgstr "Modo de pago del proveedor"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -171,6 +171,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Mode de paiement"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -215,6 +220,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr "Mode de règlement fournisseur"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, fuzzy, python-format

View File

@ -170,6 +170,11 @@ msgstr "Filtre de mode de paiement de type domaine"
msgid "Payment Modes"
msgstr "Mode de paiement"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -216,6 +221,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr "Mode de règlement fournisseur"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -168,6 +168,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Modeli plaćanja"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -212,6 +217,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -169,6 +169,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Betalinger"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -213,6 +218,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -173,6 +173,11 @@ msgstr ""
msgid "Payment Modes"
msgstr "Betaalwijze"
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -217,6 +222,13 @@ msgstr "Toon op facturen een gedeeltelijk of volledig bankrekeningnummer"
msgid "Supplier Payment Mode"
msgstr "Betaalwijze leverancier"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -168,6 +168,11 @@ msgstr ""
msgid "Payment Modes"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -212,6 +217,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr "Modo de Pagamento do Fornecedor"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -168,6 +168,11 @@ msgstr ""
msgid "Payment Modes"
msgstr ""
#. module: account_payment_partner
#: model:ir.model.fields,field_description:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid "Payment mode for refunds"
msgstr ""
#. module: account_payment_partner
#: model_terms:ir.ui.view,arch_db:account_payment_partner.view_move_line_form
msgid "Payments"
@ -212,6 +217,13 @@ msgstr ""
msgid "Supplier Payment Mode"
msgstr "Metoda plačila dobavitelja"
#. module: account_payment_partner
#: model:ir.model.fields,help:account_payment_partner.field_account_payment_mode__refund_payment_mode_id
msgid ""
"This payment mode will be used when doing refunds coming from the current "
"payment mode."
msgstr ""
#. module: account_payment_partner
#: code:addons/account_payment_partner/models/account_payment_mode.py:0
#, python-format

View File

@ -1,5 +1,6 @@
# Copyright 2014-16 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# Copyright 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from flectra import api, fields, models
@ -57,14 +58,27 @@ class AccountMove(models.Model):
for move in self:
move.payment_mode_id = False
if move.partner_id:
partner = move.with_company(move.company_id.id).partner_id
if move.move_type == "in_invoice":
move.payment_mode_id = move.with_company(
move.company_id.id
).partner_id.supplier_payment_mode_id
move.payment_mode_id = partner.supplier_payment_mode_id
elif move.move_type == "out_invoice":
move.payment_mode_id = move.with_company(
move.company_id.id
).partner_id.customer_payment_mode_id
move.payment_mode_id = partner.customer_payment_mode_id
elif (
move.move_type in ["out_refund", "in_refund"]
and move.reversed_entry_id
):
move.payment_mode_id = (
move.reversed_entry_id.payment_mode_id.refund_payment_mode_id
)
elif not move.reversed_entry_id:
if move.move_type == "out_refund":
move.payment_mode_id = (
partner.customer_payment_mode_id.refund_payment_mode_id
)
elif move.move_type == "in_refund":
move.payment_mode_id = (
partner.supplier_payment_mode_id.refund_payment_mode_id
)
@api.depends("partner_id", "payment_mode_id")
def _compute_partner_bank(self):
@ -90,13 +104,9 @@ class AccountMove(models.Model):
bank_id = get_bank_id()
move.partner_bank_id = bank_id
# I think copying payment mode from invoice to refund by default
# is a good idea because the most common way of "paying" a refund is to
# deduct it on the payment of the next invoice (and OCA/bank-payment
# allows to have negative payment lines since March 2016)
def _reverse_move_vals(self, default_values, cancel=True):
move_vals = super()._reverse_move_vals(default_values, cancel=cancel)
move_vals["payment_mode_id"] = self.payment_mode_id.id
move_vals["payment_mode_id"] = self.payment_mode_id.refund_payment_mode_id.id
if self.move_type == "in_invoice":
move_vals["partner_bank_id"] = self.partner_bank_id.id
return move_vals

View File

@ -1,5 +1,6 @@
# Copyright 2017 ForgeFlow S.L.
# Copyright 2018 Carlos Dauden - Tecnativa <carlos.dauden@tecnativa.com>
# Copyright 2018 Tecnativa - Carlos Dauden
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from flectra import _, api, fields, models
@ -24,6 +25,13 @@ class AccountPaymentMode(models.Model):
show_bank_account_chars = fields.Integer(
string="# of digits for customer bank account"
)
refund_payment_mode_id = fields.Many2one(
comodel_name="account.payment.mode",
domain="[('payment_type', '!=', payment_type)]",
string="Payment mode for refunds",
help="This payment mode will be used when doing "
"refunds coming from the current payment mode.",
)
@api.constrains("company_id")
def account_invoice_company_constrains(self):

View File

@ -9,13 +9,13 @@ class ResPartner(models.Model):
_inherit = "res.partner"
supplier_payment_mode_id = fields.Many2one(
"account.payment.mode",
comodel_name="account.payment.mode",
company_dependent=True,
domain="[('payment_type', '=', 'outbound')]",
help="Select the default payment mode for this supplier.",
)
customer_payment_mode_id = fields.Many2one(
"account.payment.mode",
comodel_name="account.payment.mode",
company_dependent=True,
domain="[('payment_type', '=', 'inbound')]",
help="Select the default payment mode for this customer.",

View File

@ -447,8 +447,9 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
<li>Danimar Ribeiro</li>
<li>Angel Moya &lt;<a class="reference external" href="mailto:angel.moya&#64;domatix.com">angel.moya&#64;domatix.com</a>&gt;</li>
<li><a class="reference external" href="https://www.tecnativa.com">Tecnativa</a>:<ul>
<li>Pedro M. Baeza &lt;<a class="reference external" href="mailto:pedro.baeza&#64;tecnativa.com">pedro.baeza&#64;tecnativa.com</a>&gt;</li>
<li>Carlos Dauden &lt;<a class="reference external" href="mailto:carlos.dauden&#64;tecnativa.com">carlos.dauden&#64;tecnativa.com</a>&gt;</li>
<li>Pedro M. Baeza</li>
<li>Carlos Dauden</li>
<li>Víctor Martínez</li>
</ul>
</li>
<li><a class="reference external" href="https://www.dynapps.be">DynApps</a>:<ul>

View File

@ -1,12 +1,14 @@
# Copyright 2017 ForgeFlow S.L.
# Copyright 2021 Tecnativa - Víctor Martínez
# License AGPL-3.0 or later (https://www.gnu.org/licenses/lgpl.html).
from flectra import _, fields
from flectra.exceptions import UserError, ValidationError
from flectra.tests import common
from flectra.fields import Date
from flectra.tests.common import Form, SavepointCase
class TestAccountPaymentPartner(common.SavepointCase):
class TestAccountPaymentPartner(SavepointCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
@ -20,6 +22,7 @@ class TestAccountPaymentPartner(common.SavepointCase):
# Refs
cls.company = cls.env.ref("base.main_company")
cls.acct_type_payable = cls.env.ref("account.data_account_type_payable")
cls.acct_type_receivable = cls.env.ref("account.data_account_type_receivable")
cls.acct_type_expenses = cls.env.ref("account.data_account_type_expenses")
cls.company_2 = cls.env["res.company"].create({"name": "Company 2"})
@ -106,9 +109,13 @@ class TestAccountPaymentPartner(common.SavepointCase):
"payment_method_id": cls.manual_in.id,
"company_id": cls.company.id,
"fixed_journal_id": cls.journal_c1.id,
"refund_payment_mode_id": cls.supplier_payment_mode.id,
"variable_journal_ids": [(6, 0, [cls.journal_c1.id])],
}
)
cls.supplier_payment_mode.write(
{"refund_payment_mode_id": cls.customer_payment_mode.id}
)
cls.customer = (
cls.env["res.partner"]
@ -186,33 +193,19 @@ class TestAccountPaymentPartner(common.SavepointCase):
}
)
def _create_invoice(self):
invoice = self.move_model.create(
{
"partner_id": self.supplier.id,
"journal_id": self.journal_purchase.id,
"move_type": "in_invoice",
"invoice_date": fields.Date.today(),
"company_id": self.company.id,
"payment_mode_id": self.env.ref(
"account_payment_mode.payment_mode_outbound_ct1"
).id,
"invoice_line_ids": [
(
0,
None,
{
"product_id": self.env.ref("product.product_product_4").id,
"quantity": 1.0,
"price_unit": 100.0,
"name": "product that cost 100",
"account_id": self.invoice_line_account.id,
},
)
],
}
def _create_invoice(self, default_move_type, partner):
move_form = Form(
self.env["account.move"].with_context(default_move_type=default_move_type)
)
return invoice
move_form.partner_id = partner
move_form.invoice_date = Date.today()
with move_form.invoice_line_ids.new() as line_form:
line_form.product_id = self.env.ref("product.product_product_4")
line_form.name = "product that cost 100"
line_form.quantity = 1.0
line_form.price_unit = 100.0
line_form.account_id = self.invoice_line_account
return move_form.save()
def test_create_partner(self):
customer = (
@ -282,14 +275,48 @@ class TestAccountPaymentPartner(common.SavepointCase):
self.assertEqual(invoice.payment_mode_id, self.payment_mode_model)
self.assertEqual(invoice.partner_bank_id, self.partner_bank_model)
def test_invoice_create(self):
invoice = self._create_invoice()
def test_invoice_create_in_invoice(self):
invoice = self._create_invoice(
default_move_type="in_invoice", partner=self.supplier
)
invoice.action_post()
aml = invoice.line_ids.filtered(
lambda l: l.account_id.user_type_id == self.acct_type_payable
)
self.assertEqual(invoice.payment_mode_id, aml[0].payment_mode_id)
def test_invoice_create_out_invoice(self):
invoice = self._create_invoice(
default_move_type="out_invoice", partner=self.customer
)
invoice.action_post()
aml = invoice.line_ids.filtered(
lambda l: l.account_id.user_type_id == self.acct_type_receivable
)
self.assertEqual(invoice.payment_mode_id, aml[0].payment_mode_id)
def test_invoice_create_out_refund(self):
self.manual_out.bank_account_required = False
invoice = self._create_invoice(
default_move_type="out_refund", partner=self.customer
)
invoice.action_post()
self.assertEqual(
invoice.payment_mode_id,
self.customer.customer_payment_mode_id.refund_payment_mode_id,
)
def test_invoice_create_in_refund(self):
self.manual_in.bank_account_required = False
invoice = self._create_invoice(
default_move_type="in_refund", partner=self.supplier
)
invoice.action_post()
self.assertEqual(
invoice.payment_mode_id,
self.supplier.supplier_payment_mode_id.refund_payment_mode_id,
)
def test_invoice_constrains(self):
with self.assertRaises(UserError):
self.move_model.create(
@ -351,8 +378,38 @@ class TestAccountPaymentPartner(common.SavepointCase):
with self.assertRaises(UserError):
self.supplier_payment_mode.company_id = self.company_2
def test_invoice_refund(self):
invoice = self._create_invoice()
def test_invoice_in_refund(self):
invoice = self._create_invoice(
default_move_type="in_invoice", partner=self.supplier
)
invoice.partner_bank_id = False
invoice.action_post()
# Lets create a refund invoice for invoice_1.
# I refund the invoice Using Refund Button.
refund_invoice_wizard = (
self.env["account.move.reversal"]
.with_context(
{
"active_ids": [invoice.id],
"active_id": invoice.id,
"active_model": "account.move",
}
)
.create({"refund_method": "refund", "reason": "reason test create"})
)
refund_invoice = self.move_model.browse(
refund_invoice_wizard.reverse_moves()["res_id"]
)
self.assertEqual(
refund_invoice.payment_mode_id,
invoice.payment_mode_id.refund_payment_mode_id,
)
self.assertEqual(refund_invoice.partner_bank_id, invoice.partner_bank_id)
def test_invoice_out_refund(self):
invoice = self._create_invoice(
default_move_type="out_invoice", partner=self.customer
)
invoice.partner_bank_id = False
invoice.action_post()
# Lets create a refund invoice for invoice_1.
@ -372,7 +429,10 @@ class TestAccountPaymentPartner(common.SavepointCase):
refund_invoice_wizard.reverse_moves()["res_id"]
)
self.assertEqual(refund_invoice.payment_mode_id, invoice.payment_mode_id)
self.assertEqual(
refund_invoice.payment_mode_id,
invoice.payment_mode_id.refund_payment_mode_id,
)
self.assertEqual(refund_invoice.partner_bank_id, invoice.partner_bank_id)
def test_partner(self):
@ -388,14 +448,22 @@ class TestAccountPaymentPartner(common.SavepointCase):
self.assertEqual(customer_invoice.payment_mode_id, self.customer_payment_mode)
self.assertEqual(self.supplier_invoice.partner_bank_id, self.supplier_bank)
vals = {"partner_id": self.customer.id, "move_type": "out_refund"}
invoice = self.move_model.new(vals)
self.assertEqual(invoice.payment_mode_id, self.supplier_payment_mode)
vals = {"partner_id": self.supplier.id, "move_type": "in_refund"}
invoice = self.move_model.new(vals)
self.assertEqual(invoice.payment_mode_id, self.customer_payment_mode)
vals = {"partner_id": False, "move_type": "out_invoice"}
invoice = self.move_model.new(vals)
self.assertFalse(invoice.payment_mode_id)
vals = {
"partner_id": False,
"move_type": "in_invoice",
"invoice_date": fields.Date.today(),
}
vals = {"partner_id": False, "move_type": "out_refund"}
invoice = self.move_model.new(vals)
self.assertFalse(invoice.partner_bank_id)
vals = {"partner_id": False, "move_type": "in_invoice"}
invoice = self.move_model.new(vals)
self.assertFalse(invoice.partner_bank_id)
vals = {"partner_id": False, "move_type": "in_refund"}
invoice = self.move_model.new(vals)
self.assertFalse(invoice.partner_bank_id)

View File

@ -6,6 +6,9 @@
<field name="model">account.payment.mode</field>
<field name="inherit_id" ref="account_payment_mode.account_payment_mode_form" />
<field name="arch" type="xml">
<field name="variable_journal_ids" position="before">
<field name="refund_payment_mode_id" />
</field>
<group name="note" position="before">
<group string="Show bank account in invoice report">
<group>