Skip to content

Commit

Permalink
Auto-update statement lines when adding/removing past invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
astirpe committed May 3, 2019
1 parent a63bb36 commit 3214fd6
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
15 changes: 12 additions & 3 deletions l10n_nl_tax_statement/models/account_move.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Onestein (<http://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import fields, models
Expand All @@ -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()
6 changes: 6 additions & 0 deletions l10n_nl_tax_statement/readme/HISTORY.rst
Original file line number Diff line number Diff line change
@@ -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
~~~~~~~~~~

Expand Down
1 change: 0 additions & 1 deletion l10n_nl_tax_statement/readme/ROADMAP.rst
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions l10n_nl_tax_statement/tests/test_l10n_nl_vat_statement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2017 Onestein (<https://www.onestein.eu>)
# Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from dateutil.relativedelta import relativedelta
Expand Down Expand Up @@ -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)

Expand Down
10 changes: 3 additions & 7 deletions l10n_nl_tax_statement/views/l10n_nl_vat_statement_view.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Onestein (<http://www.onestein.eu>)
<!-- Copyright 2017-2019 Onestein (<https://www.onestein.eu>)
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->

<odoo>
Expand Down Expand Up @@ -86,10 +86,6 @@
</group>
<group>
</group>
<div>Add/Remove the Undeclared Invoices listed below. Afterwards press the Update button in order to recompute the statement lines!</div>
<div class="oe_button_box" name="button_box">
<button name="statement_update" string="Update" states="draft" type="object" class="oe_stat_button" icon="fa-repeat"/>
</div>
</group>
<field name="unreported_move_ids">
<tree editable="bottom" create="false" delete="false" decoration-muted="l10n_nl_vat_statement_include != True">
Expand All @@ -99,8 +95,8 @@
<field name="partner_id" readonly="1"/>
<field name="amount" readonly="1"/>
<field name="l10n_nl_vat_statement_include" invisible="1"/>
<button name="add_move_in_statement" icon="fa fa-play" string="Add Invoice" type="object" attrs="{'invisible': [('l10n_nl_vat_statement_include', '=', True)]}"/>
<button name="unlink_move_from_statement" icon="fa fa-remove" string="Remove Invoice" type="object" attrs="{'invisible': [('l10n_nl_vat_statement_include', '!=', True)]}"/>
<button name="l10n_nl_add_move_in_statement" icon="fa-play" string="Add Invoice" type="object" attrs="{'invisible': [('l10n_nl_vat_statement_include', '=', True)]}"/>
<button name="l10n_nl_unlink_move_from_statement" icon="fa-remove" string="Remove Invoice" type="object" attrs="{'invisible': [('l10n_nl_vat_statement_include', '!=', True)]}"/>
</tree>
</field>
</page>
Expand Down

0 comments on commit 3214fd6

Please sign in to comment.