From 86111d347cca0d77bd5a4270ce10440cee478879 Mon Sep 17 00:00:00 2001 From: pilarvargas-tecnativa Date: Fri, 25 Oct 2024 18:04:35 +0200 Subject: [PATCH] [MIG] account_statement_import_move_line: Migration to version 17.0 TT51242 --- account_statement_import_move_line/README.rst | 20 +++++--- .../__manifest__.py | 5 +- .../readme/CONTRIBUTORS.md | 1 + .../readme/USAGE.md | 14 +++--- .../static/description/index.html | 19 +++++--- ...account_bank_statement_import_move_line.py | 32 +++---------- .../views/account_bank_statement_view.xml | 21 ++++++--- .../views/account_journal_dashboard_view.xml | 17 +++++++ .../wizards/account_statement_line_create.py | 46 +++++++++++++++---- .../account_statement_line_create_view.xml | 45 ++++++++++-------- 10 files changed, 137 insertions(+), 83 deletions(-) create mode 100644 account_statement_import_move_line/views/account_journal_dashboard_view.xml diff --git a/account_statement_import_move_line/README.rst b/account_statement_import_move_line/README.rst index b1a4e7b7..dcde01e4 100644 --- a/account_statement_import_move_line/README.rst +++ b/account_statement_import_move_line/README.rst @@ -49,14 +49,19 @@ To configure this module, you need to: Usage ===== +Journal entries can be imported in two ways, from a new bank statement +or from an existing bank statement. + 1. Go to Invoicing > Dashboard. -2. Create a new bank statement from a bank journal. -3. Click button "Import Journal Items". -4. Select filtering options. -5. Click on button "Add All Move Lines" to auto-select the move lines - matching the selected criteria or click on Add an item to manually - select the move lines filtered by the criteria. -6. Click on button "Create Statement Lines". +2. To import to a new statement, in the relevant bank journal click on + ‘Import journal items’. To import from an existing bank statement, + open the statement form and click on ‘Import journal items’. +3. Select the filtering options. +4. Click on the ‘Add all transaction lines’ button to automatically + select the transaction lines matching the selected criteria or click + on Add an item to manually select the transaction lines filtered by + the criteria. +5. Click the ‘Create extract lines’ button. Bug Tracker =========== @@ -85,6 +90,7 @@ Contributors - Victor M.M. Torres - João Marques - Ernesto García + - Pilar Vargas - Pedro Gonzalez diff --git a/account_statement_import_move_line/__manifest__.py b/account_statement_import_move_line/__manifest__.py index 2c0c1aba..cbd32448 100644 --- a/account_statement_import_move_line/__manifest__.py +++ b/account_statement_import_move_line/__manifest__.py @@ -3,17 +3,18 @@ { "name": "Bank statement import move lines", - "version": "15.0.1.0.0", + "version": "17.0.1.0.0", "category": "Accounting", "summary": "Import journal items into bank statement", "author": "Tecnativa, " "Odoo Community Association (OCA)", "maintainers": ["pedrobaeza"], "website": "https://github.com/OCA/bank-statement-import", - "depends": ["account"], + "depends": ["account_statement_base"], "data": [ "security/ir.model.access.csv", "wizards/account_statement_line_create_view.xml", "views/account_bank_statement_view.xml", + "views/account_journal_dashboard_view.xml", ], "license": "AGPL-3", "development_status": "Production/Stable", diff --git a/account_statement_import_move_line/readme/CONTRIBUTORS.md b/account_statement_import_move_line/readme/CONTRIBUTORS.md index 1517694c..09440b59 100644 --- a/account_statement_import_move_line/readme/CONTRIBUTORS.md +++ b/account_statement_import_move_line/readme/CONTRIBUTORS.md @@ -3,4 +3,5 @@ - Victor M.M. Torres - João Marques - Ernesto García + - Pilar Vargas - Pedro Gonzalez \<\> diff --git a/account_statement_import_move_line/readme/USAGE.md b/account_statement_import_move_line/readme/USAGE.md index 3223a4a0..12aac794 100644 --- a/account_statement_import_move_line/readme/USAGE.md +++ b/account_statement_import_move_line/readme/USAGE.md @@ -1,8 +1,6 @@ -1. Go to Invoicing \> Dashboard. -2. Create a new bank statement from a bank journal. -3. Click button "Import Journal Items". -4. Select filtering options. -5. Click on button "Add All Move Lines" to auto-select the move lines - matching the selected criteria or click on Add an item to manually - select the move lines filtered by the criteria. -6. Click on button "Create Statement Lines". +Journal entries can be imported in two ways, from a new bank statement or from an existing bank statement. +1. Go to Invoicing > Dashboard. +2. To import to a new statement, in the relevant bank journal click on ‘Import journal items’. To import from an existing bank statement, open the statement form and click on ‘Import journal items’. +3. Select the filtering options. +5. Click on the ‘Add all transaction lines’ button to automatically select the transaction lines matching the selected criteria or click on Add an item to manually select the transaction lines filtered by the criteria. +6. Click the ‘Create extract lines’ button. diff --git a/account_statement_import_move_line/static/description/index.html b/account_statement_import_move_line/static/description/index.html index b044a25e..8a830532 100644 --- a/account_statement_import_move_line/static/description/index.html +++ b/account_statement_import_move_line/static/description/index.html @@ -398,15 +398,19 @@ into the bank statement.

Usage

+

Journal entries can be imported in two ways, from a new bank statement +or from an existing bank statement.

  1. Go to Invoicing > Dashboard.
  2. -
  3. Create a new bank statement from a bank journal.
  4. -
  5. Click button “Import Journal Items”.
  6. -
  7. Select filtering options.
  8. -
  9. Click on button “Add All Move Lines” to auto-select the move lines -matching the selected criteria or click on Add an item to manually -select the move lines filtered by the criteria.
  10. -
  11. Click on button “Create Statement Lines”.
  12. +
  13. To import to a new statement, in the relevant bank journal click on +‘Import journal items’. To import from an existing bank statement, +open the statement form and click on ‘Import journal items’.
  14. +
  15. Select the filtering options.
  16. +
  17. Click on the ‘Add all transaction lines’ button to automatically +select the transaction lines matching the selected criteria or click +on Add an item to manually select the transaction lines filtered by +the criteria.
  18. +
  19. Click the ‘Create extract lines’ button.
@@ -433,6 +437,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
  • Victor M.M. Torres
  • João Marques
  • Ernesto García
  • +
  • Pilar Vargas
  • Pedro Gonzalez <pegonzalezs@gmail.com>
  • diff --git a/account_statement_import_move_line/tests/test_account_bank_statement_import_move_line.py b/account_statement_import_move_line/tests/test_account_bank_statement_import_move_line.py index 9ac23f84..eb17af10 100644 --- a/account_statement_import_move_line/tests/test_account_bank_statement_import_move_line.py +++ b/account_statement_import_move_line/tests/test_account_bank_statement_import_move_line.py @@ -2,32 +2,15 @@ # License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0 from odoo import fields -from odoo.tests import TransactionCase +from odoo.tests import TransactionCase, tagged +@tagged("post_install", "-at_install") class TestAccountBankStatementImportMoveLine(TransactionCase): @classmethod def setUpClass(cls): - super(TestAccountBankStatementImportMoveLine, cls).setUpClass() - - cls.account_type = cls.env["account.account.type"].create( - {"name": "Test Account Type", "type": "other", "internal_group": "asset"} - ) - - cls.a_receivable = cls.env["account.account"].create( - { - "code": "TAA", - "name": "Test Receivable Account", - "internal_type": "receivable", - "user_type_id": cls.account_type.id, - } - ) - cls.partner = cls.env["res.partner"].create( - {"name": "Test Partner 2", "parent_id": False} - ) - cls.journal = cls.env["account.journal"].create( - {"name": "Test Journal", "type": "sale", "code": "TJS0"} - ) + super().setUpClass() + cls.partner = cls.env["res.partner"].create({"name": "Test Partner 2"}) cls.journal_bank = cls.env["account.journal"].create( {"name": "Test Journal Bank", "type": "bank", "code": "TJB0"} ) @@ -36,14 +19,11 @@ class TestAccountBankStatementImportMoveLine(TransactionCase): "name": "Test Invoice 3", "partner_id": cls.partner.id, "move_type": "out_invoice", - "journal_id": cls.journal.id, - "ref": "Test", "invoice_line_ids": [ ( 0, 0, { - "account_id": cls.a_receivable.id, "name": "Test line", "quantity": 1.0, "price_unit": 100.00, @@ -53,8 +33,9 @@ class TestAccountBankStatementImportMoveLine(TransactionCase): } ) cls.statement = cls.env["account.bank.statement"].create( - {"journal_id": cls.journal_bank.id} + {"name": "Test account bank statement import move line"} ) + cls.statement.journal_id = cls.journal_bank.id def test_global(self): self.invoice.action_post() @@ -68,7 +49,6 @@ class TestAccountBankStatementImportMoveLine(TransactionCase): { "statement_id": self.statement.id, "partner_id": self.partner.id, - "journal_ids": [(4, self.journal.id)], "allow_blocked": True, "date_type": "move", "move_date": fields.Date.today(), diff --git a/account_statement_import_move_line/views/account_bank_statement_view.xml b/account_statement_import_move_line/views/account_bank_statement_view.xml index ab637dcf..2d038221 100644 --- a/account_statement_import_move_line/views/account_bank_statement_view.xml +++ b/account_statement_import_move_line/views/account_bank_statement_view.xml @@ -3,18 +3,25 @@ account.bank.statement.form.population account.bank.statement - + - + + diff --git a/account_statement_import_move_line/views/account_journal_dashboard_view.xml b/account_statement_import_move_line/views/account_journal_dashboard_view.xml new file mode 100644 index 00000000..430fadab --- /dev/null +++ b/account_statement_import_move_line/views/account_journal_dashboard_view.xml @@ -0,0 +1,17 @@ + + + account.journal + + + + + Import Journal Items + + + + + diff --git a/account_statement_import_move_line/wizards/account_statement_line_create.py b/account_statement_import_move_line/wizards/account_statement_line_create.py index 33ccdff6..ffc66ac0 100644 --- a/account_statement_import_move_line/wizards/account_statement_line_create.py +++ b/account_statement_import_move_line/wizards/account_statement_line_create.py @@ -30,9 +30,15 @@ class AccountStatementLineCreate(models.TransientModel): move_date = fields.Date(default=fields.Date.context_today) move_line_ids = fields.Many2many("account.move.line", string="Move Lines") - @api.model def default_get(self, field_list): res = super().default_get(field_list) + res.update( + { + "target_move": "posted", + "date_type": "due", + "invoice": True, + } + ) active_model = self.env.context.get("active_model") if active_model == "account.bank.statement": statement = ( @@ -43,9 +49,6 @@ class AccountStatementLineCreate(models.TransientModel): if statement: res.update( { - "target_move": "posted", - "date_type": "due", - "invoice": True, "statement_id": statement.id, } ) @@ -55,7 +58,11 @@ class AccountStatementLineCreate(models.TransientModel): self.ensure_one() domain = [ ("reconciled", "=", False), - ("account_id.internal_type", "in", ("payable", "receivable")), + ( + "account_id.account_type", + "in", + ("asset_receivable", "liability_payable"), + ), ("company_id", "=", self.env.company.id), ] if self.journal_ids: @@ -122,7 +129,30 @@ class AccountStatementLineCreate(models.TransientModel): return res def create_statement_lines(self): - for rec in self: - if rec.move_line_ids and rec.statement_id: - rec.move_line_ids.create_statement_line_from_move_line(rec.statement_id) + if self.move_line_ids: + active_model = self.env.context.get("active_model") + if active_model == "account.journal": + journal = self.env["account.journal"].browse( + self.env.context.get("active_id") + ) + statement = self.env["account.bank.statement"].create( + { + "date": fields.Date.today(), + "name": _("%(journal_code)s Statement %(date)s") + % { + "journal_code": journal.code, + "date": fields.Date.today(), + }, + } + ) + statement.journal_id = journal.id + self.statement_id = statement.id + self.move_line_ids.create_statement_line_from_move_line(self.statement_id) + return { + "type": "ir.actions.act_window", + "res_model": "account.bank.statement", + "view_mode": "form", + "res_id": self.statement_id.id, + "target": "current", + } return True diff --git a/account_statement_import_move_line/wizards/account_statement_line_create_view.xml b/account_statement_import_move_line/wizards/account_statement_line_create_view.xml index db3a20bb..419abdd8 100644 --- a/account_statement_import_move_line/wizards/account_statement_line_create_view.xml +++ b/account_statement_import_move_line/wizards/account_statement_line_create_view.xml @@ -11,13 +11,13 @@ -