From 3214fd6dca7d76711eb1ad8a73afa21df6cb2c1b Mon Sep 17 00:00:00 2001 From: Andrea Date: Fri, 3 May 2019 09:23:38 +0200 Subject: [PATCH] Auto-update statement lines when adding/removing past invoices --- l10n_nl_tax_statement/models/account_move.py | 15 ++++++++++++--- l10n_nl_tax_statement/readme/HISTORY.rst | 6 ++++++ l10n_nl_tax_statement/readme/ROADMAP.rst | 1 - .../tests/test_l10n_nl_vat_statement.py | 6 +++--- .../views/l10n_nl_vat_statement_view.xml | 10 +++------- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/l10n_nl_tax_statement/models/account_move.py b/l10n_nl_tax_statement/models/account_move.py index 83909f339..c765b4e69 100644 --- a/l10n_nl_tax_statement/models/account_move.py +++ b/l10n_nl_tax_statement/models/account_move.py @@ -1,4 +1,4 @@ -# Copyright 2017 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). from odoo import fields, models @@ -15,10 +15,19 @@ class AccountMove(models.Model): 'Include in VAT Statement' ) - def add_move_in_statement(self): + def l10n_nl_add_move_in_statement(self): for move in self: move.l10n_nl_vat_statement_include = True + self._l10n_nl_statement_update() - def unlink_move_from_statement(self): + def l10n_nl_unlink_move_from_statement(self): for move in self: move.l10n_nl_vat_statement_include = False + self._l10n_nl_statement_update() + + def _l10n_nl_statement_update(self): + model = self.env.context.get('params', {}).get('model', '') + obj_id = self.env.context.get('params', {}).get('id') + if model == 'l10n.nl.vat.statement' and isinstance(obj_id, int): + statement = self.env['l10n.nl.vat.statement'].browse(obj_id) + statement.statement_update() diff --git a/l10n_nl_tax_statement/readme/HISTORY.rst b/l10n_nl_tax_statement/readme/HISTORY.rst index 8eaca2910..14bdecb47 100644 --- a/l10n_nl_tax_statement/readme/HISTORY.rst +++ b/l10n_nl_tax_statement/readme/HISTORY.rst @@ -1,3 +1,9 @@ +11.0.2.1.1 +~~~~~~~~~~ + +* Fixes regarding inclusion of past invoices in report + https://github.com/OCA/l10n-netherlands/pull/220 + 11.0.2.1.0 ~~~~~~~~~~ diff --git a/l10n_nl_tax_statement/readme/ROADMAP.rst b/l10n_nl_tax_statement/readme/ROADMAP.rst index 39151cd0f..e658e7b0b 100644 --- a/l10n_nl_tax_statement/readme/ROADMAP.rst +++ b/l10n_nl_tax_statement/readme/ROADMAP.rst @@ -1,4 +1,3 @@ * Exporting in SBR/XBLR format not yet available * Limit invoices to last 5 year based on fiscal year end date (legal requirement) -* When adding invoices automatically recalculate the tax statement (now a manual recalculate is necessary) * The unreported from date is calculate as 1 quarter, it should take 1 fiscal year based on fiscal year end date diff --git a/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py b/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py index 88d0ce9a2..e5a19b209 100644 --- a/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py +++ b/l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py @@ -1,4 +1,4 @@ -# Copyright 2017 Onestein () +# Copyright 2017-2019 Onestein () # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). from dateutil.relativedelta import relativedelta @@ -295,10 +295,10 @@ def test_11_wizard_execute(self): def test_12_undeclared_invoice(self): self.invoice_1._onchange_invoice_line_ids() self.invoice_1.action_invoice_open() - self.invoice_1.move_id.add_move_in_statement() + self.invoice_1.move_id.l10n_nl_add_move_in_statement() for line in self.invoice_1.move_id.line_ids: self.assertTrue(line.l10n_nl_vat_statement_include) - self.invoice_1.move_id.unlink_move_from_statement() + self.invoice_1.move_id.l10n_nl_unlink_move_from_statement() for line in self.invoice_1.move_id.line_ids: self.assertFalse(line.l10n_nl_vat_statement_include) diff --git a/l10n_nl_tax_statement/views/l10n_nl_vat_statement_view.xml b/l10n_nl_tax_statement/views/l10n_nl_vat_statement_view.xml index 1596cd955..6ed89986f 100644 --- a/l10n_nl_tax_statement/views/l10n_nl_vat_statement_view.xml +++ b/l10n_nl_tax_statement/views/l10n_nl_vat_statement_view.xml @@ -1,5 +1,5 @@ - @@ -86,10 +86,6 @@ -
Add/Remove the Undeclared Invoices listed below. Afterwards press the Update button in order to recompute the statement lines!
-
-
@@ -99,8 +95,8 @@ -