Skip to content

Commit

Permalink
[16.0][IMP] l10n_es_vat_book: Add tax agency
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian-RB authored and pedrobaeza committed Jun 27, 2024
1 parent e1edad3 commit 8586ae5
Show file tree
Hide file tree
Showing 30 changed files with 85 additions and 11 deletions.
2 changes: 1 addition & 1 deletion l10n_es_vat_book/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Libro de IVA
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:25810c16ed201d3d67fa149afda3fc8a1ebe2a902cb246a0efa806e6983625f9
!! source digest: sha256:958c31ab1c83d2c69b48caea8b3f15da45dde3a569ba0ec1b2168d3e76e3c669
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_vat_book/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

{
"name": "Libro de IVA",
"version": "16.0.1.3.2",
"version": "16.0.1.4.0",
"author": "PRAXYA, ForgeFlow, Tecnativa, Odoo Community Association (OCA)",
"website": "https://github.com/OCA/l10n-spain",
"license": "AGPL-3",
Expand Down
20 changes: 20 additions & 0 deletions l10n_es_vat_book/data/aeat_vat_book_map_data.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<field name="special_tax_group" eval="False" />
<field name="fee_type_xlsx_column">N</field>
<field name="fee_amount_xlsx_column">O</field>
<field
name="tax_agency_ids"
eval="[ Command.link(ref('l10n_es_aeat.aeat_tax_agency_spain')) ]"
/>
<field
name="tax_tmpl_ids"
eval="[
Expand Down Expand Up @@ -36,6 +40,10 @@
<field name="special_tax_group" eval="False" />
<field name="fee_type_xlsx_column">O</field>
<field name="fee_amount_xlsx_column">P</field>
<field
name="tax_agency_ids"
eval="[ Command.link(ref('l10n_es_aeat.aeat_tax_agency_spain')) ]"
/>
<field name="tax_account_id" ref="l10n_es.account_common_472" />
<field
name="tax_tmpl_ids"
Expand Down Expand Up @@ -96,6 +104,10 @@
<field name="name">IVA soportado no deducible</field>
<field name="book_type">received</field>
<field name="special_tax_group" eval="False" />
<field
name="tax_agency_ids"
eval="[ Command.link(ref('l10n_es_aeat.aeat_tax_agency_spain')) ]"
/>
<field
name="tax_tmpl_ids"
eval="[
Expand All @@ -111,6 +123,10 @@
<field name="special_tax_group">req</field>
<field name="fee_type_xlsx_column">P</field>
<field name="fee_amount_xlsx_column">Q</field>
<field
name="tax_agency_ids"
eval="[ Command.link(ref('l10n_es_aeat.aeat_tax_agency_spain')) ]"
/>
<field
name="tax_tmpl_ids"
eval="[
Expand All @@ -128,6 +144,10 @@
<field name="special_tax_group">req</field>
<field name="fee_type_xlsx_column">R</field>
<field name="fee_amount_xlsx_column">S</field>
<field
name="tax_agency_ids"
eval="[ Command.link(ref('l10n_es_aeat.aeat_tax_agency_spain')) ]"
/>
<field
name="tax_tmpl_ids"
eval="[
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/bg.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/ca.po
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ msgid "Tax Account Restriction"
msgstr "Restricció d'impost al compte"

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ msgid "Tax Account Restriction"
msgstr "Restricción de la cuenta de impuestos"

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr "Agencia Tributaria"
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/es_CO.po
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/es_CR.po
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/eu.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/gl.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/hr.po
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/l10n_es_vat_book.pot
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/pt_BR.po
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/sl.po
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/sv.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/i18n/vi.po
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,7 @@ msgid "Tax Account Restriction"
msgstr ""

#. module: l10n_es_vat_book
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_aeat_vat_book_map_line__tax_agency_ids
#: model:ir.model.fields,field_description:l10n_es_vat_book.field_l10n_es_vat_book__tax_agency_ids
msgid "Tax Agency"
msgstr ""
Expand Down
1 change: 1 addition & 0 deletions l10n_es_vat_book/models/aeat_vat_book_map_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def _selection_special_tax_group(self):
comodel_name="account.account.template",
string="Tax Account Restriction",
)
tax_agency_ids = fields.Many2many("aeat.tax.agency", string="Tax Agency")

def get_taxes(self, report):
self.ensure_one()
Expand Down
21 changes: 14 additions & 7 deletions l10n_es_vat_book/models/l10n_es_vat_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,12 @@ def get_pos_partner_ids(self):

@ormcache("self.id")
def get_special_taxes_dic(self):
map_lines = self.env["aeat.vat.book.map.line"].search(
[("special_tax_group", "!=", False)]
)
domain = [("special_tax_group", "!=", False)]
if self.tax_agency_ids:
domain += [
("tax_agency_ids", "in", [False] + self.tax_agency_ids.ids),
]
map_lines = self.env["aeat.vat.book.map.line"].search(domain)
special_dic = {}
for map_line in map_lines:
for tax in map_line.get_taxes(self):
Expand Down Expand Up @@ -437,9 +440,12 @@ def _calculate_vat_book(self):
# Searches for all possible usable lines to report
moves = rec._get_account_move_lines()
for book_type in ["issued", "received"]:
map_lines = self.env["aeat.vat.book.map.line"].search(
[("book_type", "=", book_type)]
)
domain = [("book_type", "=", book_type)]
if rec.tax_agency_ids:
domain += [
("tax_agency_ids", "in", [False] + rec.tax_agency_ids.ids),
]
map_lines = self.env["aeat.vat.book.map.line"].search(domain)
taxes = self.env["account.tax"]
accounts = {}
for map_line in map_lines:
Expand All @@ -462,7 +468,8 @@ def _calculate_vat_book(self):
lines = moves.filtered(
lambda line: (line.tax_ids | line.tax_line_id) & taxes
)
rec.create_vat_book_lines(lines, map_line.book_type, taxes)
if map_lines:
rec.create_vat_book_lines(lines, map_lines[:1].book_type, taxes)
# Issued
book_type = "issued"
issued_tax_lines = rec.issued_line_ids.mapped("tax_line_ids")
Expand Down
2 changes: 1 addition & 1 deletion l10n_es_vat_book/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ <h1 class="title">Libro de IVA</h1>
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:25810c16ed201d3d67fa149afda3fc8a1ebe2a902cb246a0efa806e6983625f9
!! source digest: sha256:958c31ab1c83d2c69b48caea8b3f15da45dde3a569ba0ec1b2168d3e76e3c669
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<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-spain/tree/16.0/l10n_es_vat_book"><img alt="OCA/l10n-spain" src="https://img.shields.io/badge/github-OCA%2Fl10n--spain-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/l10n-spain-16-0/l10n-spain-16-0-l10n_es_vat_book"><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-spain&amp;target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
<p>Módulo que calcula el libro de IVA español.</p>
Expand Down
12 changes: 12 additions & 0 deletions l10n_es_vat_book/tests/test_l10n_es_aeat_vat_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,15 @@ def test_model_vat_book(self):
)
self.assertGreaterEqual(len(report_xlsx[0]), 1)
self.assertEqual(report_xlsx[1], "xlsx")
# Check empty Vat Book
vat_book.write(
{
"tax_agency_ids": [
(4, self.env.ref("l10n_es_aeat.aeat_tax_agency_araba").id)
],
}
)
vat_book.button_calculate()
self.assertEqual(len(vat_book.issued_line_ids), 0)
self.assertEqual(len(vat_book.rectification_issued_line_ids), 0)
self.assertEqual(len(vat_book.issued_tax_summary_ids), 0)
1 change: 1 addition & 0 deletions l10n_es_vat_book/views/aeat_vat_book_map_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<field name="fee_amount_xlsx_column" />
<field name="tax_tmpl_ids" widget="many2many_tags" />
<field name="tax_account_id" />
<field name="tax_agency_ids" widget="many2many_tags" />
</tree>
</field>
</record>
Expand Down
14 changes: 13 additions & 1 deletion l10n_es_vat_book/views/l10n_es_vat_book.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_l10n_es_vat_book_tree" model="ir.ui.view">
<field name="name">l10n_es.vat.book.tree</field>
<field name="model">l10n.es.vat.book</field>
<field name="inherit_id" ref="l10n_es_aeat.view_l10n_es_aeat_report_tree" />
<field name="mode">primary</field>
<field name="arch" type="xml">
<field name="period_type" position="after">
<field name="tax_agency_ids" widget="many2many_tags" />
</field>
</field>
</record>
<record id="view_l10n_es_vat_book_form" model="ir.ui.view">
<field name="name">l10n_es.vat.book.form</field>
<field name="model">l10n.es.vat.book</field>
Expand Down Expand Up @@ -44,6 +55,7 @@
</field>
<group name="group_other_parameters" position="inside">
<field name="auto_renumber" />
<field name="tax_agency_ids" widget="many2many_tags" />
</group>
<xpath expr="//group[@name='group_declaration']" position="after">
<notebook>
Expand Down Expand Up @@ -96,7 +108,7 @@
<record model="ir.actions.act_window.view" id="action_l10n_vat_book_report_tree">
<field name="sequence" eval="2" />
<field name="view_mode">tree</field>
<field name="view_id" ref="l10n_es_aeat.view_l10n_es_aeat_report_tree" />
<field name="view_id" ref="view_l10n_es_vat_book_tree" />
<field name="act_window_id" ref="l10n_es_vat_book_action" />
</record>
<record model="ir.actions.act_window.view" id="action_l10n_vat_book_report_form">
Expand Down

0 comments on commit 8586ae5

Please sign in to comment.