Skip to content

Commit

Permalink
[ADD] eng_cnab_filename module
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed Feb 3, 2025
1 parent ae58e80 commit b7b3d5b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions eng_cnab_filename/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions eng_cnab_filename/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "CNAB Filename Sequence",
"summary": "Geração dos nomes de arquivo de remessa utilizando sequências do Odoo",
"license": "AGPL-3",
"author": "Engenere",
"maintainers": ["antoniospneto"],
"website": "https://engenere.one",
"version": "14.0.1.0.0",
"depends": ["l10n_br_account_payment_order"],
"data": [
"views/account_payment_mode.xml",
],
"installable": True,
}
2 changes: 2 additions & 0 deletions eng_cnab_filename/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import account_payment_order
from . import account_payment_mode
11 changes: 11 additions & 0 deletions eng_cnab_filename/models/account_payment_mode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from odoo import fields, models


class AccountPaymentMode(models.Model):
_inherit = "account.payment.mode"

filename_sequence_id = fields.Many2one(
comodel_name="ir.sequence",
string="Sequência do nome do arquivo",
tracking=True,
)
16 changes: 16 additions & 0 deletions eng_cnab_filename/models/account_payment_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from odoo import models


class AccountPaymentOrder(models.Model):
_inherit = "account.payment.order"

def get_file_name(self, cnab_type):
"""
Sobrescreve a lógica para a criação do nome a partir do sequenciador.
"""
sequence = self.payment_mode_id.filename_sequence_id
if sequence:
filename = f"{sequence.next_by_id()}.REM"
else:
filename = super().get_file_name(cnab_type)
return filename
17 changes: 17 additions & 0 deletions eng_cnab_filename/views/account_payment_mode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="eng_cnab_filename_payment_mode_form" model="ir.ui.view">
<field name="name">eng_cnab_filename.payment_mode.form</field>
<field name="model">account.payment.mode</field>
<field name="priority">99</field>
<field
name="inherit_id"
ref="l10n_br_account_payment_order.l10n_br_account_payment_mode_form"
/>
<field name="arch" type="xml">
<field name="cnab_sequence_id" position="after">
<field name="filename_sequence_id" />
</field>
</field>
</record>
</odoo>

0 comments on commit b7b3d5b

Please sign in to comment.