Skip to content

Commit

Permalink
Merge PR #3365 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by rvalyi
  • Loading branch information
OCA-git-bot committed Sep 23, 2024
2 parents 892f6f6 + 2bc5db9 commit 01e8327
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 675 deletions.
1 change: 0 additions & 1 deletion l10n_br_account_payment_brcobranca/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
from . import account_payment_order
from . import account_payment_line
from . import account_journal
from . import account_payment_mode
from . import l10n_br_cnab_config
22 changes: 0 additions & 22 deletions l10n_br_account_payment_brcobranca/models/account_payment_mode.py

This file was deleted.

5 changes: 1 addition & 4 deletions 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": "14.0.8.0.0",
"version": "14.0.9.0.0",
"license": "AGPL-3",
"author": "KMEE, Akretion, Odoo Community Association (OCA)",
"maintainers": ["mbcosta"],
Expand Down Expand Up @@ -53,11 +53,8 @@
"views/account_payment_mode.xml",
"views/l10n_br_cnab_return_log_view.xml",
"views/account_move_line.xml",
"views/l10n_br_cnab_return_move_code_view.xml",
"views/account_payment_views.xml",
"views/l10n_br_cnab_mov_instruction_code_view.xml",
"views/account_move_view.xml",
"views/l10n_br_cnab_boleto_wallet_code_view.xml",
# Códigos CNAB
"views/l10n_br_cnab_code_view.xml",
"views/l10n_br_cnab_config_view.xml",
Expand Down
105 changes: 105 additions & 0 deletions l10n_br_account_payment_order/migrations/14.0.9.0.0/pre-migration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# Copyright (C) 2024-Today - Akretion (<http://www.akretion.com>).
# @author Magno Costa <[email protected]>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from openupgradelib import openupgrade


def update_model_data(env):
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_model_data SET model = 'l10n_br_cnab.code'
WHERE model = 'l10n_br_cnab.mov.instruction.code'
""",
)
# Codigo de Retorno
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_model_data SET model = 'l10n_br_cnab.code'
WHERE model = 'l10n_br_cnab.return.move.code'
""",
)
# Codigo Carteira
openupgrade.logged_query(
env.cr,
"""
UPDATE ir_model_data SET model = 'l10n_br_cnab.code'
WHERE model = 'l10n_br_cnab.boleto.wallet.code'
""",
)


def delete_obsolete_models(env):
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model_fields WHERE model = 'l10n_br_cnab.mov.instruction.code'
""",
)
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model WHERE model = 'l10n_br_cnab.mov.instruction.code'
""",
)
# Codigo de Retorno
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model_fields WHERE model = 'l10n_br_cnab.return.move.code'
""",
)
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model WHERE model = 'l10n_br_cnab.return.move.code'
""",
)
# Codigo Carteira
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model_fields WHERE model = 'l10n_br_cnab.boleto.wallet.code'
""",
)
openupgrade.logged_query(
env.cr,
"""
DELETE FROM ir_model WHERE model = 'l10n_br_cnab.boleto.wallet.code'
""",
)


def delete_obsolete_data(env):
openupgrade.logged_query(
env.cr,
"""
DELETE FROM l10n_br_cnab_mov_instruction_code
""",
)

# Codigo de Retorno
# Data
openupgrade.logged_query(
env.cr,
"""
DELETE FROM l10n_br_cnab_return_move_code
""",
)
# Codigo Carteira
# Data
openupgrade.logged_query(
env.cr,
"""
DELETE FROM l10n_br_cnab_boleto_wallet_code
""",
)


@openupgrade.migrate(use_env=True)
def migrate(env, version):
update_model_data(env)
delete_obsolete_models(env)
delete_obsolete_data(env)
3 changes: 0 additions & 3 deletions l10n_br_account_payment_order/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,5 @@
from . import l10n_br_cnab_return_log
from . import ir_attachment
from . import l10n_br_cnab_data_abstract
from . import l10n_br_cnab_return_move_code
from . import l10n_br_cnab_mov_intruction_code
from . import l10n_br_cnab_boleto_wallet_code
from . import l10n_br_cnab_code
from . import l10n_br_cnab_config
8 changes: 0 additions & 8 deletions l10n_br_account_payment_order/models/account_move_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@ class AccountMoveLine(models.Model):
copy=False,
)

# TODO: Remover o campo na próxima versão,
# usando apenas para migração para o l10n_br_cnab.code
mov_instruction_code_id = fields.Many2one(
comodel_name="l10n_br_cnab.mov.instruction.code",
string="Código da Instrução para Movimento",
help="Campo G061 do CNAB",
copy=False,
)
instruction_move_code_id = fields.Many2one(
comodel_name="l10n_br_cnab.code",
string="Código da Instrução para Movimento",
Expand Down
7 changes: 0 additions & 7 deletions l10n_br_account_payment_order/models/account_payment_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,6 @@ class AccountPaymentLine(models.Model):
default="0",
)

# TODO: Remover o campo na próxima versão,
# usando apenas para migração para o l10n_br_cnab.code
mov_instruction_code_id = fields.Many2one(
comodel_name="l10n_br_cnab.mov.instruction.code",
string="Código da Instrução para Movimento",
help="Campo G061 do CNAB",
)
instruction_move_code_id = fields.Many2one(
comodel_name="l10n_br_cnab.code",
string="Código da Instrução para Movimento",
Expand Down
59 changes: 3 additions & 56 deletions l10n_br_account_payment_order/models/account_payment_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
from odoo import _, api, fields, models
from odoo.exceptions import ValidationError

from ..constants import BR_CODES_PAYMENT_ORDER, FORMA_LANCAMENTO, TIPO_SERVICO
from ..constants import BR_CODES_PAYMENT_ORDER


class AccountPaymentMode(models.Model):
_name = "account.payment.mode"
_inherit = [
"account.payment.mode",
"l10n_br_cnab.boleto.fields",
"l10n_br_cnab.payment.fields",
"mail.thread",
]

Expand Down Expand Up @@ -44,24 +42,6 @@ class AccountPaymentMode(models.Model):
help="Cria a ordem de pagamento automaticamente ao confirmar a fatura",
)

service_type = fields.Selection(
selection=TIPO_SERVICO,
string="Tipo de Serviço",
help="Campo G025 do CNAB",
)

release_form = fields.Selection(
selection=FORMA_LANCAMENTO,
string="Forma Lançamento",
help="Campo G029 do CNAB",
)

cnab_sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Sequencia do Arquivo CNAB",
tracking=True,
)

# Fields used to make invisible banks specifics fields
bank_id = fields.Many2one(
related="fixed_journal_id.bank_id",
Expand All @@ -71,6 +51,8 @@ class AccountPaymentMode(models.Model):
related="fixed_journal_id.bank_id.code_bc",
)

# TODO: Necessário adaptar o modulo l10n_br_cnab_structure
# para a Separação da Configuração CNAB do Modo de Pagto
cnab_processor = fields.Selection(
selection="_selection_cnab_processor",
)
Expand All @@ -80,41 +62,6 @@ def _selection_cnab_processor(self):
# Method to be extended by modules that implement CNAB processors.
return []

# Codigos de Retorno do Movimento

# TODO: Campos many2many não estão sendo registrados pelo track_visibility.
# Debate no Odoo https://github.com/odoo/odoo/issues/10149
# Modulo na OCA v10 que faria isso
# https://github.com/OCA/social/tree/10.0/mail_improved_tracking_value
# Migração do Modulo para a v12 https://github.com/OCA/social/pull/677
# Devemos incluir esse modulo nas Dependencias OCA para poder usa-lo aqui
# já que sem ele o campo que armazena os codigos que devem ser usados para
# Baixa/Liquidação está sem a rastreabilidade a outra opção seria usar o
# modulo auditlog https://github.com/OCA/server-tools/tree/12.0/auditlog.

# TODO: Ligação com o payment_mode_id não permite extrair para o objeto
# l10n_br_cnab.boleto.fields, teria alguma forma de fazer ?
# Podem existir diferentes codigos, mesmo no 240

# TODO: Remover o campo na próxima versão,
# usando apenas para migração para o l10n_br_cnab.code
cnab_liq_return_move_code_ids = fields.Many2many(
comodel_name="l10n_br_cnab.return.move.code",
relation="l10n_br_cnab_return_liquidity_move_code_rel",
column1="cnab_liq_return_move_code_id",
column2="payment_mode_id",
string="CNAB Liquidity Return Move Code",
tracking=True,
)
liq_return_move_code_ids = fields.Many2many(
comodel_name="l10n_br_cnab.code",
relation="l10n_br_cnab_liq_return_move_code_rel",
column1="liq_return_move_code_id",
column2="payment_mode_id",
string="CNAB Liquidity Return Move Code",
tracking=True,
)

@api.constrains(
"fixed_journal_id",
"group_lines",
Expand Down
Loading

0 comments on commit 01e8327

Please sign in to comment.