Skip to content

Commit

Permalink
[MIG] l10n_br_cnab_structure: Migration to 15.0
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniospneto committed Jul 26, 2024
1 parent 72772b8 commit 7536f2a
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 35 deletions.
10 changes: 5 additions & 5 deletions l10n_br_cnab_structure/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ CNAB Structure
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_cnab_structure
:target: https://github.com/OCA/l10n-brazil/tree/15.0/l10n_br_cnab_structure
:alt: OCA/l10n-brazil
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_cnab_structure
:target: https://translation.odoo-community.org/projects/l10n-brazil-15-0/l10n-brazil-15-0-l10n_br_cnab_structure
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=14.0
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=15.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|
Expand Down Expand Up @@ -55,7 +55,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-brazil/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_cnab_structure%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
`feedback <https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_cnab_structure%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Expand Down Expand Up @@ -109,6 +109,6 @@ Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-antoniospneto| |maintainer-felipemotter|

This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_cnab_structure>`_ project on GitHub.
This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/15.0/l10n_br_cnab_structure>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 1 addition & 1 deletion l10n_br_cnab_structure/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"summary": """
This module allows defining the structure for generating the CNAB file.
Used to exchange information with Brazilian banks.""",
"version": "14.0.1.2.0",
"version": "15.0.1.0.0",
"author": "Engenere, Escodoo, Odoo Community Association (OCA)",
"maintainers": ["antoniospneto", "felipemotter"],
"website": "https://github.com/OCA/l10n-brazil",
Expand Down
15 changes: 11 additions & 4 deletions l10n_br_cnab_structure/demo/account_journal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
<odoo noupdate="1">
<!-- Diario Itau -->
<record id="l10n_br_account_payment_order.itau_journal" model="account.journal">
<field
name="outbound_payment_method_ids"
eval="[(6,0,[ref('l10n_br_account_payment_order.payment_mode_type_cnab240_out')])]"
/>
<field name="used_to_import_cnab">True</field>
<field name="default_outbound_cnab_processor">oca_processor</field>
<field
Expand Down Expand Up @@ -47,4 +43,15 @@
ref="l10n_br_account_payment_order.1_account_template_32302_avoid_travis_error"
/>
</record>
<record
id="itau_journal_payment_method_cnab240_out"
model="account.payment.method.line"
>
<field name="name">ITAU CNAB 240</field>
<field
name="payment_method_id"
ref="l10n_br_account_payment_order.payment_mode_type_cnab240_out"
/>
<field name="journal_id" ref="l10n_br_account_payment_order.itau_journal" />
</record>
</odoo>
30 changes: 21 additions & 9 deletions l10n_br_cnab_structure/models/l10n_br_cnab_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,14 @@ def _get_reconciliation_items(self, move_id):
def _create_counterpart_move_line(self, move_id, partner_id):
if self.move_line_ids[0].balance < 0:
debit_or_credit = "credit"
account_id = self.journal_id.payment_credit_account_id
account_id = (
self.journal_id.company_id.account_journal_payment_credit_account_id
)
else:
debit_or_credit = "debit"
account_id = self.journal_id.payment_debit_account_id
account_id = (
self.journal_id.company_id.account_journal_payment_debit_account_id
)
move_line_obj = self.env["account.move.line"]
counterpart_vals = {
"move_id": move_id.id,
Expand All @@ -282,7 +286,9 @@ def _create_tariff_move_lines(self, move_id):
{
"name": "Bank Tariff: " + self.your_number,
"credit": self.tariff_charge,
"account_id": self.journal_id.payment_credit_account_id.id,
"account_id": (
self.journal_id.company_id.account_journal_payment_credit_account_id.id
),
"partner_id": self.move_line_ids[0].partner_id.id,
"move_id": move_id.id,
}
Expand Down Expand Up @@ -341,7 +347,9 @@ def _create_rebate_move_lines(self, move_id):
if self.cnab_return_log_id.type == "inbound":
credit_move_line[
"account_id"
] = self.journal_id.payment_credit_account_id.id
] = (
self.journal_id.company_id.account_journal_payment_credit_account_id.id
)
debit_move_line[
"account_id"
] = self.journal_id.inbound_rebate_account_id.id
Expand All @@ -351,7 +359,7 @@ def _create_rebate_move_lines(self, move_id):
] = self.journal_id.outbound_rebate_account_id.id
debit_move_line[

Check warning on line 360 in l10n_br_cnab_structure/models/l10n_br_cnab_event.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/models/l10n_br_cnab_event.py#L360

Added line #L360 was not covered by tests
"account_id"
] = self.journal_id.payment_debit_account_id.id
] = self.journal_id.company_id.account_journal_payment_debit_account_id

move_line_obj.with_context(check_move_validity=False).create(
[credit_move_line, debit_move_line]
Expand All @@ -375,7 +383,9 @@ def _create_discount_move_lines(self, move_id):
if self.cnab_return_log_id.type == "inbound":
credit_move_line[
"account_id"
] = self.journal_id.payment_credit_account_id.id
] = (
self.journal_id.company_id.account_journal_payment_credit_account_id.id
)
debit_move_line[
"account_id"
] = self.journal_id.inbound_discount_account_id.id
Expand All @@ -385,7 +395,7 @@ def _create_discount_move_lines(self, move_id):
] = self.journal_id.outbound_discount_account_id.id
debit_move_line[

Check warning on line 396 in l10n_br_cnab_structure/models/l10n_br_cnab_event.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/models/l10n_br_cnab_event.py#L396

Added line #L396 was not covered by tests
"account_id"
] = self.journal_id.payment_debit_account_id.id
] = self.journal_id.company_id.account_journal_payment_debit_account_id

move_line_obj.with_context(check_move_validity=False).create(
[credit_move_line, debit_move_line]
Expand All @@ -412,11 +422,13 @@ def _create_fees_move_lines(self, move_id):
] = self.journal_id.inbound_interest_fee_account_id.id
debit_move_line[

Check warning on line 423 in l10n_br_cnab_structure/models/l10n_br_cnab_event.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/models/l10n_br_cnab_event.py#L423

Added line #L423 was not covered by tests
"account_id"
] = self.journal_id.payment_debit_account_id.id
] = self.journal_id.company_id.account_journal_payment_debit_account_id
else:
credit_move_line[

Check warning on line 427 in l10n_br_cnab_structure/models/l10n_br_cnab_event.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/models/l10n_br_cnab_event.py#L427

Added line #L427 was not covered by tests
"account_id"
] = self.journal_id.payment_credit_account_id.id
] = (
self.journal_id.company_id.account_journal_payment_credit_account_id.id
)
debit_move_line[

Check warning on line 432 in l10n_br_cnab_structure/models/l10n_br_cnab_event.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/models/l10n_br_cnab_event.py#L432

Added line #L432 was not covered by tests
"account_id"
] = self.journal_id.outbound_interest_fee_account_id.id
Expand Down
17 changes: 10 additions & 7 deletions l10n_br_cnab_structure/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

/*
:Author: David Goodger ([email protected])
:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $
:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
Despite the name, some widely supported CSS2 features are used.

See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to
customize this style sheet.
Expand Down Expand Up @@ -274,7 +275,7 @@
margin-left: 2em ;
margin-right: 2em }

pre.code .ln { color: grey; } /* line numbers */
pre.code .ln { color: gray; } /* line numbers */
pre.code, code { background-color: #eeeeee }
pre.code .comment, code .comment { color: #5C6576 }
pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold }
Expand All @@ -300,7 +301,7 @@
span.pre {
white-space: pre }

span.problematic {
span.problematic, pre.problematic {
color: red }

span.section-subtitle {
Expand Down Expand Up @@ -368,7 +369,7 @@ <h1 class="title">CNAB Structure</h1>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:96ca0f1eb804341d0e36d4d79df0162d6a5e3be4ee9f214c6e217d9a00027048
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_cnab_structure"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-l10n_br_cnab_structure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&amp;target_branch=14.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/l10n-brazil/tree/15.0/l10n_br_cnab_structure"><img alt="OCA/l10n-brazil" src="https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-brazil-15-0/l10n-brazil-15-0-l10n_br_cnab_structure"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&amp;target_branch=15.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>This module adds functionality for implementing brazilian banking automation by CNAB file exchange.</p>
<p><strong>Table of contents</strong></p>
<div class="contents local topic" id="contents">
Expand Down Expand Up @@ -405,7 +406,7 @@ <h1><a class="toc-backref" href="#toc-entry-4">Bug Tracker</a></h1>
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/l10n-brazil/issues">GitHub Issues</a>.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
<a class="reference external" href="https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_cnab_structure%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<a class="reference external" href="https://github.com/OCA/l10n-brazil/issues/new?body=module:%20l10n_br_cnab_structure%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
<p>Do not contact contributors directly about support or help with technical issues.</p>
</div>
<div class="section" id="credits">
Expand Down Expand Up @@ -438,13 +439,15 @@ <h2><a class="toc-backref" href="#toc-entry-8">Other credits</a></h2>
<div class="section" id="maintainers">
<h2><a class="toc-backref" href="#toc-entry-9">Maintainers</a></h2>
<p>This module is maintained by the OCA.</p>
<a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a>
<a class="reference external image-reference" href="https://odoo-community.org">
<img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" />
</a>
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.</p>
<p>Current <a class="reference external" href="https://odoo-community.org/page/maintainer-role">maintainers</a>:</p>
<p><a class="reference external image-reference" href="https://github.com/antoniospneto"><img alt="antoniospneto" src="https://github.com/antoniospneto.png?size=40px" /></a> <a class="reference external image-reference" href="https://github.com/felipemotter"><img alt="felipemotter" src="https://github.com/felipemotter.png?size=40px" /></a></p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-brazil/tree/14.0/l10n_br_cnab_structure">OCA/l10n-brazil</a> project on GitHub.</p>
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/l10n-brazil/tree/15.0/l10n_br_cnab_structure">OCA/l10n-brazil</a> project on GitHub.</p>
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_cnab_structure/tests/test_cnab_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def test_field_select_wizard(self):

field_select_wizard = (
self.env[wiz_action["res_model"]]
.with_context(wiz_action["context"])
.with_context(**wiz_action["context"])
.create({})
)

Expand Down
4 changes: 2 additions & 2 deletions l10n_br_cnab_structure/tests/test_return_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def test_move_create(self):
lambda line: line.account_id
in (
self.bank_journal_itau.default_account_id,
self.bank_journal_itau.payment_debit_account_id,
self.bank_journal_itau.payment_credit_account_id,
self.bank_journal_itau.company_id.account_journal_payment_debit_account_id,
self.bank_journal_itau.company_id.account_journal_payment_credit_account_id,
)
)
rebate_moves = event.generated_move_id.line_ids.filtered(
Expand Down
6 changes: 2 additions & 4 deletions l10n_br_cnab_structure/views/journal_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
<field name="model">account.journal</field>
<field name="inherit_id" ref="account.view_account_journal_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='journal_entries']/group" position="after">
<xpath expr="//page[@name='bank_account']/group" position="after">
<separator string="Import CNAB" />
<group>
<field name="used_to_import_cnab" />
</group>
</xpath>
<xpath expr="//page[@name='journal_entries']" position="after">
<xpath expr="//page[@name='bank_account']" position="after">
<page name="cnab_configuration" string="CNAB Configuration">
<group name="outbound" string="Outgoing Payments">
<div
Expand All @@ -28,8 +28,6 @@
<field name="default_outbound_cnab_structure_id" />
</group>
</page>
</xpath>
<xpath expr="//page[@name='journal_entries']" position="after">
<page
name="cnab_accounts"
string="CNAB Accounts"
Expand Down
6 changes: 4 additions & 2 deletions l10n_br_cnab_structure/wizard/cnab_import_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ def _onchange_journal_id(self):
def _compute_payment_method_ids(self):
for record in self:
if record.type == "inbound":
record.payment_method_ids = record.journal_id.inbound_payment_method_ids
record.payment_method_ids = (

Check warning on line 76 in l10n_br_cnab_structure/wizard/cnab_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/wizard/cnab_import_wizard.py#L76

Added line #L76 was not covered by tests
record.journal_id.inbound_payment_method_line_ids.payment_method_id
)
elif record.type == "outbound":
record.payment_method_ids = (

Check warning on line 80 in l10n_br_cnab_structure/wizard/cnab_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/wizard/cnab_import_wizard.py#L80

Added line #L80 was not covered by tests
record.journal_id.outbound_payment_method_ids
record.journal_id.outbound_payment_method_line_ids.payment_method_id
)
else:
record.payment_method_ids = [(5, 0, 0)]

Check warning on line 84 in l10n_br_cnab_structure/wizard/cnab_import_wizard.py

View check run for this annotation

Codecov / codecov/patch

l10n_br_cnab_structure/wizard/cnab_import_wizard.py#L84

Added line #L84 was not covered by tests
Expand Down

0 comments on commit 7536f2a

Please sign in to comment.