Skip to content

Commit

Permalink
[MIG] l10n_br_account_payment_order: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed Jul 25, 2024
1 parent 1c83954 commit e964bda
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 37 deletions.
11 changes: 7 additions & 4 deletions l10n_br_account_payment_brcobranca/models/account_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,15 @@ def _get_moves(self, parser, result_row_list):
parser_vals = parser.get_move_line_vals(line)
values = self.prepare_move_line_vals(parser_vals, move)
move_store.append(values)
move_line_obj.with_context(check_move_validity=False).create(move_store)
self._write_extra_move_lines(parser, move)
move_store += self._get_extra_move_line_vals_list(parser, move)
if self.create_counterpart:
self._create_counterpart(parser, move)
move_store += self._get_counterpart_vals_list(
parser, move, move_store
)
# Check if move is balanced
move._check_balanced()
container = {"records": move}
with move._check_balanced(container):
move_line_obj.create(move_store)
# Computed total amount of the move
# move._amount_compute()
# No caso do CNAB o arquivo usado está sendo armazenado no
Expand Down
32 changes: 22 additions & 10 deletions l10n_br_account_payment_brcobranca/tests/test_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from odoo.exceptions import UserError
from odoo.modules import get_resource_path
from odoo.tests import Form, SavepointCase, tagged
from odoo.tests import Form, TransactionCase, tagged

_module_ns = "odoo.addons.l10n_br_account_payment_brcobranca"
_provider_class_pay_order = (
Expand All @@ -18,7 +18,7 @@


@tagged("post_install", "-at_install")
class TestPaymentOrder(SavepointCase):
class TestPaymentOrder(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand Down Expand Up @@ -299,9 +299,11 @@ def test_payment_outside_cnab_writeoff_and_change_tittle_value(self):
.create(
{
"payment_type": "inbound",
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_in"
).id,
"payment_method_line_id": (
self.journal_cash._get_available_payment_method_lines("inbound")
.filtered(lambda x: x.code == "manual")
.id
),
"partner_type": "customer",
"partner_id": self.partner_akretion.id,
"amount": 600,
Expand Down Expand Up @@ -796,7 +798,11 @@ def test_payment(self):
)
)
payment_register.journal_id = self.journal_cash
payment_register.payment_method_id = self.payment_method_manual_in
payment_register.payment_method_line_id = (
self.journal_cash._get_available_payment_method_lines("inbound").filtered(
lambda x: x.code == "manual"
)
)

# Perform the partial payment by setting the amount at 300 instead of 500
payment_register.amount = 100
Expand Down Expand Up @@ -851,7 +857,11 @@ def test_payment(self):
)
)
payment_register.journal_id = self.journal_cash
payment_register.payment_method_id = self.payment_method_manual_in
payment_register.payment_method_line_id = (
self.journal_cash._get_available_payment_method_lines("inbound").filtered(
lambda x: x.code == "manual"
)
)

# Perform the partial payment by setting the amount at 300 instead of 500
payment_register.amount = 50
Expand Down Expand Up @@ -907,9 +917,11 @@ def test_payment(self):
.create(
{
"payment_type": "inbound",
"payment_method_id": self.env.ref(
"account.account_payment_method_manual_in"
).id,
"payment_method_line_id": (
self.journal_cash._get_available_payment_method_lines("inbound")
.filtered(lambda x: x.code == "manual")
.id
),
"partner_type": "customer",
"partner_id": self.partner_akretion.id,
"amount": 150,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from unittest import mock

from odoo.modules import get_resource_path
from odoo.tests import SavepointCase, tagged
from odoo.tests import TransactionCase, tagged

_module_ns = "odoo.addons.l10n_br_account_payment_brcobranca"
_provider_class_pay_order = (
Expand All @@ -19,7 +19,7 @@


@tagged("post_install", "-at_install")
class TestReturnImport(SavepointCase):
class TestReturnImport(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
Expand All @@ -35,7 +35,7 @@ def setUpClass(cls):
{
"code": "X1014",
"name": "Bank Current Account - (test)",
"user_type_id": cls.env.ref("account.data_account_type_liquidity").id,
"account_type": "asset_cash",
}
)
cls.import_wizard_obj = cls.env["credit.statement.import"]
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_account_payment_order/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Brazilian Payment Order",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "KMEE, Akretion, Odoo Community Association (OCA)",
"maintainers": ["mbcosta"],
Expand Down
28 changes: 14 additions & 14 deletions l10n_br_account_payment_order/demo/account_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
model="account.account"
id="1_account_template_3010101010200_avoid_travis_error"
>
<field name="code">3.01.01.01.01.02.00</field>
<field name="code">3010101010200</field>
<field name="name">Receita da Venda no Mercado Interno
de Produtos de Fabricação Própria - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_revenue" />
<field name="account_type">income</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>
Expand All @@ -19,54 +19,54 @@
model="account.account"
id="1_account_template_3010101010300_avoid_travis_error"
>
<field name="code">3.01.01.01.01.03.00-*</field>
<field name="code">3010101010300</field>
<field name="name">Taxa do Boleto - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_revenue" />
<field name="account_type">income</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>

<!-- Conta Contabil de Tarifa Bancaria para Modo de Pagamento -->
<record model="account.account" id="1_account_template_32302_avoid_travis_error">
<field name="code">3.2.3.02-*</field>
<field name="code">32302</field>
<field name="name">Outras Despesas Financeiras - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_expenses" />
<field name="account_type">expense</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>

<!-- Conta Contabil de Juros/Multa para Modo de Pagamento -->
<record model="account.account" id="1_account_template_31202_avoid_travis_error">
<field name="code">3.1.2.02-*</field>
<field name="code">31202</field>
<field name="name">Juros Ativos - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_revenue" />
<field name="account_type">income</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>

<!-- Conta Contabil de Desconto para Modo de Pagamento -->
<record model="account.account" id="1_account_template_32202_avoid_travis_error">
<field name="code">3.2.2.02-*</field>
<field name="code">32202</field>
<field name="name">Despesas com Vendas - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_expenses" />
<field name="account_type">expense</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>

<!-- Conta Contabil de Abatimento para Modo de Pagamento -->
<record model="account.account" id="1_account_template_32203_avoid_travis_error">
<field name="code">3.2.2.03-*</field>
<field name="code">32203</field>
<field name="name">Outras Despesas Gerais - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_expenses" />
<field name="account_type">expense</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>

<!-- Conta Contabil de Não Pagamento/Inadimplencia para Modo de Pagamento -->
<record model="account.account" id="1_account_template_32333_avoid_travis_error">
<field name="code">3.2.3.33-*</field>
<field name="code">32333</field>
<field name="name"> Não Pagamento/Inadimplencia - AVOID_TRAVIS_ERROR</field>
<field name="user_type_id" ref="account.data_account_type_expenses" />
<field name="account_type">expense</field>
<field name="company_id" ref="base.main_company" />
<field name="reconcile" eval="True" />
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def draft2open(self):
"paylines": payline,
"total": payline.amount_currency,
}
order.recompute()
order.env.flush_all()
# Create account payments
payment_vals = []
for paydict in list(group_paylines.values()):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def test_payment_outside_cnab_payment_order_draft(self):

self.assertAlmostEqual(payment.amount, 1000)
self.assertEqual(payment.state, "posted")
self.assertEqual(self.invoice_unicred.payment_state, "paid")
self.assertEqual(self.invoice_unicred.payment_state, "in_payment")
# Linhas Apagadas
self.assertEqual(len(payment_order.payment_line_ids), 0)

Expand Down Expand Up @@ -316,7 +316,7 @@ def test_payment_inbound_payment_in_cash_full(self):
# I verify that invoice is now in Paid state
self.assertEqual(
self.demo_invoice_auto.payment_state,
"paid",
"in_payment",
"Invoice is not in Paid state",
)

Expand Down Expand Up @@ -412,7 +412,7 @@ def test_payment_inbound_payment_in_cash_twice(self):
# I verify that invoice is now in Paid state
self.assertEqual(
self.demo_invoice_auto.payment_state,
"paid",
"in_payment",
"Invoice is not in Paid state",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<field name="priority">99</field>
<field
name="inherit_id"
ref="payment.view_account_payment_form_inherit_payment"
ref="account_payment.view_account_payment_form_inherit_payment"
/>
<field name="arch" type="xml">

Expand Down

0 comments on commit e964bda

Please sign in to comment.