Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16 add account fix statement line creation #674

Open
wants to merge 2 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions account_fix_statement_line_creation/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
========================================
Account bank statement fix line creation
========================================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:cba093a615bb7c4b03e5b56ce538c39d55ee98e27f1bcb744fddf04ba90a46b3
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Faccount--reconcile-lightgray.png?logo=github
:target: https://github.com/OCA/account-reconcile/tree/16.0/account_fix_statement_line_creation
:alt: OCA/account-reconcile
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/account-reconcile-16-0/account-reconcile-16-0-account_fix_statement_line_creation
: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/account-reconcile&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|


This module fix bug about creation of new statement line on statement that contain
lines.
The bug is reported in this issue https://github.com/odoo/odoo/issues/171077

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/account-reconcile/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/account-reconcile/issues/new?body=module:%20account_fix_statement_line_creation%0Aversion:%2016.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.

Credits
=======

Authors
~~~~~~~

* Akretion

Contributors
~~~~~~~~~~~~

* Mourad EL HADJ MIMOUNE <[email protected]>


Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

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.

This module is part of the `OCA/account-reconcile <https://github.com/OCA/account-reconcile/tree/16.0/account_fix_statement_line_creation>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions account_fix_statement_line_creation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions account_fix_statement_line_creation/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)
{
"name": "Account bank statement fix line creation",
"version": "16.0.1.0.0",
"author": "Akretion, Odoo Community Association (OCA)",
"maintainer": "Akretion",
"category": "Hidden/Dependency",
"depends": [
"account",
],
"website": "https://github.com/OCA/account-reconcile",
"installable": True,
"license": "AGPL-3",
}
1 change: 1 addition & 0 deletions account_fix_statement_line_creation/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import account_bank_statement
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl)


from odoo import api, models


class AccountBankStatement(models.Model):
_inherit = "account.bank.statement"

# -------------------------------------------------------------------------
# COMPUTE METHODS
# -------------------------------------------------------------------------
@api.depends("line_ids.internal_index", "line_ids.state")
def _compute_date_index(self):
for stmt in self:
# When we create a new statement line for existing statement,
# internal_index field of line can be False
# And we can not sort str and bool type (python error)
# sort only line with internal_index != False to avoid bug when sort value from
# different type
sorted_lines = stmt.line_ids.filtered(lambda l: l.internal_index).sorted(
"internal_index"
)
if not sorted_lines:
sorted_lines = stmt.line_ids

Check warning on line 26 in account_fix_statement_line_creation/models/account_bank_statement.py

View check run for this annotation

Codecov / codecov/patch

account_fix_statement_line_creation/models/account_bank_statement.py#L26

Added line #L26 was not covered by tests
stmt.first_line_index = sorted_lines[:1].internal_index
stmt.date = sorted_lines.filtered(lambda l: l.state == "posted")[-1:].date
2 changes: 2 additions & 0 deletions account_fix_statement_line_creation/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
* Mourad EL HADJ MIMOUNE <[email protected]>

4 changes: 4 additions & 0 deletions account_fix_statement_line_creation/readme/DESCRIPTION.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

This module fix bug about creation of new statement line on statement that contain
lines.
The bug is reported in this issue https://github.com/odoo/odoo/issues/171077
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions account_fix_statement_line_creation/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from . import statement_line_creation
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2024 Akretion
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo.tests import tagged

from odoo.addons.account.tests.common import AccountTestInvoicingCommon


@tagged("post_install", "-at_install")
class TestAccountBankStatementLineCreation(AccountTestInvoicingCommon):
@classmethod
def setUpClass(cls, chart_template_ref=None):
super().setUpClass(chart_template_ref=chart_template_ref)

Check warning on line 13 in account_fix_statement_line_creation/tests/statement_line_creation.py

View check run for this annotation

Codecov / codecov/patch

account_fix_statement_line_creation/tests/statement_line_creation.py#L13

Added line #L13 was not covered by tests

cls.bank_journal_1 = cls.company_data["default_journal_bank"]
cls.currency_1 = cls.company_data["currency"]
cls.statement = cls.env["account.bank.statement"].create(

Check warning on line 17 in account_fix_statement_line_creation/tests/statement_line_creation.py

View check run for this annotation

Codecov / codecov/patch

account_fix_statement_line_creation/tests/statement_line_creation.py#L15-L17

Added lines #L15 - L17 were not covered by tests
{
"name": "test_statement",
"line_ids": [
(
0,
0,
{
"date": "2024-01-01",
"payment_ref": "line_1",
"journal_id": cls.bank_journal_1.id,
"amount": 1000.0,
},
),
],
}
)
cls.statement_line = cls.statement.line_ids

Check warning on line 34 in account_fix_statement_line_creation/tests/statement_line_creation.py

View check run for this annotation

Codecov / codecov/patch

account_fix_statement_line_creation/tests/statement_line_creation.py#L34

Added line #L34 was not covered by tests

def test_bank_statement_line_creation(self):
"""
Check that we can create a new statement.
"""
self.statement.line_ids.new()
self.statement._compute_date_index()
self.assertEqual(len(self.statement.line_ids), 2)

Check warning on line 42 in account_fix_statement_line_creation/tests/statement_line_creation.py

View check run for this annotation

Codecov / codecov/patch

account_fix_statement_line_creation/tests/statement_line_creation.py#L40-L42

Added lines #L40 - L42 were not covered by tests
Loading